gmac.h revision 281196
1151497Sru/*- 2151497Sru * Copyright (c) 2014 The FreeBSD Foundation 318099Spst * All rights reserved. 4151497Sru * 5151497Sru * This software was developed by John-Mark Gurney under 6151497Sru * the sponsorship of the FreeBSD Foundation and 7151497Sru * Rubicon Communications, LLC (Netgate). 8151497Sru * Redistribution and use in source and binary forms, with or without 9151497Sru * modification, are permitted provided that the following conditions 10151497Sru * are met: 11151497Sru * 1. Redistributions of source code must retain the above copyright 1218099Spst * notice, this list of conditions and the following disclaimer. 13151497Sru * 2. Redistributions in binary form must reproduce the above copyright 14151497Sru * notice, this list of conditions and the following disclaimer in the 1518099Spst * documentation and/or other materials provided with the distribution. 16151497Sru * 1718099Spst * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18151497Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19151497Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2018099Spst * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21151497Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22151497Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2318099Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24151497Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25151497Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2618099Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27151497Sru * SUCH DAMAGE. 28151497Sru * 29151497Sru * $FreeBSD: head/sys/opencrypto/gmac.h 281196 2015-04-07 09:00:03Z jmg $ 30151497Sru * 3118099Spst */ 32151497Sru 33151497Sru#ifndef _GMAC_H_ 34151497Sru#define _GMAC_H_ 3555839Sasmodai 36151497Sru#include "gfmult.h" 3755839Sasmodai#include <crypto/rijndael/rijndael.h> 38151497Sru 39151497Sru#define GMAC_BLOCK_LEN 16 40151497Sru#define GMAC_DIGEST_LEN 16 4155839Sasmodai 42151497Srustruct aes_gmac_ctx { 43151497Sru struct gf128table4 ghashtbl; 4455839Sasmodai struct gf128 hash; 45151497Sru uint32_t keysched[4*(RIJNDAEL_MAXNR + 1)]; 4655839Sasmodai uint8_t counter[GMAC_BLOCK_LEN]; 47151497Sru int rounds; 48151497Sru}; 4955839Sasmodai 50151497Sruvoid AES_GMAC_Init(struct aes_gmac_ctx *); 5155839Sasmodaivoid AES_GMAC_Setkey(struct aes_gmac_ctx *, const uint8_t *, uint16_t); 52151497Sruvoid AES_GMAC_Reinit(struct aes_gmac_ctx *, const uint8_t *, uint16_t); 53151497Sruint AES_GMAC_Update(struct aes_gmac_ctx *, const uint8_t *, uint16_t); 5455839Sasmodaivoid AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN], struct aes_gmac_ctx *); 55151497Sru 5655839Sasmodai#endif /* _GMAC_H_ */ 57151497Sru