1 /* $OpenBSD: cmac.h,v 1.3 2017/05/02 17:07:06 mikeb Exp $ */ 2 3 /*- 4 * Copyright (c) 2008 Damien Bergamini <damien.bergamini@free.fr> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _CMAC_H_ 20 #define _CMAC_H_ 21 22 #define AES_CMAC_KEY_LENGTH 16 23 #define AES_CMAC_DIGEST_LENGTH 16 24 25 typedef struct _AES_CMAC_CTX { 26 AES_CTX aesctx; 27 u_int8_t X[16]; 28 u_int8_t M_last[16]; 29 u_int M_n; 30 } AES_CMAC_CTX; 31 32 __BEGIN_DECLS 33 void AES_CMAC_Init(AES_CMAC_CTX *); 34 void AES_CMAC_SetKey(AES_CMAC_CTX *, const u_int8_t [AES_CMAC_KEY_LENGTH]); 35 void AES_CMAC_Update(AES_CMAC_CTX *, const u_int8_t *, u_int) 36 __attribute__((__bounded__(__string__,2,3))); 37 void AES_CMAC_Final(u_int8_t [AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *) 38 __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH))); 39 __END_DECLS 40 41 #endif /* _CMAC_H_ */ 42