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