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"
30 #include "qapi/error.h"
33 #define XTS_BLOCK_SIZE 16
35 typedef void xts_cipher_func(const void *ctx
,
42 * @datactx: the cipher context for data decryption
43 * @tweakctx: the cipher context for tweak decryption
44 * @encfunc: the cipher function for encryption
45 * @decfunc: the cipher function for decryption
46 * @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
47 * @length: the length of @dst and @src
48 * @dst: buffer to hold the decrypted plaintext
49 * @src: buffer providing the ciphertext
51 * Decrypts @src into @dst
53 void xts_decrypt(const void *datactx
,
55 xts_cipher_func
*encfunc
,
56 xts_cipher_func
*decfunc
,
64 * @datactx: the cipher context for data encryption
65 * @tweakctx: the cipher context for tweak encryption
66 * @encfunc: the cipher function for encryption
67 * @decfunc: the cipher function for decryption
68 * @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
69 * @length: the length of @dst and @src
70 * @dst: buffer to hold the encrypted ciphertext
71 * @src: buffer providing the plaintext
73 * Decrypts @src into @dst
75 void xts_encrypt(const void *datactx
,
77 xts_cipher_func
*encfunc
,
78 xts_cipher_func
*decfunc
,
85 #endif /* QCRYPTO_XTS_H */