]> git.proxmox.com Git - mirror_qemu.git/blob - include/crypto/xts.h
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2016-03-17-3' into...
[mirror_qemu.git] / include / crypto / xts.h
1 /*
2 * QEMU Crypto XTS cipher mode
3 *
4 * Copyright (c) 2015-2016 Red Hat, Inc.
5 *
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.
10 *
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.
15 *
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/>.
18 *
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
23 *
24 */
25
26
27 #ifndef QCRYPTO_XTS_H_
28 #define QCRYPTO_XTS_H_
29
30 #include "qemu-common.h"
31 #include "qapi/error.h"
32
33
34 #define XTS_BLOCK_SIZE 16
35
36 typedef void xts_cipher_func(const void *ctx,
37 size_t length,
38 uint8_t *dst,
39 const uint8_t *src);
40
41 /**
42 * xts_decrypt:
43 * @datactx: the cipher context for data decryption
44 * @tweakctx: the cipher context for tweak decryption
45 * @encfunc: the cipher function for encryption
46 * @decfunc: the cipher function for decryption
47 * @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
48 * @length: the length of @dst and @src
49 * @dst: buffer to hold the decrypted plaintext
50 * @src: buffer providing the ciphertext
51 *
52 * Decrypts @src into @dst
53 */
54 void xts_decrypt(const void *datactx,
55 const void *tweakctx,
56 xts_cipher_func *encfunc,
57 xts_cipher_func *decfunc,
58 uint8_t *iv,
59 size_t length,
60 uint8_t *dst,
61 const uint8_t *src);
62
63 /**
64 * xts_decrypt:
65 * @datactx: the cipher context for data encryption
66 * @tweakctx: the cipher context for tweak encryption
67 * @encfunc: the cipher function for encryption
68 * @decfunc: the cipher function for decryption
69 * @iv: the initialization vector tweak of XTS_BLOCK_SIZE bytes
70 * @length: the length of @dst and @src
71 * @dst: buffer to hold the encrypted ciphertext
72 * @src: buffer providing the plaintext
73 *
74 * Decrypts @src into @dst
75 */
76 void xts_encrypt(const void *datactx,
77 const void *tweakctx,
78 xts_cipher_func *encfunc,
79 xts_cipher_func *decfunc,
80 uint8_t *iv,
81 size_t length,
82 uint8_t *dst,
83 const uint8_t *src);
84
85
86 #endif /* QCRYPTO_XTS_H_ */