X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcrypto%2Fhmac_sha256%2Ftest%2Fapi-rfc4231.c;h=ed99b0eb8978b8998d132f3554df3fcf8d635cd5;hp=0c2b2ee559bd850878bc1ea82757bbc7eb4d16b1;hb=ce907a7f849c8cce11083864bf39c84a0f6c7810;hpb=d32033ada4a4e5821baef20958ae6de0b54622b2 diff --git a/ccan/crypto/hmac_sha256/test/api-rfc4231.c b/ccan/crypto/hmac_sha256/test/api-rfc4231.c index 0c2b2ee5..ed99b0eb 100644 --- a/ccan/crypto/hmac_sha256/test/api-rfc4231.c +++ b/ccan/crypto/hmac_sha256/test/api-rfc4231.c @@ -129,11 +129,12 @@ int main(void) size_t i; struct hmac_sha256 hmac; - plan_tests(sizeof(tests) / sizeof(tests[0])); + plan_tests(sizeof(tests) / sizeof(tests[0]) * 2); for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { size_t ksize, dsize, hmacsize; void *k, *d, *expect; + struct hmac_sha256_ctx ctx; k = fromhex(tests[i].key, &ksize); d = fromhex(tests[i].data, &dsize); @@ -141,6 +142,14 @@ int main(void) assert(hmacsize == sizeof(hmac)); hmac_sha256(&hmac, k, ksize, d, dsize); ok1(memcmp(&hmac, expect, hmacsize) == 0); + + /* Now test partial API. */ + hmac_sha256_init(&ctx, k, ksize); + hmac_sha256_update(&ctx, d, dsize / 2); + hmac_sha256_update(&ctx, (char *)d + dsize/2, dsize - dsize/2); + hmac_sha256_done(&ctx, &hmac); + ok1(memcmp(&hmac, expect, hmacsize) == 0); + free(k); free(d); free(expect);