briansmith / ring

Safe, fast, small crypto using Rust
Other
3.7k stars 697 forks source link

Add support for verifying P-521 signatures with SHA-512 and SHA-384 #1771

Open briansmith opened 10 months ago

briansmith commented 10 months ago

Work plan:

Work that was already done to support this:

briansmith commented 10 months ago

Regarding the test case data generation: I created a branch b/generate-curve that contains the old (current) test case data generator. See https://github.com/briansmith/ring/blob/b/generate-curve/boringssl/tool/generate_tests.cc. I am fine with removing the point multiplication test generation from generate_tests.cc as those were already usurped by crypto/fipsmodule/ec/make_ec_scalar_base_mult_tests.go. I would be fine with modifying the test of generate_tests.cc to resolve the Montgomery-encoding issues and to add P-521 test data generation as a stopgap. I am also open to alternate solutions regarding how the test data files get generated. The important thing is that we have the same level of test coverage for P-521 as we have for P-384, and that we have automation for extending these tests easily across all curves.

briansmith commented 10 months ago

Regarding benchmarks: It turns out that the agreement (ECDH) benchmarks are sufficient for the private key operation side, as base point multiplication is handled by compute_public_key benchmarks and variable-point benchmarks are handled by the agree_ephemeral benchmarks. I generalized the X25519 benchmarks to support all 3 currently-supported algorithms in PR #1773.

briansmith commented 10 months ago

Here is the original version of mk/generate_curves.py that actually generated C code: gfp_generate.py.txt

vkrasnov commented 8 months ago

I think most of the plan is now addressed. The benchmarks are merged generate_curves.py generates the constants for p384 I have a PR open to avoid montgomery encoding in base point mul tests and regenerated the tests with generate_tests.cc I also split my PR into two, with the first parts simply making the P384 code more generic