-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Generated EC key has wrong length #4861
Comments
In 10,000 iterations (above), it generates 30-50 "bad" keys. |
OTP-22.0 is also affected and probably all previous versions. |
I did some digging. The
|
More digging. afaict, the private key should be the same length as the "order" of the curve, which, for the named curves, is defined in |
… maint * hans/crypto/zero_pad_ec_keys-24/GH-4861/OTP-17442: crypto: EC key padding crypto: Test generated EC private key length
… maint * hans/crypto/zero_pad_ec_keys-23/GH-4861/OTP-17442: crypto: EC key padding crypto: Test generated EC private key length
… maint * hans/crypto/zero_pad_ec_keys-22/GH-4861/OTP-17442: crypto: EC key padding crypto: Test generated EC private key length
Fixed in maint and master, and a patch is planned to be released in:
Thanks for the report @rlipscombe ! |
… maint-23 * hans/crypto/zero_pad_ec_keys-23/GH-4861/OTP-17442: crypto: EC key padding crypto: Test generated EC private key length
… maint-22 * hans/crypto/zero_pad_ec_keys-22/GH-4861/OTP-17442: crypto: EC key padding crypto: Test generated EC private key length
… maint-24 * hans/crypto/zero_pad_ec_keys-24/GH-4861/OTP-17442: crypto: EC key padding crypto: Test generated EC private key length
Describe the bug
EC private keys on the secp256r1 curve should have 32-byte private keys. public_key:generate_key/1 occasionally generates 31-byte keys.
To Reproduce
Expected behavior
The private key (binary) should be zero-prefixed to the correct length.
References
RFC5915 (section 3) -- https://www.rfc-editor.org/rfc/rfc5915.html#section-3
RFC3447 (section 4.1) -- https://www.rfc-editor.org/rfc/rfc3447#section-4.1
Affected versions
OTP-23.0.3
OTP-24.0
The text was updated successfully, but these errors were encountered: