/*1* Copyright (c) 2014 The FreeBSD Foundation2* Copyright (c) 2018, iXsystems Inc.3* All rights reserved.4*5* This software was developed by Sean Eric Fagan, with lots of references6* to existing AES-CCM (gmac) code.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*29*/3031#ifndef _CBC_CCM_H32# define _CBC_CCM_H3334# include <sys/types.h>35# include <crypto/rijndael/rijndael.h>3637# define CCM_CBC_BLOCK_LEN 16 /* 128 bits */38# define CCM_CBC_MAX_DIGEST_LEN 1639# define CCM_CBC_MIN_DIGEST_LEN 44041/*42* This is the authentication context structure;43* the encryption one is similar.44*/45struct aes_cbc_mac_ctx {46uint8_t staging_block[CCM_CBC_BLOCK_LEN];47uint8_t block[CCM_CBC_BLOCK_LEN];48int blockIndex;49int nonceLength; /* This one is in bytes, not bits! */50const uint8_t *nonce;51/* AES state data */52int rounds;53uint32_t keysched[4*(RIJNDAEL_MAXNR+1)];54};5556void AES_CBC_MAC_Init(void *);57void AES_CBC_MAC_Setkey(void *, const uint8_t *, u_int);58void AES_CBC_MAC_Reinit(void *, const uint8_t *, u_int);59int AES_CBC_MAC_Update(void *, const void *, u_int);60void AES_CBC_MAC_Final(uint8_t *, void *);6162#endif /* _CBC_CCM_H */636465