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