Conversation
|
Nice to see progress in ed25519 support in OpenSSL. From a benchmark I did on an Intel core i7 processor: Libsodium (ISC License): BoringSSL (with optimisations enabled release build): ed25519-donna (public domain): As a comparison P-256 in OpenSSL 1.1.0e: [contains a correction for Boringssl optimisations thanks to davidben] |
|
There are licensing issues. We'll improve the speed over time. |
|
@richsalz Thank you for your reply. |
|
It's an unknown path, as opposed to someone explicitly signing the CLA. Shrug. Speed will be addressed later. |
|
@yugits Are you building with optimizations on? BoringSSL's default standalone build is primarily intended for those of us working on it and produces a debug build. |
kaduk
left a comment
There was a problem hiding this comment.
A commit message mentions tests from "RFC 8022", which is a typo for RFC 8032.
It's good to have those test vectors; are there other implementations we could do additional interop testing with?
crypto/evp/m_sigver.c
Outdated
There was a problem hiding this comment.
We're happy repurposing the vtable entry in the pmeth as an indicator of what operation is being performed, as opposed to a more explicit signal?
crypto/ec/ecx_meth.c
Outdated
There was a problem hiding this comment.
What sort of cases benefit from "pass 0 to use the pkey_id from the ameth" as opposed to having callers that would otherwise pass 0 do the dereferencing themselves? (That is, are we introducing the possibility for subtle bugs later on?)
There was a problem hiding this comment.
Since there are only two cases that use the "pass 0" we don't gain much from that so I've removed it.
doc/man7/Ed25519.pod
Outdated
There was a problem hiding this comment.
It's probably worth mentioning RFC 8032 here, to give the reader a hint as to what "Pure"EdDSA is and how it relates to the "EdDSA" that they are more likely (?) to have heard of.
|
@richsalz If it's public domain, and I took the code and submitted it under CLA, would that pass the legal requirements? |
4edb02e to
009d61a
Compare
|
@davidben I added a correction for that in my previous post. I should also mention that the values are fluctuating and there's an error margin that should be taken into account. I might come back to that later. I also tested this WIP by calling the ED25519_sign and ED25519_verify functions through EVP_DigestSign and EVP_DigestVerify and got signing and verification speeds that were similar to the BoringSSL release build with optimisations on. Are there any plans to include the amd64 optimisations for ed25519 (see the amd64-51-30k and amd64-64-24k implementations) into BoringSSL?
Do you have any thoughts on ARM (NEON) specific optimisations for ed25519? Because there is an ARM assembly language implementation for X25519 available in BoringSSL, but there's no ARM assembly language implementation for ed25519. Speaking about ARM... BoringSSL (release build): ed25519-donna: As a comparison, P-256 in OpenSSL 1.1.0e: PS: @floodyberry Do you know why ed25519-donna is faster than ref10 based implementations of ed25519 on an ARM processor? |
|
My goal with this PR is to get the appropriate EVP API in place and see that it behaves as expected (test vectors and signature verification OK). To do that we need a low level implementation and the easiest was to just use what we already have: we'd actually removed Ed25519 code in the past because it was unused. The internal API between OpenSSL and the low level algorithm is very simple: 5 functions covering X25519 and Ed25519. It can be replaced with optimised versions in future. Adding X448/Ed448 support should also be much easier by following a similar model but we're lacking the low level algorithm code in a form we can use. |
|
@snhensen What would be needed to get this PR into OpenSSL? As for ed448, The best C code implementation of ed448 at the moment would be probably the implementation of the author of ed448 ( Mike Hamburg [ @bitwiseshiftleft ] ) in libdecaf. This version can verify the testvectors for ed448 in RFC8032 correctly and contains a reference implementation and implementations with inline assembly code optimisations for x86/64 and ARM (NEON) processors. For those who are interested in ed448, below is a mini-tutorial of how to work with ed448, if you can compile the code on your computer:
But this is also the point where most people experience problems. Note the complexity of the makefile: It consists of several phases such as first regenerating files in the "GENERATED" folder, then compiling a program to generate tables, and then finally compiling the library itself. There are implementations for other architectures (arch_32, arch_arm_32, arch_neon, arch_ref64) available, but compiling for these architectures could require more changes to the makefile or alternatively you could compile and link the files manually.
Compiling the library required the generation and linking of several object files, such as the ones below. x448/ed448 specific: build/obj/ed448goldilocks/decaf.o build/obj/ed448goldilocks/elligator.o build/obj/ed448goldilocks/scalar.o build/obj/ed448goldilocks/eddsa.o build/obj/ed448goldilocks/decaf_tables.o x25519/ed448 specific: build/obj/curve25519/decaf.o build/obj/curve25519/elligator.o build/obj/curve25519/scalar.o build/obj/curve25519/eddsa.o build/obj/curve25519/decaf_tables.o |
|
Update: cleanse some sensitive data, rebase against master. Taken out of WIP. This should now be ready for review. |
Reinstate Ed25519 algorithm to curv25519.c this is largely just a copy of the code from BoringSSL with some adjustments so it compiles under OpenSSL.
Rename and change ED25519_keypair_from_seed to ED25519_public_from_private to be consistent with X25519 API. Modidy ED25519_sign to take separate public key argument instead of requiring it to follow the private key.
Make X25519 key method more flexible by removing hard coding of NID_X25519 OID. Since the parameters and key syntax between ED25519 and X25519 are almost identical they can share a lot of common code.
|
Update: rebased against master to resolve conflict. |
|
Thanks to everyone for the comments. Pushed. |
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reinstate Ed25519 algorithm to curv25519.c this is largely just a copy of the code from BoringSSL with some adjustments so it compiles under OpenSSL. Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Rename and change ED25519_keypair_from_seed to ED25519_public_from_private to be consistent with X25519 API. Modidy ED25519_sign to take separate public key argument instead of requiring it to follow the private key. Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Make X25519 key method more flexible by removing hard coding of NID_X25519 OID. Since the parameters and key syntax between ED25519 and X25519 are almost identical they can share a lot of common code. Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Since ED25519 doesn't have an associated digest it needs custom sign/verify routines to handle ASN.1 signatures. Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Add Ed25519 certificate verify test using certificate from draft-ietf-curdle-pkix-04 and custom generated root certificate. Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Reviewed-by: Rich Salz <[email protected]> (Merged from #3503)
Checklist
This PR includes provisional Ed25519 support. It includes all the test data from RFC8022 and verifies the sample certificate from draft-ietf-curdle-pkix-04
The API uses the "one shot" EVP_DigestSign/EVP_DigestVerify functions in a new public key method.
The low level algorithm uses the Ed25519 code from BoringSSL with a few minor changes, this is similar to the unused code we removed when we added X25519 support. This may well need some further work: for example it doesn't currently cleanse sensitive data from memory. At some point we will hopefully have fast assembly language versions of Ed25519/X25519.
TLS support is not included yet: that will be a separate PR.