Add tests for invalid generichash parameters

This commit is contained in:
Frank Denis 2014-09-14 12:56:32 -07:00
parent 0ec5a25c88
commit dc49ae0491
3 changed files with 20 additions and 0 deletions

View File

@ -22,6 +22,12 @@ int main(void)
printf("\n");
}
assert(crypto_generichash(out, 0U, in, sizeof in, k, sizeof k) == -1);
assert(crypto_generichash(out, crypto_generichash_BYTES_MAX + 1U, in, sizeof in,
k, sizeof k) == -1);
assert(crypto_generichash(out, sizeof out, in, sizeof in,
k, crypto_generichash_KEYBYTES_MAX + 1U) == -1);
assert(crypto_generichash_bytes_min() > 0U);
assert(crypto_generichash_bytes_max() > 0U);
assert(crypto_generichash_bytes() > 0U);

View File

@ -27,5 +27,11 @@ int main(void)
}
printf("\n");
}
assert(crypto_generichash_init(&st, k, sizeof k, 0U) == -1);
assert(crypto_generichash_init(&st, k, sizeof k,
crypto_generichash_BYTES_MAX + 1U) == -1);
assert(crypto_generichash_init(&st, k, crypto_generichash_KEYBYTES_MAX + 1U,
sizeof out) == -1);
return 0;
}

View File

@ -32,5 +32,13 @@ int main(void)
}
printf("\n");
}
assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k, 0U,
salt, personal) == -1);
assert(crypto_generichash_blake2b_init_salt_personal(&st, k, sizeof k,
crypto_generichash_BYTES_MAX + 1U,
salt, personal) == -1);
assert(crypto_generichash_blake2b_init_salt_personal(&st, k,
crypto_generichash_KEYBYTES_MAX + 1U,
sizeof out, salt, personal) == -1);
return 0;
}