xref: /dragonfly/sys/opencrypto/gmac.h (revision 7d84b73d)
1 /*	$OpenBSD: gmac.h,v 1.1 2010/09/22 11:54:23 mikeb Exp $	*/
2 
3 /*
4  * Copyright (c) 2010 Mike Belopuhov <mike@vantronix.net>
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 _GMAC_H_
20 #define _GMAC_H_
21 
22 #include <crypto/rijndael/rijndael.h>
23 
24 #define GMAC_BLOCK_LEN		16
25 #define GMAC_DIGEST_LEN		16
26 
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 */
31 } GHASH_CTX;
32 
33 typedef struct _AES_GMAC_CTX {
34 	GHASH_CTX	ghash;
35 	uint32_t	K[4*(RIJNDAEL_MAXNR + 1)];
36 	uint8_t		J[GMAC_BLOCK_LEN];		/* counter block */
37 	int		rounds;
38 } AES_GMAC_CTX;
39 
40 #include <sys/cdefs.h>
41 
42 __BEGIN_DECLS
43 void	AES_GMAC_Init(AES_GMAC_CTX *);
44 int	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 *);
48 __END_DECLS
49 
50 #endif /* _GMAC_H_ */
51 
52