More tests for signatures

This commit is contained in:
Frank Denis 2017-07-29 22:42:05 +02:00
parent 90bd94e4e4
commit 180a89cb21

View File

@ -1190,6 +1190,8 @@ int main(void)
i, pk) != -1) {
printf("detached signature verification should have failed\n");
}
assert(crypto_sign_detached(sig, NULL,
(const unsigned char *)test_data[i].m, i, skpk) == 0);
sodium_hex2bin(pk, crypto_sign_PUBLICKEYBYTES,
"3eee494fb9eac773144e34b0c755affaf33ea782c0722e5ea8b150e61209ab36",
@ -1200,6 +1202,24 @@ int main(void)
printf("signature with an invalid public key should have failed\n");
}
sodium_hex2bin(pk, crypto_sign_PUBLICKEYBYTES,
"0200000000000000000000000000000000000000000000000000000000000000",
crypto_sign_PUBLICKEYBYTES * 2, NULL, NULL, NULL);
if (crypto_sign_verify_detached(sig,
(const unsigned char *)test_data[i].m,
i, pk) != -1) {
printf("signature with an invalid public key should have failed\n");
}
sodium_hex2bin(pk, crypto_sign_PUBLICKEYBYTES,
"0500000000000000000000000000000000000000000000000000000000000000",
crypto_sign_PUBLICKEYBYTES * 2, NULL, NULL, NULL);
if (crypto_sign_verify_detached(sig,
(const unsigned char *)test_data[i].m,
i, pk) != -1) {
printf("signature with an invalid public key should have failed\n");
}
if (crypto_sign_seed_keypair(pk, sk, keypair_seed) != 0) {
printf("crypto_sign_seed_keypair() failure\n");
return -1;