-
Notifications
You must be signed in to change notification settings - Fork 12
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
Should this spec define byte prefixes associated with ASN.1 RSA Keys? #42
Comments
I supposed that it would be simple (#41 (comment)), but the length encoding is more complex than I remembered. The RSAPublicKey ASN.1 type is a sequence (array) containing two integers. Looking at two example keys from multiformats/multicodec#233 (comment), the initial bytes are the following for a 2048-bit key: Looking at what those byte values mean: Length encoding is 1 byte if the length is <= 127, in which case the length is encoded in that byte ("short mode"). If the length is > 127, one byte with the high bit set encodes the number of following bytes in the lower 7 bits, and then is followed by that many bytes that encode the length ("long mode"). We see the short mode in this example in the length of the public exponent ( The leading zero for an integer value is supposed to be used if the high bit of the integer value is set, as the high bit otherwise would be interpreted as a sign bit (reference). I assume this is too much complexity for this specification, but if it is desired to put this into code, I could try to do so. |
Imo, it is too much complexity for the specification, unless we do the same to all the other key representations.... It might be better to just point to a good source for this information from each key representation. |
This was done in #45. |
Originally reported here: #41 (comment)
IMO, it's a nice to have, that would make is possible for some implementations to skip importing bulky ASN.1 libraries as @dlongley mentions.
The text was updated successfully, but these errors were encountered: