Test crypto_sign_detached()

This commit is contained in:
Frank Denis 2014-07-10 22:48:33 -07:00
parent c9c49c61fd
commit 16fa9960e0

View File

@ -1052,6 +1052,7 @@ static TestData test_data[] = {
int main(void)
{
unsigned char sig[crypto_sign_BYTES];
unsigned char sm[1024 + crypto_sign_BYTES];
unsigned char m[1024];
unsigned char skpk[crypto_sign_SECRETKEYBYTES +
@ -1060,6 +1061,7 @@ int main(void)
unsigned char sk[crypto_sign_SECRETKEYBYTES];
char pk_hex[crypto_sign_PUBLICKEYBYTES * 2 + 1];
char sk_hex[crypto_sign_SECRETKEYBYTES * 2 + 1];
unsigned long long siglen;
unsigned long long smlen;
unsigned long long mlen;
unsigned int i;
@ -1096,6 +1098,22 @@ int main(void)
i % crypto_sign_BYTES);
continue;
}
if (crypto_sign_detached(sig, &siglen,
(const unsigned char *) test_data[i].m, i,
test_data[i].sk) != 0) {
printf("detached signature failed: [%u]\n", i);
continue;
}
if (siglen == 0U || siglen > crypto_sign_BYTES) {
printf("detached signature has an unexpected length");
continue;
}
if (crypto_sign_verify_detached(sig,
(const unsigned char *) test_data[i].m,
i, test_data[i].pk) != 0) {
printf("detached signature verification failed: [%u]\n", i);
continue;
}
}
printf("%u tests\n", i);