]> source.dussan.org Git - rspamd.git/commitdiff
Fix eddsa keys generation
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 3 Feb 2016 00:40:43 +0000 (00:40 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 3 Feb 2016 00:40:43 +0000 (00:40 +0000)
src/libcryptobox/ed25519/ref.c

index 5ae5eb898c2e0adaeb95b670991435a2ec09200e..589556e9cc9f123b69597142d4c7fe38b2700b86 100644 (file)
@@ -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));