From: Aki Tuomi Date: Tue, 29 Nov 2016 21:19:37 +0000 (+0200) Subject: lib: Add test for hmac helper X-Git-Tag: 2.3.0.rc1~2483 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a62b4fb5f0b1577535fa20fc88f4d1ade72070a3;p=thirdparty%2Fdovecot%2Fcore.git lib: Add test for hmac helper --- diff --git a/src/lib/test-hmac.c b/src/lib/test-hmac.c index a7a1984d79..8aef2d6489 100644 --- a/src/lib/test-hmac.c +++ b/src/lib/test-hmac.c @@ -4,6 +4,7 @@ #include "hash-method.h" #include "hmac.h" #include "sha-common.h" +#include "buffer.h" struct test_vector { const char *prf; @@ -79,7 +80,24 @@ static void test_hmac_rfc(void) test_end(); } +static void test_hmac_buffer(void) +{ + const struct test_vector *vec = &(test_vectors[0]); + test_begin("hmac temporary buffer"); + + buffer_t *tmp; + + tmp = t_hmac_data(hash_method_lookup(vec->prf), vec->key, vec->key_len, + vec->data, vec->data_len); + + test_assert(tmp->used == vec->res_len && + memcmp(tmp->data, vec->res, vec->res_len) == 0); + + test_end(); +} + void test_hmac(void) { test_hmac_rfc(); + test_hmac_buffer(); }