The code i wrote somehow does not work properly. When using the same key and cipher with an online tool, the hmac is different.
My code is:
EVP_MD_CTX* mdctx = NULL;
const EVP_MD* md = NULL;
EVP_PKEY *pkey = NULL;
unsigned char md_value[EVP_MAX_MD_SIZE];
size_t md_len = 0;
mdctx = EVP_MD_CTX_create();
md = EVP_get_digestbyname("SHA256");
const unsigned char a[] = "qwertzuiopqwertzuiopqw";
pkey = EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, NULL, a, strlen("qwertzuiopqwertzuiopqw"));
EVP_DigestSignInit(mdctx, NULL, md, NULL, pkey);
EVP_DigestSignUpdate(mdctx, "Hallo", sizeof("Hallo")); // iv
EVP_DigestSignFinal(mdctx, md_value, &md_len);
The hmac calculated by my code is : eadfb51c9fb3f3fcd5741006861d04bc0d695347db4bfb9e04e954e17583c3c5.
The hmac calculated by the online-tool is: a9e0f9acc1452bdb796556c3c64e29d7f7ab47a59a179ec918c61894eefeba26.
What am i doing wrong?