Implement deterministic ECDSA sign (RFC6979)#9223
Conversation
|
Is it possible to implement the deterministic signature schema via special EVP ctrl call? |
|
@beldmit It seems all signing calls would finally call EC_KEY_METHOD->sign_sig, in this case it would be ossl_ecdsa_sign_sig defined in crypto/ec/ec_kmeth.c . However, this method doesn't accept parameter about hash method, as I think, this has to be changed... |
|
@beldmit I missunderstood your meaning just now.... |
|
Maybe call sign_setup directly in EVP, initialize k_reverse and r before calling sign_sig is a good way? |
|
Okay, I will change the code tonnight. |
|
@JemmyLoveJenny At a minimum, you should integrate the test vectors from RFC 6979 as plaintext EVP tests. If you need help with that, my team has some tooling. Tagging @romen |
|
I suggest that you only add new APIs when it's actually needed. We
want users to switch to the EVP API. If it's easy to do with the
EVP API, I suggest you only add support for it in the EVP API.
|
|
@kroeckx Actually, the EVP ctx pmeth->sign would call ECDSA_sign. You mean that I can skip that method and call the kmeth->sign_sig directly in EVP ? |
|
@bbbrumley Yes, I will integrate these test vectors into EVP test finally. |
fd0175c to
1bd48bf
Compare
|
@kroeckx |
|
I have some questions about the checks
|
Yes.
Please give your legal name in English. |
|
@beldmit Updated according to your suggestions |
There was a problem hiding this comment.
I thought this code looked familiar.
Did you look at HMAC_DRBG.c ?
@paulidale would there be some way to rework this so it can use the drbg code?
Have a look at test/drbg_cavs_test.c for an example of how to drive the code..
|
Travis failures are relevant. You have a memory leak somewhere. |
The similarity is great. Direct sharing of internal code between the two possibly isn't a great idea but if there was a way of using the HMAC-DRBG to get the same output, that would be worthwhile. |
|
@slontis Is the Travis ECDSA tests still failing? I thought it was solved in the most recent commit. |
|
Maybe you havent pushed the new commits? |
|
@slontis |
|
I looked in travis 26035.2 (open the raw log and search for not ok) |
|
If you look at the options for each build e.g for 26035.2 you will see what options it uses.. |
|
@slontis Oh, I see it... but it is confusing to me, some ECDH tests failed, even tests unrelated to EC failed... |
|
No problems.. All those tests use ECDSA. Fix the one problem in a simpler test (which is a memory leak) and the others will most likely all be fixed also.. |
|
@mspncp I noticed that OpenSSL has recently changed the If I understood it correctly, the fetched I read the I wonder if this is the correct way of specifying custom entropy and nonce? |
Currently, this is the only way to feed a random number generator specific seed material. Another place that does this is the FIPS known answer tests. Look for |
This reverts commit 9b0e818. Turns out ECDSA signatures aren't deterministic at the moment, meaning the signed executables are always different when re-built, due to the nonce included in the signature. We need to wait till OpenSSL gets support for deterministic ECDSA signatures, or run ahead and switch to EdDSA/ED25519, which uses a deterministic nonce, out of the box. Could not find evidence that Windows supports such code signatures, so either solutions will have to wait. Relevant links: - OpenSSL PR: openssl/openssl#9223 - OpenSSL Issue: openssl/openssl#2078 - RFC: https://tools.ietf.org/html/rfc6979
|
What is the status of this PR? How can we get it merged? And also, sorry if this is completely off-topic, but how does BoringSSL and OpenSSL sync feature wise? Does Google's BoringSSL get updated with features X, Y, Z when added to OpenSSL? I.e. if we get deterministic signing (RFC6979) merged into OpenSSL, is it likely that BoringSSL will follow and implement that/cherry-pick that commit and merge it into their code base? |
|
May I ask whether there are still plans to get this PR (deterministic signing ala RFC6979) merged. For example, "Knot DNS" now supports deterministic zone signing, but only when linked with GnuTLS. I really do think we should have an interoperable implementation in at least a 3.1 release, if not in any earlier versions... |
I'd say why not. If someone brings it up-to-date with the current master branch which means making it into a provided implementation. |
What do you mean by a "provided implementation"? Do you mean a separate provider? Or do you mean a feature (EVP_PKEY_CTX control operation?) of the default implementation? Any volunteers to resume this effort? |
|
I mean a feature of the existing implementation. The question is if it should be a separate algorithm or just a parameter of the existing ECDSA. |
|
OTC: Can be reviewed through the normal review process. Please rebase |
@openssl/otc These questions should be answered to allow @JemmyLoveJenny to continue the work @JemmyLoveJenny , despite the delays, are you still willing to work on this PR? |
Yes, I'm still willing to work on this PR. But as you have mentioned, I need to know what to do next. |
|
This PR has been closed. It was waiting for the creator to make requested changes but it has not been updated for 90 days. |
This PR is based off the contributions in PR openssl#9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Use OpenSSL's HMAC_DRBG via the EVP_RAND_CTX interface. To do this some behaviour of the DRBG needed to be disabled via a new OSSL_PARAM. A nonce_type is passed around in the API's, just in case there are future deterministic algorithms.
|
Hi @Jemmy1228 I have created a new PR #18809 based off your great work. (I have referenced you in the commit - hope that is ok). |
This PR is based off the contributions in PR openssl#9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Use a variant of OpenSSL's HMAC_DRBG via the EVP_RAND_CTX interface. A nonce_type is passed around in the API's, just in case there are future deterministic algorithms.
This PR is based off the contributions in PR openssl#9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Add a KDF HMAC_DRBG implementation that shares code with the RAND HMAC_DRBG. A nonce_type is passed around inside the Signing API's, in order to support any future deterministic algorithms.
This PR is based off the contributions in PR openssl#9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Add a KDF HMAC_DRBG implementation that shares code with the RAND HMAC_DRBG. A nonce_type is passed around inside the Signing API's, in order to support any future deterministic algorithms.
This PR is based off the contributions in PR openssl#9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Add a KDF HMAC_DRBG implementation that shares code with the RAND HMAC_DRBG. A nonce_type is passed around inside the Signing API's, in order to support any future deterministic algorithms.
This PR is based off the contributions in PR #9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Add a KDF HMAC_DRBG implementation that shares code with the RAND HMAC_DRBG. A nonce_type is passed around inside the Signing API's, in order to support any future deterministic algorithms. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from #18809)
This PR is based off the contributions in PR openssl#9223 by Jemmy1228. It has been modified and reworked to: (1) Work with providers (2) Support ECDSA and DSA (3) Add a KDF HMAC_DRBG implementation that shares code with the RAND HMAC_DRBG. A nonce_type is passed around inside the Signing API's, in order to support any future deterministic algorithms. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from openssl#18809)
Implements RFC6979 deterministic ECDSA/DSA sign (in this commit, only ECDSA is available)
ECDSA deterministic sign is now available by specifying "ecdsa_nonce_type:deterministic" when signing.
for example:
Maybe fixed #2078
Checklist
I haven't thought of that there would be so many comments in this PR.
I read through this thread and list the up-to-date TO-DOs here: