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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Length in DER should use minimum possible bytes #53

Open
Weetbix opened this issue Jun 19, 2019 · 1 comment
Open

Length in DER should use minimum possible bytes #53

Weetbix opened this issue Jun 19, 2019 · 1 comment

Comments

@Weetbix
Copy link

Weetbix commented Jun 19, 2019

Hi 馃憢

Firstly thanks for the work and the great library :)

Currently in your DER encoding you are not stripping any leading 0 value octets.

When generating a PKCS8 PEM from a 4096 bit rsa key using derToPKCS8PEM the top level sequence contains leading 0's in the value of its length.

So for example:

30 83 00 02 23 . . . . . . .

The same key using OpenSSL will produce:

30 82 02 22

If you look at the DER spec it specifies that these should be stripped during DER encoding:

10.1 Length forms
The definite form of length encoding shall be used, encoded in the minimum number of octets. [Contrast with 8.1.3.2 b).]

https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf

@amlynarczyk
Copy link

Have you ever found a workaround to that?

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

No branches or pull requests

2 participants