3 XEX-based tweaked-codebook mode with ciphertext stealing (XTS)
5 Copyright (C) 2005 Niels Möller
6 Copyright (C) 2018 Red Hat, Inc.
8 This file is part of GNU Nettle.
10 GNU Nettle is free software: you can redistribute it and/or
11 modify it under the terms of either:
13 * the GNU Lesser General Public License as published by the Free
14 Software Foundation; either version 3 of the License, or (at your
15 option) any later version.
19 * the GNU General Public License as published by the Free
20 Software Foundation; either version 2 of the License, or (at your
21 option) any later version.
23 or both in parallel, as here.
25 GNU Nettle is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 General Public License for more details.
30 You should have received copies of the GNU General Public License and
31 the GNU Lesser General Public License along with this program. If
32 not, see http://www.gnu.org/licenses/.
36 #ifndef NETTLE_XTS_H_INCLUDED
37 #define NETTLE_XTS_H_INCLUDED
39 #include "nettle-types.h"
47 #define xts_encrypt_message nettle_xts_encrypt_message
48 #define xts_decrypt_message nettle_xts_decrypt_message
49 #define xts_aes128_set_encrypt_key nettle_xts_aes128_set_encrypt_key
50 #define xts_aes128_set_decrypt_key nettle_xts_aes128_set_decrypt_key
51 #define xts_aes128_encrypt_message nettle_xts_aes128_encrypt_message
52 #define xts_aes128_decrypt_message nettle_xts_aes128_decrypt_message
53 #define xts_aes256_set_encrypt_key nettle_xts_aes256_set_encrypt_key
54 #define xts_aes256_set_decrypt_key nettle_xts_aes256_set_decrypt_key
55 #define xts_aes256_encrypt_message nettle_xts_aes256_encrypt_message
56 #define xts_aes256_decrypt_message nettle_xts_aes256_decrypt_message
58 #define XTS_BLOCK_SIZE 16
61 xts_encrypt_message(const void *enc_ctx, const void *twk_ctx,
62 nettle_cipher_func *encf,
63 const uint8_t *tweak, size_t length,
64 uint8_t *dst, const uint8_t *src);
66 xts_decrypt_message(const void *dec_ctx, const void *twk_ctx,
67 nettle_cipher_func *decf, nettle_cipher_func *encf,
68 const uint8_t *tweak, size_t length,
69 uint8_t *dst, const uint8_t *src);
71 /* XTS Mode with AES-128 */
72 struct xts_aes128_key {
73 struct aes128_ctx cipher;
74 struct aes128_ctx tweak_cipher;
78 xts_aes128_set_encrypt_key(struct xts_aes128_key *xts_key,
82 xts_aes128_set_decrypt_key(struct xts_aes128_key *xts_key,
86 xts_aes128_encrypt_message(struct xts_aes128_key *xtskey,
87 const uint8_t *tweak, size_t length,
88 uint8_t *dst, const uint8_t *src);
91 xts_aes128_decrypt_message(struct xts_aes128_key *xts_key,
92 const uint8_t *tweak, size_t length,
93 uint8_t *dst, const uint8_t *src);
95 /* XTS Mode with AES-256 */
96 struct xts_aes256_key {
97 struct aes256_ctx cipher;
98 struct aes256_ctx tweak_cipher;
102 xts_aes256_set_encrypt_key(struct xts_aes256_key *xts_key,
106 xts_aes256_set_decrypt_key(struct xts_aes256_key *xts_key,
110 xts_aes256_encrypt_message(struct xts_aes256_key *xts_key,
111 const uint8_t *tweak, size_t length,
112 uint8_t *dst, const uint8_t *src);
115 xts_aes256_decrypt_message(struct xts_aes256_key *xts_key,
116 const uint8_t *tweak, size_t length,
117 uint8_t *dst, const uint8_t *src);
123 #endif /* NETTLE_XTS_H_INCLUDED */