Set a key before benching PRFs
authorMartin Willi <martin@revosec.ch>
Tue, 10 Jul 2012 07:07:13 +0000 (09:07 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 16 Jul 2012 12:55:07 +0000 (14:55 +0200)
src/libstrongswan/crypto/crypto_tester.c

index 0462222..948d306 100644 (file)
@@ -815,11 +815,18 @@ static u_int bench_prf(private_crypto_tester_t *this,
        prf = create(alg);
        if (prf)
        {
-               char bytes[prf->get_block_size(prf)];
+               char bytes[prf->get_block_size(prf)], key[prf->get_block_size(prf)];
                chunk_t buf;
                struct timespec start;
                u_int runs;
 
+               memset(key, 0x56, prf->get_block_size(prf));
+               if (!prf->set_key(prf, chunk_create(key, prf->get_block_size(prf))))
+               {
+                       prf->destroy(prf);
+                       return 0;
+               }
+
                buf = chunk_alloc(this->bench_size);
                memset(buf.ptr, 0x34, buf.len);