From cd757ac4e75c57b2f79da6eea9f9ccea8589310a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 3 Feb 2016 00:40:43 +0000 Subject: [PATCH] Fix eddsa keys generation --- src/libcryptobox/ed25519/ref.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libcryptobox/ed25519/ref.c b/src/libcryptobox/ed25519/ref.c index 5ae5eb898..589556e9c 100644 --- a/src/libcryptobox/ed25519/ref.c +++ b/src/libcryptobox/ed25519/ref.c @@ -28,8 +28,12 @@ ed_seed_keypair_ref (unsigned char *pk, unsigned char *sk, const unsigned char *seed) { ge_p3 A; + EVP_MD_CTX sha_ctx; + + g_assert (EVP_DigestInit (&sha_ctx, EVP_sha512()) == 1); + EVP_DigestUpdate (&sha_ctx, seed, 32); + EVP_DigestFinal (&sha_ctx, sk, NULL); - memmove (sk, seed, 32); sk[0] &= 248; sk[31] &= 63; sk[31] |= 64; @@ -46,11 +50,10 @@ ed_seed_keypair_ref (unsigned char *pk, unsigned char *sk, int ed_keypair_ref (unsigned char *pk, unsigned char *sk) { - unsigned char seed[rspamd_cryptobox_HASHBYTES]; + unsigned char seed[32]; int ret; ottery_rand_bytes (seed, sizeof (seed)); - rspamd_cryptobox_hash (seed, seed, sizeof (seed), NULL, 0); ret = ed_seed_keypair_ref (pk, sk, seed); rspamd_explicit_memzero (seed, sizeof (seed)); -- 2.39.5