1*ffae97bbSchristos /* $NetBSD: cipher-aesctr.h,v 1.2 2018/04/06 18:59:00 christos Exp $ */ 25484a5efSchristos /* $OpenBSD: cipher-aesctr.h,v 1.1 2014/04/29 15:39:33 markus Exp $ */ 35484a5efSchristos /* 45484a5efSchristos * Copyright (c) 2014 Markus Friedl 55484a5efSchristos * 65484a5efSchristos * Permission to use, copy, modify, and distribute this software for any 75484a5efSchristos * purpose with or without fee is hereby granted, provided that the above 85484a5efSchristos * copyright notice and this permission notice appear in all copies. 95484a5efSchristos * 105484a5efSchristos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 115484a5efSchristos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 125484a5efSchristos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 135484a5efSchristos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 145484a5efSchristos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 155484a5efSchristos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 165484a5efSchristos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 175484a5efSchristos */ 185484a5efSchristos 195484a5efSchristos #ifndef OPENSSH_AESCTR_H 205484a5efSchristos #define OPENSSH_AESCTR_H 215484a5efSchristos 225484a5efSchristos #include "rijndael.h" 235484a5efSchristos 245484a5efSchristos #define AES_BLOCK_SIZE 16 255484a5efSchristos 265484a5efSchristos typedef struct aesctr_ctx { 275484a5efSchristos int rounds; /* keylen-dependent #rounds */ 285484a5efSchristos u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */ 295484a5efSchristos u8 ctr[AES_BLOCK_SIZE]; /* counter */ 305484a5efSchristos } aesctr_ctx; 315484a5efSchristos 325484a5efSchristos void aesctr_keysetup(aesctr_ctx *x,const u8 *k,u32 kbits,u32 ivbits); 335484a5efSchristos void aesctr_ivsetup(aesctr_ctx *x,const u8 *iv); 345484a5efSchristos void aesctr_encrypt_bytes(aesctr_ctx *x,const u8 *m,u8 *c,u32 bytes); 355484a5efSchristos 365484a5efSchristos #endif 37