diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-08-26 23:15:14 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-25 15:08:31 -0400 |
commit | 22760c4899cb7e8b643f3f572ce93fb6587b31b8 (patch) | |
tree | 8d2d811ed7766c8b2fa68d72723f53fc16c3d575 /src/common/crypto_ed25519.c | |
parent | 006e6d3b6f52e193b14dc17db4502e14f9ffeb82 (diff) | |
download | tor-22760c4899cb7e8b643f3f572ce93fb6587b31b8.tar.gz tor-22760c4899cb7e8b643f3f572ce93fb6587b31b8.zip |
Restore the operation of extra_strong in ed25519_secret_key_generate
Diffstat (limited to 'src/common/crypto_ed25519.c')
-rw-r--r-- | src/common/crypto_ed25519.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/common/crypto_ed25519.c b/src/common/crypto_ed25519.c index 44c9e5e31b..9dedac2bd7 100644 --- a/src/common/crypto_ed25519.c +++ b/src/common/crypto_ed25519.c @@ -21,10 +21,15 @@ int ed25519_secret_key_generate(ed25519_secret_key_t *seckey_out, int extra_strong) { - (void) extra_strong; - if (ed25519_ref10_seckey(seckey_out->seckey) < 0) - return -1; - return 0; + int r; + uint8_t seed[32]; + if (! extra_strong || crypto_strongest_rand(seed, sizeof(seed)) < 0) + crypto_rand((char*)seed, sizeof(seed)); + + r = ed25519_ref10_seckey_expand(seckey_out->seckey, seed); + memwipe(seed, 0, sizeof(seed)); + + return r < 0 ? -1 : 0; } int @@ -51,10 +56,10 @@ ed25519_public_key_generate(ed25519_public_key_t *pubkey_out, int ed25519_keypair_generate(ed25519_keypair_t *keypair_out, int extra_strong) { - (void) extra_strong; - - if (ed25519_ref10_keygen(keypair_out->pubkey.pubkey, - keypair_out->seckey.seckey)<0) + if (ed25519_secret_key_generate(&keypair_out->seckey, extra_strong) < 0) + return -1; + if (ed25519_public_key_generate(&keypair_out->pubkey, + &keypair_out->seckey)<0) return -1; return 0; } |