- md = (*t->alg)();
- HMAC(md,t->key,strlen(t->key),
- (const unsigned char *)t->iv,strlen(t->iv),
- out,&outlen);
+ size_t n;
+ unsigned int outlen;
+ unsigned char out[EVP_MAX_MD_SIZE];
+ const EVP_MD *md;
+ const HMAC_KAT *t;
+ int rv = 1, subid;
+ HMAC_CTX c;
+ HMAC_CTX_init(&c);
+
+
+ for(n=0,t=vector; n<sizeof(vector)/sizeof(vector[0]); n++,t++)
+ {
+ md = (*t->alg)();
+ subid = M_EVP_MD_type(md);
+ if (!fips_post_started(FIPS_TEST_HMAC, subid, 0))
+ continue;
+ if (!HMAC_Init_ex(&c, t->key, strlen(t->key), md, NULL))
+ {
+ rv = -1;
+ goto err;
+ }
+ if (!HMAC_Update(&c, (const unsigned char *)t->iv, strlen(t->iv)))
+ {
+ rv = -1;
+ goto err;
+ }
+ if (!fips_post_corrupt(FIPS_TEST_HMAC, subid, NULL))
+ {
+ if (!HMAC_Update(&c, (const unsigned char *)t->iv, 1))
+ {
+ rv = -1;
+ goto err;
+ }
+ }
+ if (!HMAC_Final(&c, out, &outlen))
+ {
+ rv = -1;
+ goto err;
+ }
+
+ if(memcmp(out,t->kaval,outlen))
+ {
+ fips_post_failed(FIPS_TEST_HMAC, subid, NULL);
+ rv = 0;
+ }
+ else if (!fips_post_success(FIPS_TEST_HMAC, subid, NULL))
+ goto err;
+ }