1aface142SAlex Hornung /* $OpenBSD: gmac.h,v 1.1 2010/09/22 11:54:23 mikeb Exp $ */ 2aface142SAlex Hornung 3aface142SAlex Hornung /* 4aface142SAlex Hornung * Copyright (c) 2010 Mike Belopuhov <mike@vantronix.net> 5aface142SAlex Hornung * 6aface142SAlex Hornung * Permission to use, copy, modify, and distribute this software for any 7aface142SAlex Hornung * purpose with or without fee is hereby granted, provided that the above 8aface142SAlex Hornung * copyright notice and this permission notice appear in all copies. 9aface142SAlex Hornung * 10aface142SAlex Hornung * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11aface142SAlex Hornung * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12aface142SAlex Hornung * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13aface142SAlex Hornung * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14aface142SAlex Hornung * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15aface142SAlex Hornung * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16aface142SAlex Hornung * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17aface142SAlex Hornung */ 18aface142SAlex Hornung 19aface142SAlex Hornung #ifndef _GMAC_H_ 20aface142SAlex Hornung #define _GMAC_H_ 21aface142SAlex Hornung 22aface142SAlex Hornung #include <crypto/rijndael/rijndael.h> 23aface142SAlex Hornung 24aface142SAlex Hornung #define GMAC_BLOCK_LEN 16 25aface142SAlex Hornung #define GMAC_DIGEST_LEN 16 26aface142SAlex Hornung 27aface142SAlex Hornung typedef struct _GHASH_CTX { 28aface142SAlex Hornung uint8_t H[GMAC_BLOCK_LEN]; /* hash subkey */ 29aface142SAlex Hornung uint8_t S[GMAC_BLOCK_LEN]; /* state */ 30aface142SAlex Hornung uint8_t Z[GMAC_BLOCK_LEN]; /* initial state */ 31aface142SAlex Hornung } GHASH_CTX; 32aface142SAlex Hornung 33aface142SAlex Hornung typedef struct _AES_GMAC_CTX { 34aface142SAlex Hornung GHASH_CTX ghash; 35aface142SAlex Hornung uint32_t K[4*(RIJNDAEL_MAXNR + 1)]; 36aface142SAlex Hornung uint8_t J[GMAC_BLOCK_LEN]; /* counter block */ 37aface142SAlex Hornung int rounds; 38aface142SAlex Hornung } AES_GMAC_CTX; 39aface142SAlex Hornung 40aface142SAlex Hornung #include <sys/cdefs.h> 41aface142SAlex Hornung 42aface142SAlex Hornung __BEGIN_DECLS 43aface142SAlex Hornung void AES_GMAC_Init(AES_GMAC_CTX *); 44*e340ae2aSAaron LI int AES_GMAC_Setkey(AES_GMAC_CTX *, const uint8_t *, uint16_t); 45aface142SAlex Hornung void AES_GMAC_Reinit(AES_GMAC_CTX *, const uint8_t *, uint16_t); 46aface142SAlex Hornung int AES_GMAC_Update(AES_GMAC_CTX *, uint8_t *, uint16_t); 47aface142SAlex Hornung void AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN], AES_GMAC_CTX *); 48aface142SAlex Hornung __END_DECLS 49aface142SAlex Hornung 50aface142SAlex Hornung #endif /* _GMAC_H_ */ 51aface142SAlex Hornung 52