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