From: Vsevolod Stakhov Date: Fri, 6 Feb 2015 17:15:08 +0000 (+0000) Subject: Set curve25519 bits on keypair generation. X-Git-Tag: 0.9.0~755 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5773d9e998e626328bf49a655d49df4810e6f980;p=rspamd.git Set curve25519 bits on keypair generation. --- diff --git a/src/libcryptobox/curve25519/curve25519-donna-c64.c b/src/libcryptobox/curve25519/curve25519-donna-c64.c index 2d693ee44..e6a5045ad 100644 --- a/src/libcryptobox/curve25519/curve25519-donna-c64.c +++ b/src/libcryptobox/curve25519/curve25519-donna-c64.c @@ -482,17 +482,10 @@ int curve25519 (u8 *, const u8 *, const u8 *); int curve25519 (u8 *mypublic, const u8 *secret, const u8 *basepoint) { limb bp[5], x[5], z[5], zmone[5]; - uint8_t e[32]; int i; - for (i = 0; i < 32; ++i) - e[i] = secret[i]; - e[0] &= 248; - e[31] &= 127; - e[31] |= 64; - fexpand (bp, basepoint); - cmult (x, z, e, bp); + cmult (x, z, secret, bp); crecip (zmone, z); fmul (z, x, zmone); fcontract (mypublic, z); diff --git a/src/libcryptobox/curve25519/curve25519-donna.c b/src/libcryptobox/curve25519/curve25519-donna.c index f9f19a632..e6a50b87f 100644 --- a/src/libcryptobox/curve25519/curve25519-donna.c +++ b/src/libcryptobox/curve25519/curve25519-donna.c @@ -894,17 +894,10 @@ static void crecip (limb *out, const limb *z) int curve25519 (u8 *mypublic, const u8 *secret, const u8 *basepoint) { limb bp[10], x[10], z[11], zmone[10]; - uint8_t e[32]; int i; - for (i = 0; i < 32; ++i) - e[i] = secret[i]; - e[0] &= 248; - e[31] &= 127; - e[31] |= 64; - fexpand (bp, basepoint); - cmult (x, z, e, bp); + cmult (x, z, secret, bp); crecip (zmone, z); fmul (z, x, zmone); fcontract (mypublic, z); diff --git a/src/libcryptobox/curve25519/ref.c b/src/libcryptobox/curve25519/ref.c index ac3827c27..7e4820906 100644 --- a/src/libcryptobox/curve25519/ref.c +++ b/src/libcryptobox/curve25519/ref.c @@ -303,17 +303,12 @@ int curve25519 (unsigned char *q, const unsigned char *n, const unsigned char *p) { unsigned int work[96]; - unsigned char e[32]; unsigned int i; - for (i = 0; i < 32; ++i) - e[i] = n[i]; - e[0] &= 248; - e[31] &= 127; - e[31] |= 64; + for (i = 0; i < 32; ++i) work[i] = p[i]; work[31] &= 127; - mainloop (work, e); + mainloop (work, n); recip (work + 32, work + 32); mult (work + 64, work, work + 32); freeze (work + 64);