gmac.h revision 275732
1275732Sjmg/*-
2275732Sjmg * Copyright (c) 2014 The FreeBSD Foundation
3275732Sjmg * All rights reserved.
4275732Sjmg *
5275732Sjmg * This software was developed by John-Mark Gurney under
6275732Sjmg * the sponsorship of the FreeBSD Foundation and
7275732Sjmg * Rubicon Communications, LLC (Netgate).
8275732Sjmg * Redistribution and use in source and binary forms, with or without
9275732Sjmg * modification, are permitted provided that the following conditions
10275732Sjmg * are met:
11275732Sjmg * 1.  Redistributions of source code must retain the above copyright
12275732Sjmg *     notice, this list of conditions and the following disclaimer.
13275732Sjmg * 2.  Redistributions in binary form must reproduce the above copyright
14275732Sjmg *     notice, this list of conditions and the following disclaimer in the
15275732Sjmg *     documentation and/or other materials provided with the distribution.
16275732Sjmg *
17275732Sjmg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18275732Sjmg * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19275732Sjmg * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20275732Sjmg * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21275732Sjmg * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22275732Sjmg * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23275732Sjmg * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24275732Sjmg * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25275732Sjmg * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26275732Sjmg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27275732Sjmg * SUCH DAMAGE.
28275732Sjmg *
29275732Sjmg *	$FreeBSD: head/sys/opencrypto/gmac.h 275732 2014-12-12 19:56:36Z jmg $
30275732Sjmg *
31275732Sjmg */
32275732Sjmg
33275732Sjmg#ifndef _GMAC_H_
34275732Sjmg
35275732Sjmg#include "gfmult.h"
36275732Sjmg#include <crypto/rijndael/rijndael.h>
37275732Sjmg
38275732Sjmg#define	GMAC_BLOCK_LEN	16
39275732Sjmg#define	GMAC_DIGEST_LEN	16
40275732Sjmg
41275732Sjmgstruct aes_gmac_ctx {
42275732Sjmg	struct gf128table4	ghashtbl;
43275732Sjmg	struct gf128		hash;
44275732Sjmg	uint32_t		keysched[4*(RIJNDAEL_MAXNR + 1)];
45275732Sjmg	uint8_t			counter[GMAC_BLOCK_LEN];
46275732Sjmg	int			rounds;
47275732Sjmg};
48275732Sjmg
49275732Sjmgvoid AES_GMAC_Init(struct aes_gmac_ctx *);
50275732Sjmgvoid AES_GMAC_Setkey(struct aes_gmac_ctx *, const uint8_t *, uint16_t);
51275732Sjmgvoid AES_GMAC_Reinit(struct aes_gmac_ctx *, const uint8_t *, uint16_t);
52275732Sjmgint AES_GMAC_Update(struct aes_gmac_ctx *, const uint8_t *, uint16_t);
53275732Sjmgvoid AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN], struct aes_gmac_ctx *);
54275732Sjmg
55275732Sjmg#endif /* _GMAC_H_ */
56