Home | History | Annotate | Line # | Download | only in opencrypto
gmac.h revision 1.1
      1  1.1  drochner /* $NetBSD: gmac.h,v 1.1 2011/05/26 21:50:03 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.1  drochner typedef struct _GHASH_CTX {
     29  1.1  drochner 	uint32_t	H[GMAC_BLOCK_LEN/4];		/* hash subkey */
     30  1.1  drochner 	uint32_t	S[GMAC_BLOCK_LEN/4];		/* state */
     31  1.1  drochner 	uint32_t	Z[GMAC_BLOCK_LEN/4];		/* initial state */
     32  1.1  drochner } GHASH_CTX;
     33  1.1  drochner 
     34  1.1  drochner typedef struct _AES_GMAC_CTX {
     35  1.1  drochner 	GHASH_CTX	ghash;
     36  1.1  drochner 	uint32_t	K[4*(RIJNDAEL_MAXNR + 1)];
     37  1.1  drochner 	uint8_t		J[GMAC_BLOCK_LEN];		/* counter block */
     38  1.1  drochner 	int		rounds;
     39  1.1  drochner } AES_GMAC_CTX;
     40  1.1  drochner 
     41  1.1  drochner #include <sys/cdefs.h>
     42  1.1  drochner 
     43  1.1  drochner __BEGIN_DECLS
     44  1.1  drochner void	AES_GMAC_Init(AES_GMAC_CTX *);
     45  1.1  drochner void	AES_GMAC_Setkey(AES_GMAC_CTX *, const uint8_t *, uint16_t);
     46  1.1  drochner void	AES_GMAC_Reinit(AES_GMAC_CTX *, const uint8_t *, uint16_t);
     47  1.1  drochner int	AES_GMAC_Update(AES_GMAC_CTX *, const uint8_t *, uint16_t);
     48  1.1  drochner void	AES_GMAC_Final(uint8_t [GMAC_DIGEST_LEN], AES_GMAC_CTX *);
     49  1.1  drochner __END_DECLS
     50  1.1  drochner 
     51  1.1  drochner #endif /* _GMAC_H_ */
     52