freebsd-skq/sys/opencrypto/xform_cbc_mac.c
Sean Eric Fagan a99bc4c3eb Add CBC-MAC authentication.
This adds the CBC-MAC code to the kernel, but does not hook it up to
anything (that comes in the next commit).

https://tools.ietf.org/html/rfc3610 describes the algorithm.

Note that this is a software-only implementation, which means it is
fairly slow.

Sponsored by:   iXsystems Inc
Differential Revision:  https://reviews.freebsd.org/D18592
2019-02-15 03:46:39 +00:00

56 lines
2.0 KiB
C

#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <opencrypto/cbc_mac.h>
#include <opencrypto/xform_auth.h>
/* Authentication instances */
struct auth_hash auth_hash_ccm_cbc_mac_128 = {
.type = CRYPTO_AES_CCM_CBC_MAC,
.name = "CBC-CCM-AES-128",
.keysize = AES_128_CBC_MAC_KEY_LEN,
.hashsize = AES_CBC_MAC_HASH_LEN,
.ctxsize = sizeof(struct aes_cbc_mac_ctx),
.blocksize = CCM_CBC_BLOCK_LEN,
.Init = (void (*)(void *)) AES_CBC_MAC_Init,
.Setkey =
(void (*)(void *, const u_int8_t *, u_int16_t))AES_CBC_MAC_Setkey,
.Reinit =
(void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Reinit,
.Update =
(int (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Update,
.Final = (void (*)(u_int8_t *, void *)) AES_CBC_MAC_Final,
};
struct auth_hash auth_hash_ccm_cbc_mac_192 = {
.type = CRYPTO_AES_CCM_CBC_MAC,
.name = "CBC-CCM-AES-192",
.keysize = AES_192_CBC_MAC_KEY_LEN,
.hashsize = AES_CBC_MAC_HASH_LEN,
.ctxsize = sizeof(struct aes_cbc_mac_ctx),
.blocksize = CCM_CBC_BLOCK_LEN,
.Init = (void (*)(void *)) AES_CBC_MAC_Init,
.Setkey =
(void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Setkey,
.Reinit =
(void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Reinit,
.Update =
(int (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Update,
.Final = (void (*)(u_int8_t *, void *)) AES_CBC_MAC_Final,
};
struct auth_hash auth_hash_ccm_cbc_mac_256 = {
.type = CRYPTO_AES_CCM_CBC_MAC,
.name = "CBC-CCM-AES-256",
.keysize = AES_256_CBC_MAC_KEY_LEN,
.hashsize = AES_CBC_MAC_HASH_LEN,
.ctxsize = sizeof(struct aes_cbc_mac_ctx),
.blocksize = CCM_CBC_BLOCK_LEN,
.Init = (void (*)(void *)) AES_CBC_MAC_Init,
.Setkey =
(void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Setkey,
.Reinit =
(void (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Reinit,
.Update =
(int (*)(void *, const u_int8_t *, u_int16_t)) AES_CBC_MAC_Update,
.Final = (void (*)(u_int8_t *, void *)) AES_CBC_MAC_Final,
};