Add extra scalarmult tests

This commit is contained in:
Frank Denis
2025-12-29 22:08:59 +01:00
parent f2da4cd8cb
commit 087770f38d
+10
View File
@@ -13,6 +13,10 @@ static const unsigned char max_canonical_p[32] = {
0xe4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
};
static const unsigned char not_main_subgroup_p[32] = {
0x95, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99,
0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99
};
static const unsigned char B[32] = {
0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
@@ -69,9 +73,15 @@ main(void)
if (crypto_scalarmult_ed25519(q, n, non_canonical_invalid_p) != -1) {
printf("crypto_scalarmult_ed25519() didn't fail\n");
}
if (crypto_scalarmult_ed25519(q, n, not_main_subgroup_p) != -1) {
printf("crypto_scalarmult_ed25519() didn't fail (non-subgroup)\n");
}
if (crypto_scalarmult_ed25519(q, n, max_canonical_p) != 0) {
printf("crypto_scalarmult_ed25519() failed\n");
}
if (crypto_scalarmult_ed25519_noclamp(q, n, not_main_subgroup_p) != -1) {
printf("crypto_scalarmult_ed25519_noclamp() didn't fail (non-subgroup)\n");
}
n[0] = 9;
if (crypto_scalarmult_ed25519(q, n, p) != 0) {