19
19
*/
20
20
21
21
#include " crypto/aes.h"
22
- #include " crypto/xts.h"
23
22
24
23
typedef struct QCryptoCipherBuiltinAESContext QCryptoCipherBuiltinAESContext;
25
24
struct QCryptoCipherBuiltinAESContext {
@@ -31,7 +30,6 @@ typedef struct QCryptoCipherBuiltinAES QCryptoCipherBuiltinAES;
31
30
struct QCryptoCipherBuiltinAES {
32
31
QCryptoCipher base;
33
32
QCryptoCipherBuiltinAESContext key;
34
- QCryptoCipherBuiltinAESContext key_tweak;
35
33
uint8_t iv[AES_BLOCK_SIZE];
36
34
};
37
35
@@ -193,39 +191,6 @@ static int qcrypto_cipher_aes_decrypt_cbc(QCryptoCipher *cipher,
193
191
return 0 ;
194
192
}
195
193
196
- static int qcrypto_cipher_aes_encrypt_xts (QCryptoCipher *cipher,
197
- const void *in, void *out,
198
- size_t len, Error **errp)
199
- {
200
- QCryptoCipherBuiltinAES *ctx
201
- = container_of (cipher, QCryptoCipherBuiltinAES, base);
202
-
203
- if (!qcrypto_length_check (len, AES_BLOCK_SIZE, errp)) {
204
- return -1 ;
205
- }
206
- xts_encrypt (&ctx->key , &ctx->key_tweak ,
207
- do_aes_encrypt_ecb, do_aes_decrypt_ecb,
208
- ctx->iv , len, out, in);
209
- return 0 ;
210
- }
211
-
212
- static int qcrypto_cipher_aes_decrypt_xts (QCryptoCipher *cipher,
213
- const void *in, void *out,
214
- size_t len, Error **errp)
215
- {
216
- QCryptoCipherBuiltinAES *ctx
217
- = container_of (cipher, QCryptoCipherBuiltinAES, base);
218
-
219
- if (!qcrypto_length_check (len, AES_BLOCK_SIZE, errp)) {
220
- return -1 ;
221
- }
222
- xts_decrypt (&ctx->key , &ctx->key_tweak ,
223
- do_aes_encrypt_ecb, do_aes_decrypt_ecb,
224
- ctx->iv , len, out, in);
225
- return 0 ;
226
- }
227
-
228
-
229
194
static int qcrypto_cipher_aes_setiv (QCryptoCipher *cipher, const uint8_t *iv,
230
195
size_t niv, Error **errp)
231
196
{
@@ -256,14 +221,6 @@ static const struct QCryptoCipherDriver qcrypto_cipher_aes_driver_cbc = {
256
221
.cipher_free = qcrypto_cipher_ctx_free,
257
222
};
258
223
259
- static const struct QCryptoCipherDriver qcrypto_cipher_aes_driver_xts = {
260
- .cipher_encrypt = qcrypto_cipher_aes_encrypt_xts,
261
- .cipher_decrypt = qcrypto_cipher_aes_decrypt_xts,
262
- .cipher_setiv = qcrypto_cipher_aes_setiv,
263
- .cipher_free = qcrypto_cipher_ctx_free,
264
- };
265
-
266
-
267
224
bool qcrypto_cipher_supports (QCryptoCipherAlgorithm alg,
268
225
QCryptoCipherMode mode)
269
226
{
@@ -274,7 +231,6 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
274
231
switch (mode) {
275
232
case QCRYPTO_CIPHER_MODE_ECB:
276
233
case QCRYPTO_CIPHER_MODE_CBC:
277
- case QCRYPTO_CIPHER_MODE_XTS:
278
234
return true ;
279
235
default :
280
236
return false ;
@@ -310,29 +266,13 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
310
266
case QCRYPTO_CIPHER_MODE_CBC:
311
267
drv = &qcrypto_cipher_aes_driver_cbc;
312
268
break ;
313
- case QCRYPTO_CIPHER_MODE_XTS:
314
- drv = &qcrypto_cipher_aes_driver_xts;
315
- break ;
316
269
default :
317
270
goto bad_mode;
318
271
}
319
272
320
273
ctx = g_new0 (QCryptoCipherBuiltinAES, 1 );
321
274
ctx->base .driver = drv;
322
275
323
- if (mode == QCRYPTO_CIPHER_MODE_XTS) {
324
- nkey /= 2 ;
325
- if (AES_set_encrypt_key (key + nkey, nkey * 8 ,
326
- &ctx->key_tweak .enc )) {
327
- error_setg (errp, " Failed to set encryption key" );
328
- goto error;
329
- }
330
- if (AES_set_decrypt_key (key + nkey, nkey * 8 ,
331
- &ctx->key_tweak .dec )) {
332
- error_setg (errp, " Failed to set decryption key" );
333
- goto error;
334
- }
335
- }
336
276
if (AES_set_encrypt_key (key, nkey * 8 , &ctx->key .enc )) {
337
277
error_setg (errp, " Failed to set encryption key" );
338
278
goto error;
0 commit comments