xref: /openssh-portable/cipher-aesctr.h (revision 1f0311c7)
1*1f0311c7SDamien Miller /* $OpenBSD: cipher-aesctr.h,v 1.1 2014/04/29 15:39:33 markus Exp $ */
2*1f0311c7SDamien Miller /*
3*1f0311c7SDamien Miller  * Copyright (c) 2014 Markus Friedl
4*1f0311c7SDamien Miller  *
5*1f0311c7SDamien Miller  * Permission to use, copy, modify, and distribute this software for any
6*1f0311c7SDamien Miller  * purpose with or without fee is hereby granted, provided that the above
7*1f0311c7SDamien Miller  * copyright notice and this permission notice appear in all copies.
8*1f0311c7SDamien Miller  *
9*1f0311c7SDamien Miller  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*1f0311c7SDamien Miller  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*1f0311c7SDamien Miller  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*1f0311c7SDamien Miller  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*1f0311c7SDamien Miller  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*1f0311c7SDamien Miller  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*1f0311c7SDamien Miller  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*1f0311c7SDamien Miller  */
17*1f0311c7SDamien Miller 
18*1f0311c7SDamien Miller #ifndef OPENSSH_AESCTR_H
19*1f0311c7SDamien Miller #define OPENSSH_AESCTR_H
20*1f0311c7SDamien Miller 
21*1f0311c7SDamien Miller #include "rijndael.h"
22*1f0311c7SDamien Miller 
23*1f0311c7SDamien Miller #define AES_BLOCK_SIZE 16
24*1f0311c7SDamien Miller 
25*1f0311c7SDamien Miller typedef struct aesctr_ctx {
26*1f0311c7SDamien Miller 	int	rounds;				/* keylen-dependent #rounds */
27*1f0311c7SDamien Miller 	u32	ek[4*(AES_MAXROUNDS + 1)];	/* encrypt key schedule */
28*1f0311c7SDamien Miller 	u8	ctr[AES_BLOCK_SIZE];		/* counter */
29*1f0311c7SDamien Miller } aesctr_ctx;
30*1f0311c7SDamien Miller 
31*1f0311c7SDamien Miller void aesctr_keysetup(aesctr_ctx *x,const u8 *k,u32 kbits,u32 ivbits);
32*1f0311c7SDamien Miller void aesctr_ivsetup(aesctr_ctx *x,const u8 *iv);
33*1f0311c7SDamien Miller void aesctr_encrypt_bytes(aesctr_ctx *x,const u8 *m,u8 *c,u32 bytes);
34*1f0311c7SDamien Miller 
35*1f0311c7SDamien Miller #endif
36