Return -1 if the scalar is 0 in crypto_scalarmult_ed25519()

For consistency with _base()
This commit is contained in:
Frank Denis
2017-12-12 14:35:08 +01:00
parent e82e69ad98
commit ac8dffbecb
2 changed files with 11 additions and 3 deletions
@@ -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;
}
+9 -1
View File
@@ -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) {