cmac

How to calculate AES CMAC using OpenSSL's CMAC_xxx functions?

北城以北 提交于 2019-11-29 05:17:00
Is there any way to compute AES CMAC with OpenSSL / libcrypto ? Preferably in a way that takes advantage of AES-NI (or any other hardware acceleration). See also CMAC Key generation with OpenSSL EVP_DigestSign* fails ecerulm As stated in my blog post you can use the CMAC_CTX_new , CMAC_Init , CMAC_Update and CMAC_Final from lib crypto to calculate AES-128-CBC CMAC. Here is an example: #include <stdio.h> #include <openssl/cmac.h> void printBytes(unsigned char *buf, size_t len) { for(int i=0; i<len; i++) { printf("%02x ", buf[i]); } printf("\n"); } int main(int argc, char *argv[]) { // https:/