-
Notifications
You must be signed in to change notification settings - Fork 172
Add Error case for PEM with headers fields #13
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
Conversation
PEM from RFC 1421 defines header fields https://datatracker.ietf.org/doc/html/rfc1421.html#section-9 this change detects header fields as an initial line that contains the colon char. PEM from RFC 7468 disallows https://datatracker.ietf.org/doc/html/rfc7468#section-2 > Unlike legacy PEM encoding [RFC1421], OpenPGP ASCII armor, and the > OpenSSH key file format, textual encoding does *not* define or permit > headers to be encoded alongside the data. originally from RustCrypto/utils#630
|
Recreated from https://github.com/RustCrypto/utils/pull/630.patch and squashed |
|
Looks good now, thanks! |
|
@tarcieri, It would be great to be able to return the label from the encapsulation boundary as context in the error cases where the label has been found, but something is wrong in the content.
|
|
Personally I would prefer not to reveal any part of what is potentially a private key. You can imagine a case where someone accidentally typos a |
|
@tarcieri I mean a case such as returning Error::Base64("RSA PRIVATE KEY") as opposed to Error::Base64 The alternative is to re-parse for encapsulation boundaries only. |
|
While that would probably be OK security-wise, it's also pretty tricky. As you noted, that would probably require using an owned There are a few hacks you could do (e.g. when |
Missed in PR RustCrypto#13 - add test coverage for new cases - refactor out decoding of encapsulated text - compromise here on estimating buffer size - slightly more overestimation, due to counting whitespace - faster due to no two-pass - required to ensure that we attempt a base64 decode of the first line before chopping the second line
Missed in PR RustCrypto#13 - add test coverage for new cases - refactor out decoding of encapsulated text - compromise here on estimating buffer size - slightly more overestimation, due to counting whitespace - faster due to no two-pass - required to ensure that we attempt a base64 decode of the first line before chopping the second line
Missed in PR #13 - add test coverage for new cases - refactor out decoding of encapsulated text - compromise here on estimating buffer size - slightly more overestimation, due to counting whitespace - faster due to no two-pass - required to ensure that we attempt a base64 decode of the first line before chopping the second line
PEM from RFC 1421 defines header fields
https://datatracker.ietf.org/doc/html/rfc1421.html#section-9
this change detects header fields as an initial line that contains the
colon char.
PEM from RFC 7468 disallows
https://datatracker.ietf.org/doc/html/rfc7468#section-2
originally from RustCrypto/utils#630