mirror of https://github.com/wolfSSL/wolfssl.git
set rng when making a curve25519 key and cast type after shift
parent
aa840f9c94
commit
cbc4cba263
|
@ -212,11 +212,11 @@ static int curve25519_smul_blind(byte* rp, const byte* n, const byte* p,
|
||||||
return ret;
|
return ret;
|
||||||
a[CURVE25519_KEYSIZE-1] &= 0x7f;
|
a[CURVE25519_KEYSIZE-1] &= 0x7f;
|
||||||
/* k' = k ^ 2k ^ a */
|
/* k' = k ^ 2k ^ a */
|
||||||
n_a[0] = n[0] ^ (n[0] << 1) ^ a[0];
|
n_a[0] = n[0] ^ (byte)(n[0] << 1) ^ a[0];
|
||||||
for (i = 1; i < CURVE25519_KEYSIZE; i++) {
|
for (i = 1; i < CURVE25519_KEYSIZE; i++) {
|
||||||
byte b1, b2, b3;
|
byte b1, b2, b3;
|
||||||
b1 = n[i] ^ a[i];
|
b1 = n[i] ^ a[i];
|
||||||
b2 = (n[i] << 1) ^ a[i];
|
b2 = (byte)(n[i] << 1) ^ a[i];
|
||||||
b3 = (n[i-1] >> 7) ^ a[i];
|
b3 = (n[i-1] >> 7) ^ a[i];
|
||||||
n_a[i] = b1 ^ b2 ^ b3;
|
n_a[i] = b1 ^ b2 ^ b3;
|
||||||
}
|
}
|
||||||
|
@ -422,6 +422,9 @@ int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key)
|
||||||
ret = wc_curve25519_make_pub_blind((int)sizeof(key->p.point),
|
ret = wc_curve25519_make_pub_blind((int)sizeof(key->p.point),
|
||||||
key->p.point, (int)sizeof(key->k),
|
key->p.point, (int)sizeof(key->k),
|
||||||
key->k, rng);
|
key->k, rng);
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = wc_curve25519_set_rng(key, rng);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
ret = wc_curve25519_make_pub((int)sizeof(key->p.point), key->p.point,
|
ret = wc_curve25519_make_pub((int)sizeof(key->p.point), key->p.point,
|
||||||
(int)sizeof(key->k), key->k);
|
(int)sizeof(key->k), key->k);
|
||||||
|
|
Loading…
Reference in New Issue