scalarmult(): don't use the output as a temporary buffer
So that application can use the same pointer for the public key and the shared secret.
This commit is contained in:
parent
e2bd402400
commit
2a2fe56189
@ -74,7 +74,7 @@ crypto_scalarmult_curve25519_ref10(unsigned char *q,
|
|||||||
const unsigned char *n,
|
const unsigned char *n,
|
||||||
const unsigned char *p)
|
const unsigned char *p)
|
||||||
{
|
{
|
||||||
unsigned char *t = q;
|
unsigned char t[32];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
fe25519 x1;
|
fe25519 x1;
|
||||||
fe25519 x2;
|
fe25519 x2;
|
||||||
@ -136,6 +136,8 @@ crypto_scalarmult_curve25519_ref10(unsigned char *q,
|
|||||||
fe25519_mul(x2, x2, z2);
|
fe25519_mul(x2, x2, z2);
|
||||||
fe25519_tobytes(q, x2);
|
fe25519_tobytes(q, x2);
|
||||||
|
|
||||||
|
sodium_memzero(t, sizeof t);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ static int
|
|||||||
crypto_scalarmult_curve25519_sandy2x(unsigned char *q, const unsigned char *n,
|
crypto_scalarmult_curve25519_sandy2x(unsigned char *q, const unsigned char *n,
|
||||||
const unsigned char *p)
|
const unsigned char *p)
|
||||||
{
|
{
|
||||||
unsigned char *t = q;
|
unsigned char t[32];
|
||||||
fe var[3];
|
fe var[3];
|
||||||
fe51 x_51;
|
fe51 x_51;
|
||||||
fe51 z_51;
|
fe51 z_51;
|
||||||
@ -57,6 +57,8 @@ crypto_scalarmult_curve25519_sandy2x(unsigned char *q, const unsigned char *n,
|
|||||||
fe51_mul(&x_51, &x_51, &z_51);
|
fe51_mul(&x_51, &x_51, &z_51);
|
||||||
fe51_pack(q, &x_51);
|
fe51_pack(q, &x_51);
|
||||||
|
|
||||||
|
sodium_memzero(t, sizeof t);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user