gmac.h revision 281196
11541Srgrimes/*- 21541Srgrimes * Copyright (c) 2014 The FreeBSD Foundation 31541Srgrimes * All rights reserved. 41541Srgrimes * 51541Srgrimes * This software was developed by John-Mark Gurney under 61541Srgrimes * the sponsorship of the FreeBSD Foundation and 71541Srgrimes * Rubicon Communications, LLC (Netgate). 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * $FreeBSD: head/sys/opencrypto/gmac.h 281196 2015-04-07 09:00:03Z jmg $ 301541Srgrimes * 311541Srgrimes */ 321541Srgrimes 331541Srgrimes#ifndef _GMAC_H_ 3411789Sbde#define _GMAC_H_ 351541Srgrimes 361541Srgrimes#include "gfmult.h" 371541Srgrimes#include <crypto/rijndael/rijndael.h> 381541Srgrimes 391541Srgrimes#define GMAC_BLOCK_LEN 16 401541Srgrimes#define GMAC_DIGEST_LEN 16 411541Srgrimes 421541Srgrimesstruct aes_gmac_ctx { 431541Srgrimes struct gf128table4 ghashtbl; 441541Srgrimes struct gf128 hash; 451541Srgrimes uint32_t keysched[4*(RIJNDAEL_MAXNR + 1)]; 461541Srgrimes uint8_t counter[GMAC_BLOCK_LEN]; 471541Srgrimes int rounds; 481541Srgrimes}; 491541Srgrimes 501541Srgrimesvoid AES_GMAC_Init(struct aes_gmac_ctx *); 511541Srgrimesvoid AES_GMAC_Setkey(struct aes_gmac_ctx *, const uint8_t *, uint16_t); 521541Srgrimesvoid AES_GMAC_Reinit(struct aes_gmac_ctx *, const uint8_t *, uint16_t); 533308Sphkint AES_GMAC_Update(struct aes_gmac_ctx *, const uint8_t *, uint16_t); 541541Srgrimesvoid AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN], struct aes_gmac_ctx *); 5511789Sbde 5611789Sbde#endif /* _GMAC_H_ */ 5711789Sbde