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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

p521: initial ecdsa support with FIPS 186-4 test vectors #956

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

tarcieri
Copy link
Member

@tarcieri tarcieri commented Nov 9, 2023

Initial ecdsa feature and test vectors to ensure it's working.

Due to P-521's unusual modulus size, we can't use the upstream ecdsa::{SigningKey, VerifyingKey} types (although we are able to use the generic implementation of ECDSA). The ecdsa crate currently includes bounds for the digest size in several places, including the RFC6979 implementation, which are incompatible with P-521, which uses a 66-byte serialized scalar size along with SHA-521, which emits a 64-byte digest. Fixing that will require breaking changes to the ecdsa crate.

To work around this, newtypes for SigningKey and VerifyingKey have been added. They largely wrap the inner types, but don't use RFC6979 and instead randomly generate R each time signing is performed (using an on-by-default getrandom feature which enables rand_core::OsRng).

FIPS 186-4 test vectors adapted from SigGen.txt in 186-4ecdsatestvectors.zip from:

https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/digital-signatures

cc @MasterAwesome

Initial `ecdsa` feature and test vectors to ensure it's working.

Due to P-521's unusual modulus size, we can't use the upstream
`ecdsa::{SigningKey, VerifyingKey}` types (although we are able to use
the generic implementation of ECDSA). The `ecdsa` crate currently
includes bounds for the digest size in several places, including the
RFC6979 implementation, which are incompatible with P-521, which uses a
66-byte serialized scalar size along with SHA-521, which emits a 64-byte
digest.

To work around this, newtypes for `SigningKey` and `VerifyingKey` have
been added. They largely wrap the inner types, but don't use RFC6979 and
instead randomly generate `R` each time signing is performed (using an
on-by-default `getrandom` feature which enables `rand_core::OsRng`).

FIPS 186-4 test vectors adapted from `SigGen.txt` in
`186-4ecdsatestvectors.zip` from:

https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program/digital-signatures
@tarcieri tarcieri merged commit 62a4091 into master Nov 9, 2023
122 checks passed
@tarcieri tarcieri deleted the p521/ecdsa branch November 9, 2023 21:47
@tarcieri tarcieri mentioned this pull request Nov 10, 2023
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

Successfully merging this pull request may close these issues.

1 participant