1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 02:25:14 -07:00

Add a compile-time switch to create non-deterministic signatures

This commit is contained in:
Frank Denis 2017-10-06 15:35:07 +02:00
parent 381080bf02
commit 0dd8338b83
2 changed files with 9 additions and 0 deletions

View File

@ -5,6 +5,7 @@
#include "crypto_sign_ed25519.h" #include "crypto_sign_ed25519.h"
#include "ed25519_ref10.h" #include "ed25519_ref10.h"
#include "private/curve25519_ref10.h" #include "private/curve25519_ref10.h"
#include "randombytes.h"
#include "utils.h" #include "utils.h"
void void
@ -40,6 +41,10 @@ _crypto_sign_ed25519_detached(unsigned char *sig, unsigned long long *siglen_p,
az[31] |= 64; az[31] |= 64;
_crypto_sign_ed25519_ref10_hinit(&hs, prehashed); _crypto_sign_ed25519_ref10_hinit(&hs, prehashed);
#ifdef ED25519_NONDETERMINISTIC
randombytes_buf(nonce, 32);
crypto_hash_sha512_update(&hs, nonce, 32);
#endif
crypto_hash_sha512_update(&hs, az + 32, 32); crypto_hash_sha512_update(&hs, az + 32, 32);
crypto_hash_sha512_update(&hs, m, mlen); crypto_hash_sha512_update(&hs, m, mlen);
crypto_hash_sha512_final(&hs, nonce); crypto_hash_sha512_final(&hs, nonce);

View File

@ -1311,5 +1311,9 @@ int main(void)
== crypto_sign_ed25519_secretkeybytes()); == crypto_sign_ed25519_secretkeybytes());
assert(crypto_sign_statebytes() == crypto_sign_ed25519ph_statebytes()); assert(crypto_sign_statebytes() == crypto_sign_ed25519ph_statebytes());
#ifdef ED25519_NONDETERMINISTIC
exit(0);
#endif
return 0; return 0;
} }