added support for stateful PRFs (such as the FIPS_PRF)
This commit is contained in:
@@ -407,6 +407,10 @@ static bool test_prf(private_crypto_tester_t *this,
|
|||||||
}
|
}
|
||||||
/* bytes to existing buffer */
|
/* bytes to existing buffer */
|
||||||
memset(out.ptr, 0, out.len);
|
memset(out.ptr, 0, out.len);
|
||||||
|
if (vector->stateful)
|
||||||
|
{
|
||||||
|
prf->set_key(prf, key);
|
||||||
|
}
|
||||||
prf->get_bytes(prf, seed, out.ptr);
|
prf->get_bytes(prf, seed, out.ptr);
|
||||||
if (!memeq(vector->out, out.ptr, out.len))
|
if (!memeq(vector->out, out.ptr, out.len))
|
||||||
{
|
{
|
||||||
@@ -416,6 +420,10 @@ static bool test_prf(private_crypto_tester_t *this,
|
|||||||
if (seed.len > 2)
|
if (seed.len > 2)
|
||||||
{
|
{
|
||||||
memset(out.ptr, 0, out.len);
|
memset(out.ptr, 0, out.len);
|
||||||
|
if (vector->stateful)
|
||||||
|
{
|
||||||
|
prf->set_key(prf, key);
|
||||||
|
}
|
||||||
prf->allocate_bytes(prf, chunk_create(seed.ptr, 1), NULL);
|
prf->allocate_bytes(prf, chunk_create(seed.ptr, 1), NULL);
|
||||||
prf->get_bytes(prf, chunk_create(seed.ptr + 1, 1), NULL);
|
prf->get_bytes(prf, chunk_create(seed.ptr + 1, 1), NULL);
|
||||||
prf->get_bytes(prf, chunk_skip(seed, 2), out.ptr);
|
prf->get_bytes(prf, chunk_skip(seed, 2), out.ptr);
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ struct hasher_test_vector_t {
|
|||||||
struct prf_test_vector_t {
|
struct prf_test_vector_t {
|
||||||
/** prf algorithm this test vector tests */
|
/** prf algorithm this test vector tests */
|
||||||
pseudo_random_function_t alg;
|
pseudo_random_function_t alg;
|
||||||
|
/** is this PRF stateful? */
|
||||||
|
bool stateful;
|
||||||
/** key length to use, in bytes */
|
/** key length to use, in bytes */
|
||||||
size_t key_size;
|
size_t key_size;
|
||||||
/** key to use */
|
/** key to use */
|
||||||
|
|||||||
Reference in New Issue
Block a user