summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/aes/aes.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/aes/aes.c')
-rw-r--r--src/lib/libcrypto/aes/aes.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/lib/libcrypto/aes/aes.c b/src/lib/libcrypto/aes/aes.c
index e9dbe975e3..45b7a3b109 100644
--- a/src/lib/libcrypto/aes/aes.c
+++ b/src/lib/libcrypto/aes/aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: aes.c,v 1.10 2025/06/27 17:10:45 jsing Exp $ */ 1/* $OpenBSD: aes.c,v 1.11 2025/07/13 06:01:33 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2002-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -57,6 +57,7 @@
57 57
58#include "crypto_arch.h" 58#include "crypto_arch.h"
59#include "crypto_internal.h" 59#include "crypto_internal.h"
60#include "modes_local.h"
60 61
61static const unsigned char aes_wrap_default_iv[] = { 62static const unsigned char aes_wrap_default_iv[] = {
62 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 63 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6,
@@ -322,6 +323,35 @@ AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, size_t length,
322} 323}
323LCRYPTO_ALIAS(AES_ofb128_encrypt); 324LCRYPTO_ALIAS(AES_ofb128_encrypt);
324 325
326void
327aes_xts_encrypt_generic(const unsigned char *in, unsigned char *out, size_t len,
328 const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16],
329 int encrypt)
330{
331 XTS128_CONTEXT xctx;
332
333 if (encrypt)
334 xctx.block1 = aes_encrypt_block128;
335 else
336 xctx.block1 = aes_decrypt_block128;
337
338 xctx.block2 = aes_encrypt_block128;
339 xctx.key1 = key1;
340 xctx.key2 = key2;
341
342 CRYPTO_xts128_encrypt(&xctx, iv, in, out, len, encrypt);
343}
344
345#ifndef HAVE_AES_XTS_ENCRYPT_INTERNAL
346void
347aes_xts_encrypt_internal(const unsigned char *in, unsigned char *out, size_t len,
348 const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16],
349 int encrypt)
350{
351 aes_xts_encrypt_generic(in, out, len, key1, key2, iv, encrypt);
352}
353#endif
354
325int 355int
326AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out, 356AES_wrap_key(AES_KEY *key, const unsigned char *iv, unsigned char *out,
327 const unsigned char *in, unsigned int inlen) 357 const unsigned char *in, unsigned int inlen)