1*eea83730Sjsing /* $OpenBSD: aes_xts.h,v 1.1 2012/10/09 12:36:50 jsing Exp $ */ 2*eea83730Sjsing /* 3*eea83730Sjsing * Copyright (C) 2008, Damien Miller 4*eea83730Sjsing * 5*eea83730Sjsing * Permission to use, copy, and modify this software with or without fee 6*eea83730Sjsing * is hereby granted, provided that this entire notice is included in 7*eea83730Sjsing * all copies of any software which is or includes a copy or 8*eea83730Sjsing * modification of this software. 9*eea83730Sjsing * You may use this code under the GNU public license if you so wish. Please 10*eea83730Sjsing * contribute changes back to the authors under this freer than GPL license 11*eea83730Sjsing * so that we may further the use of strong encryption without limitations to 12*eea83730Sjsing * all. 13*eea83730Sjsing * 14*eea83730Sjsing * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR 15*eea83730Sjsing * IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY 16*eea83730Sjsing * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE 17*eea83730Sjsing * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR 18*eea83730Sjsing * PURPOSE. 19*eea83730Sjsing */ 20*eea83730Sjsing 21*eea83730Sjsing #include "rijndael.h" 22*eea83730Sjsing 23*eea83730Sjsing #define AES_XTS_BLOCKSIZE 16 24*eea83730Sjsing #define AES_XTS_IVSIZE 8 25*eea83730Sjsing #define AES_XTS_ALPHA 0x87 /* GF(2^128) generator polynomial */ 26*eea83730Sjsing 27*eea83730Sjsing struct aes_xts_ctx { 28*eea83730Sjsing rijndael_ctx key1; 29*eea83730Sjsing rijndael_ctx key2; 30*eea83730Sjsing u_int8_t tweak[AES_XTS_BLOCKSIZE]; 31*eea83730Sjsing }; 32*eea83730Sjsing 33*eea83730Sjsing int aes_xts_setkey(struct aes_xts_ctx *, u_int8_t *, int); 34*eea83730Sjsing void aes_xts_crypt(struct aes_xts_ctx *, u_int8_t *, u_int); 35*eea83730Sjsing void aes_xts_encrypt(struct aes_xts_ctx *, u_int8_t *); 36*eea83730Sjsing void aes_xts_decrypt(struct aes_xts_ctx *, u_int8_t *); 37*eea83730Sjsing void aes_xts_zerokey(struct aes_xts_ctx *); 38*eea83730Sjsing void aes_xts_reinit(struct aes_xts_ctx *, u_int8_t *); 39