xref: /freebsd/sys/opencrypto/gmac.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
108fca7a5SJohn-Mark Gurney /*-
208fca7a5SJohn-Mark Gurney  * Copyright (c) 2014 The FreeBSD Foundation
308fca7a5SJohn-Mark Gurney  *
408fca7a5SJohn-Mark Gurney  * This software was developed by John-Mark Gurney under
508fca7a5SJohn-Mark Gurney  * the sponsorship of the FreeBSD Foundation and
608fca7a5SJohn-Mark Gurney  * Rubicon Communications, LLC (Netgate).
708fca7a5SJohn-Mark Gurney  * Redistribution and use in source and binary forms, with or without
808fca7a5SJohn-Mark Gurney  * modification, are permitted provided that the following conditions
908fca7a5SJohn-Mark Gurney  * are met:
1008fca7a5SJohn-Mark Gurney  * 1.  Redistributions of source code must retain the above copyright
1108fca7a5SJohn-Mark Gurney  *     notice, this list of conditions and the following disclaimer.
1208fca7a5SJohn-Mark Gurney  * 2.  Redistributions in binary form must reproduce the above copyright
1308fca7a5SJohn-Mark Gurney  *     notice, this list of conditions and the following disclaimer in the
1408fca7a5SJohn-Mark Gurney  *     documentation and/or other materials provided with the distribution.
1508fca7a5SJohn-Mark Gurney  *
1608fca7a5SJohn-Mark Gurney  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1708fca7a5SJohn-Mark Gurney  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1808fca7a5SJohn-Mark Gurney  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1908fca7a5SJohn-Mark Gurney  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2008fca7a5SJohn-Mark Gurney  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2108fca7a5SJohn-Mark Gurney  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2208fca7a5SJohn-Mark Gurney  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2308fca7a5SJohn-Mark Gurney  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2408fca7a5SJohn-Mark Gurney  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2508fca7a5SJohn-Mark Gurney  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2608fca7a5SJohn-Mark Gurney  * SUCH DAMAGE.
2708fca7a5SJohn-Mark Gurney  *
2808fca7a5SJohn-Mark Gurney  */
2908fca7a5SJohn-Mark Gurney 
3008fca7a5SJohn-Mark Gurney #ifndef _GMAC_H_
319df9c6bcSJohn-Mark Gurney #define _GMAC_H_
3208fca7a5SJohn-Mark Gurney 
3308fca7a5SJohn-Mark Gurney #include "gfmult.h"
3408fca7a5SJohn-Mark Gurney #include <crypto/rijndael/rijndael.h>
3508fca7a5SJohn-Mark Gurney 
3608fca7a5SJohn-Mark Gurney #define	GMAC_BLOCK_LEN	16
3708fca7a5SJohn-Mark Gurney #define	GMAC_DIGEST_LEN	16
3808fca7a5SJohn-Mark Gurney 
3908fca7a5SJohn-Mark Gurney struct aes_gmac_ctx {
4008fca7a5SJohn-Mark Gurney 	struct gf128table4	ghashtbl;
4108fca7a5SJohn-Mark Gurney 	struct gf128		hash;
4208fca7a5SJohn-Mark Gurney 	uint32_t		keysched[4*(RIJNDAEL_MAXNR + 1)];
4308fca7a5SJohn-Mark Gurney 	uint8_t			counter[GMAC_BLOCK_LEN];
4408fca7a5SJohn-Mark Gurney 	int			rounds;
4508fca7a5SJohn-Mark Gurney };
4608fca7a5SJohn-Mark Gurney 
47*9b6b2f86SJohn Baldwin void AES_GMAC_Init(void *);
48*9b6b2f86SJohn Baldwin void AES_GMAC_Setkey(void *, const uint8_t *, u_int);
49*9b6b2f86SJohn Baldwin void AES_GMAC_Reinit(void *, const uint8_t *, u_int);
50*9b6b2f86SJohn Baldwin int AES_GMAC_Update(void *, const void *, u_int);
51*9b6b2f86SJohn Baldwin void AES_GMAC_Final(uint8_t *, void *);
5208fca7a5SJohn-Mark Gurney 
5308fca7a5SJohn-Mark Gurney #endif /* _GMAC_H_ */
54