mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Return -1 if the scalar is 0 in crypto_scalarmult_ed25519()
For consistency with _base()
This commit is contained in:
@@ -47,8 +47,8 @@ crypto_scalarmult_ed25519(unsigned char *q, const unsigned char *n,
|
||||
_crypto_scalarmult_ed25519_clamp(t);
|
||||
ge25519_scalarmult(&Q, t, &P);
|
||||
ge25519_p3_tobytes(q, &Q);
|
||||
if (_crypto_scalarmult_ed25519_is_inf(q) != 0) {
|
||||
return -1; /* LCOV_EXCL_LINE */
|
||||
if (_crypto_scalarmult_ed25519_is_inf(q) != 0 || sodium_is_zero(n, 32)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,18 @@ main(void)
|
||||
|
||||
memset(n, 0, crypto_scalarmult_ed25519_SCALARBYTES);
|
||||
if (crypto_scalarmult_ed25519_base(q, n) != -1) {
|
||||
printf("crypto_scalarmult_ed25519_base(0) failed\n");
|
||||
}
|
||||
if (crypto_scalarmult_ed25519(q2, n, p) != -1) {
|
||||
printf("crypto_scalarmult_ed25519(0) passed\n");
|
||||
}
|
||||
|
||||
n[0] = 1;
|
||||
if (crypto_scalarmult_ed25519_base(q, n) != 0) {
|
||||
printf("crypto_scalarmult_ed25519_base() failed\n");
|
||||
}
|
||||
if (crypto_scalarmult_ed25519(q2, n, p) != 0) {
|
||||
printf("crypto_scalarmult_ed25519() failed\n");
|
||||
printf("crypto_scalarmult_ed25519() passed\n");
|
||||
}
|
||||
|
||||
if (crypto_scalarmult_ed25519(q, n, non_canonical_p) != -1) {
|
||||
|
||||
Reference in New Issue
Block a user