Merge remote-tracking branch 'kraxel/tags/pull-vga-20161205-1' into staging
[qemu/ar7.git] / include / crypto / xts.h
blobda32ab82b64c650dbb80a0604dae2038cf8fd3ea
1 /*
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
26 #ifndef QCRYPTO_XTS_H
27 #define QCRYPTO_XTS_H
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,
36 size_t length,
37 uint8_t *dst,
38 const uint8_t *src);
40 /**
41 * xts_decrypt:
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,
54 const void *tweakctx,
55 xts_cipher_func *encfunc,
56 xts_cipher_func *decfunc,
57 uint8_t *iv,
58 size_t length,
59 uint8_t *dst,
60 const uint8_t *src);
62 /**
63 * xts_decrypt:
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,
76 const void *tweakctx,
77 xts_cipher_func *encfunc,
78 xts_cipher_func *decfunc,
79 uint8_t *iv,
80 size_t length,
81 uint8_t *dst,
82 const uint8_t *src);
85 #endif /* QCRYPTO_XTS_H */