1 /* $OpenBSD: gmac.h,v 1.1 2010/09/22 11:54:23 mikeb Exp $ */
4 * Copyright (c) 2010 Mike Belopuhov <mike@vantronix.net>
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.
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.
22 #include <crypto/rijndael/rijndael.h>
24 #define GMAC_BLOCK_LEN 16
25 #define GMAC_DIGEST_LEN 16
27 typedef struct _GHASH_CTX
{
28 uint8_t H
[GMAC_BLOCK_LEN
]; /* hash subkey */
29 uint8_t S
[GMAC_BLOCK_LEN
]; /* state */
30 uint8_t Z
[GMAC_BLOCK_LEN
]; /* initial state */
33 typedef struct _AES_GMAC_CTX
{
35 uint32_t K
[4*(RIJNDAEL_MAXNR
+ 1)];
36 uint8_t J
[GMAC_BLOCK_LEN
]; /* counter block */
40 #include <sys/cdefs.h>
43 void AES_GMAC_Init(AES_GMAC_CTX
*);
44 void AES_GMAC_Setkey(AES_GMAC_CTX
*, const uint8_t *, uint16_t);
45 void AES_GMAC_Reinit(AES_GMAC_CTX
*, const uint8_t *, uint16_t);
46 int AES_GMAC_Update(AES_GMAC_CTX
*, uint8_t *, uint16_t);
47 void AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN
], AES_GMAC_CTX
*);