From 371a54c7a902c0869ca6fb05ca6ced2d6d765214 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Fri, 12 Jun 2009 10:39:47 +0200 Subject: [PATCH] added support for stateful PRFs (such as the FIPS_PRF) --- src/libstrongswan/crypto/crypto_tester.c | 8 ++++++++ src/libstrongswan/crypto/crypto_tester.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/libstrongswan/crypto/crypto_tester.c b/src/libstrongswan/crypto/crypto_tester.c index 4b81734..da7bea0 100644 --- a/src/libstrongswan/crypto/crypto_tester.c +++ b/src/libstrongswan/crypto/crypto_tester.c @@ -407,6 +407,10 @@ static bool test_prf(private_crypto_tester_t *this, } /* bytes to existing buffer */ memset(out.ptr, 0, out.len); + if (vector->stateful) + { + prf->set_key(prf, key); + } prf->get_bytes(prf, seed, out.ptr); 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) { 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->get_bytes(prf, chunk_create(seed.ptr + 1, 1), NULL); prf->get_bytes(prf, chunk_skip(seed, 2), out.ptr); diff --git a/src/libstrongswan/crypto/crypto_tester.h b/src/libstrongswan/crypto/crypto_tester.h index 5a97261..d2929f3 100644 --- a/src/libstrongswan/crypto/crypto_tester.h +++ b/src/libstrongswan/crypto/crypto_tester.h @@ -75,6 +75,8 @@ struct hasher_test_vector_t { struct prf_test_vector_t { /** prf algorithm this test vector tests */ pseudo_random_function_t alg; + /** is this PRF stateful? */ + bool stateful; /** key length to use, in bytes */ size_t key_size; /** key to use */ -- 2.7.4