Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conf: fix support for private key PEM files other than PKCS#8 #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikewadsten
Copy link

The Mbed TLS bug being worked around
(Mbed-TLS/mbedtls#3896)
affects all PEM inputs.
conf_set_pem only applied the workaround to certificates and PKCS#8 encoded keys.

Copy link
Collaborator

@MathisMARION MathisMARION left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello and thank you for your contribution!

Interestingly, this syntax is not included in the official PEM file format specification (RFC 7468). However most crypto library implement it so it makes sense to support it (OpenSSL, MbedTLS, GnuTLS).

strstr(dest_str, "-----BEGIN PRIVATE KEY-----"))
strstr(dest_str, "-----BEGIN PRIVATE KEY-----") ||
strstr(dest_str, "-----BEGIN EC PRIVATE KEY-----") ||
strstr(dest_str, "-----BEGIN RSA PRIVATE KEY-----"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wi-SUN only supports EC. RSA support is not necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point - I'll remove that and amend the commit. Thanks!

@mikewadsten
Copy link
Author

Hello and thank you for your contribution!

Interestingly, this syntax is not included in the official PEM file format specification (RFC 7468). However most crypto library implement it so it makes sense to support it (OpenSSL, MbedTLS, GnuTLS).

RFC 7468 specifically is about textual encodings of, among other things, PKCS structures, so I'm not surprised that RFC doesn't touch on other content structures. -----BEGIN EC PRIVATE KEY----- is mentioned in RFC 5915 as a "popular format" of using PEM encoding to store the key.

@MathisMARION
Copy link
Collaborator

Hello and thank you for your contribution!
Interestingly, this syntax is not included in the official PEM file format specification (RFC 7468). However most crypto library implement it so it makes sense to support it (OpenSSL, MbedTLS, GnuTLS).

RFC 7468 specifically is about textual encodings of, among other things, PKCS structures, so I'm not surprised that RFC doesn't touch on other content structures. -----BEGIN EC PRIVATE KEY----- is mentioned in RFC 5915 as a "popular format" of using PEM encoding to store the key.

Good to know! Thank you for providing this reference. Do you mind mentioning it in the commit log?

The Mbed TLS bug being worked around
(Mbed-TLS/mbedtls#3896)
affects _all_ PEM inputs.
`conf_set_pem` only applied the workaround to certificates and
PKCS#8 encoded keys.

`-----BEGIN PRIVATE KEY-----` is the PKCS#8 PEM header called out in
RFC 7468. While `-----BEGIN EC PRIVATE KEY-----` is not mentioned in
that RFC, RFC 5915 does describe it as a "popular format" for using
PEM encoding to store an EC key, and most crypto libraries implement it.
@mikewadsten
Copy link
Author

Good to know! Thank you for providing this reference. Do you mind mentioning it in the commit log?

Done.

@MathisMARION
Copy link
Collaborator

Great! I have applied this patch onto our private development repository. It will be released as part of v2.3.2, and I will close this PR when it is made public.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants