-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
PublicKeyAlgorithm does not encode None parameters as ASN1 Null element for RSA Keys #251
Comments
You're conflating the ASN.1 types Imagine that you really do want to force the generation of the
|
So I found where this behavior can be non-intuitive: round-tripping or copying from one object to another with native OrderedDict representation.
The native representation has to use a
|
The "native" representation isn't intended to retain all information: >>> GraphicString("Hello").dump() == VisibleString("Hello").dump()
False
>>> GraphicString("Hello").native == VisibleString("Hello").native
True If you're writing code that needs to emit different algorithms, either leave out the parameters when not needed, or always specify them with the correct value. >>> PublicKeyAlgorithm({"algorithm": "rsa"}).dump().hex()
'300d 0609 2a864886f70d010101 0500'
>>> PublicKeyAlgorithm({"algorithm": "ed25519"}).dump().hex()
'3005 0603 2b6570' ASN.1 and its encodings are confusing and error-prone, the standards (like X.509) building upon it even more so. Perhaps documentation could be improved, e.g. a "common pitfalls" page. |
PublicKeyAlgorithm has an optional parameters, RSA keys do not specify any parameters and when asn1crypto encodes an RSA key with
None
parameters it omits the parameters entirely. This is incorrect according to rfc4055 section 1.2 which states "the parameters field MUST contain NULL". This seems to be a known requirement but this isn't injecting the expected NULL ASN1 element.Prints:
Expected output:
The incorrect output can cause downstream consumers to fail to parse the output from asn1crypto.
However, if I pass in asn1crypto's Null() it does work. Is it expected that I need to pass in Null when construction the PublicKeyALgorithm?
The text was updated successfully, but these errors were encountered: