Add a scalarmult test to show that the high bit is ignored

This commit is contained in:
Frank Denis 2020-04-26 20:00:49 +02:00
parent b817cd8fc8
commit 8cd121c989
2 changed files with 7 additions and 0 deletions

View File

@ -52,6 +52,12 @@ main(void)
sodium_bin2hex(hex, sizeof hex, k, crypto_scalarmult_BYTES); sodium_bin2hex(hex, sizeof hex, k, crypto_scalarmult_BYTES);
printf("%s\n", hex); printf("%s\n", hex);
alicepk[31] ^= 0x80;
ret = crypto_scalarmult(k, bobsk, alicepk);
assert(ret == 0);
sodium_bin2hex(hex, sizeof hex, k, crypto_scalarmult_BYTES);
printf("%s\n", hex);
ret = crypto_scalarmult(k, bobsk, small_order_p); ret = crypto_scalarmult(k, bobsk, small_order_p);
assert(ret == -1); assert(ret == -1);

View File

@ -2,3 +2,4 @@
de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f de9edb7d7b7dc1b4d35b61c2ece435373f8343c85b78674dadfc7e146f882b4f
4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742
4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742 4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742
4a5d9d5ba4ce2de1728e3bf480350f25e07e21c947d19e3376f09b3c1e161742