2 * QEMU Crypto XTS cipher mode
4 * Copyright (c) 2015-2016 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 * This code is originally derived from public domain / WTFPL code in
20 * LibTomCrypt crytographic library http://libtom.org. The XTS code
21 * was donated by Elliptic Semiconductor Inc (www.ellipticsemi.com)
22 * to the LibTom Projects
29 #include "qemu-common.h"
31 #define XTS_BLOCK_SIZE 16
33 typedef void xts_cipher_func(const void *ctx
,
40 * @datactx: the cipher context for data decryption
41 * @tweakctx: the cipher context for tweak decryption
42 * @encfunc: the cipher function for encryption
43 * @decfunc: the cipher function for decryption
44 * @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
45 * @length: the length of @dst and @src
46 * @dst: buffer to hold the decrypted plaintext
47 * @src: buffer providing the ciphertext
49 * Decrypts @src into @dst
51 void xts_decrypt(const void *datactx
,
53 xts_cipher_func
*encfunc
,
54 xts_cipher_func
*decfunc
,
62 * @datactx: the cipher context for data encryption
63 * @tweakctx: the cipher context for tweak encryption
64 * @encfunc: the cipher function for encryption
65 * @decfunc: the cipher function for decryption
66 * @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
67 * @length: the length of @dst and @src
68 * @dst: buffer to hold the encrypted ciphertext
69 * @src: buffer providing the plaintext
71 * Decrypts @src into @dst
73 void xts_encrypt(const void *datactx
,
75 xts_cipher_func
*encfunc
,
76 xts_cipher_func
*decfunc
,
83 #endif /* QCRYPTO_XTS_H */