10 #include <linux/kernel.h>
11 #include <linux/types.h>
14 #include <crypto/aes.h>
20 #define AES_CMAC_KEY_LEN 16
25 static void gf_mulx(
u8 *
pad)
29 carry = pad[0] & 0x80;
31 pad[i] = (pad[i] << 1) | (pad[i + 1] >> 7);
32 pad[AES_BLOCK_SIZE - 1] <<= 1;
34 pad[AES_BLOCK_SIZE - 1] ^= 0x87;
38 static void aes_128_cmac_vector(
struct crypto_cipher *tfm,
size_t num_elem,
48 for (e = 0; e < num_elem; e++)
65 if (left > AES_BLOCK_SIZE)
66 crypto_cipher_encrypt_one(tfm, cbc, cbc);
70 memset(pad, 0, AES_BLOCK_SIZE);
71 crypto_cipher_encrypt_one(tfm, pad, pad);
74 if (left || total_len == 0) {
75 for (i = 0; i <
left; i++) {
89 crypto_cipher_encrypt_one(tfm, pad, pad);
109 aes_128_cmac_vector(tfm, 3, addr, len, mic);
127 crypto_free_cipher(tfm);