-/* $OpenBSD: aes_cbc.c,v 1.12 2014/06/12 15:49:27 deraadt Exp $ */
+/* $OpenBSD: aes_cbc.c,v 1.13 2024/03/28 12:28:48 jsing Exp $ */
/* ====================================================================
* Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
*
#include <openssl/aes.h>
#include <openssl/modes.h>
-void
-AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
+#ifdef HAVE_AES_CBC_ENCRYPT_INTERNAL
+void aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out,
+ size_t len, const AES_KEY *key, unsigned char *ivec, const int enc);
+
+#else
+static inline void
+aes_cbc_encrypt_internal(const unsigned char *in, unsigned char *out,
size_t len, const AES_KEY *key, unsigned char *ivec, const int enc)
{
if (enc)
CRYPTO_cbc128_decrypt(in, out, len, key, ivec,
(block128_f)AES_decrypt);
}
+#endif
+
+void
+AES_cbc_encrypt(const unsigned char *in, unsigned char *out,
+ size_t len, const AES_KEY *key, unsigned char *ivec, const int enc)
+{
+ aes_cbc_encrypt_internal(in, out, len, key, ivec, enc);
+}
&mov (&DWP(12,$acc),$s3);
&function_end("AES_decrypt");
-# void AES_cbc_encrypt (const void char *inp, unsigned char *out,
-# size_t length, const AES_KEY *key,
-# unsigned char *ivp,const int enc);
+# void aes_cbc_encrypt_internal(const void char *inp, unsigned char *out,
+# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc);
{
# stack frame layout
# -4(%esp) # return address 0(%esp)
my $aes_key=&DWP(76,"esp"); # copy of aes_key
my $mark=&DWP(76+240,"esp"); # copy of aes_key->rounds
-&function_begin("AES_cbc_encrypt");
+&function_begin("aes_cbc_encrypt_internal");
&mov ($s2 eq "ecx"? $s2 : "",&wparam(2)); # load len
&cmp ($s2,0);
&je (&label("drop_out"));
&mov ("esp",$_esp);
&popf ();
-&function_end("AES_cbc_encrypt");
+&function_end("aes_cbc_encrypt_internal");
}
#------------------------------------------------------------------#
.size AES_set_decrypt_key,.-AES_set_decrypt_key
___
-# void AES_cbc_encrypt (const void char *inp, unsigned char *out,
-# size_t length, const AES_KEY *key,
-# unsigned char *ivp,const int enc);
+# void aes_cbc_encrypt_internal(const void char *inp, unsigned char *out,
+# size_t length, const AES_KEY *key, unsigned char *ivp,const int enc);
{
# stack frame layout
# -8(%rsp) return address
my $mark="80+240(%rsp)"; # copy of aes_key->rounds
$code.=<<___;
-.globl AES_cbc_encrypt
-.type AES_cbc_encrypt,\@function,6
+.globl aes_cbc_encrypt_internal
+.type aes_cbc_encrypt_internal,\@function,6
.align 16
.extern OPENSSL_ia32cap_P
.hidden OPENSSL_ia32cap_P
.globl asm_AES_cbc_encrypt
.hidden asm_AES_cbc_encrypt
asm_AES_cbc_encrypt:
-AES_cbc_encrypt:
+aes_cbc_encrypt_internal:
_CET_ENDBR
cmp \$0,%rdx # check length
je .Lcbc_epilogue
popfq
.Lcbc_epilogue:
ret
-.size AES_cbc_encrypt,.-AES_cbc_encrypt
+.size aes_cbc_encrypt_internal,.-aes_cbc_encrypt_internal
___
}
-# $OpenBSD: Makefile.inc,v 1.18 2024/03/28 01:57:00 jsing Exp $
+# $OpenBSD: Makefile.inc,v 1.19 2024/03/28 12:28:48 jsing Exp $
# amd64-specific libcrypto build rules
CFLAGS+= -DVPAES_ASM
SSLASM+= aes vpaes-x86_64
SSLASM+= aes aesni-x86_64
+CFLAGS+= -DHAVE_AES_CBC_ENCRYPT_INTERNAL
+SRCS+= aes_cbc.c
# bn
CFLAGS+= -DOPENSSL_IA32_SSE2
CFLAGS+= -DRSA_ASM
-# $OpenBSD: Makefile.inc,v 1.15 2024/03/28 01:57:00 jsing Exp $
+# $OpenBSD: Makefile.inc,v 1.16 2024/03/28 12:28:48 jsing Exp $
# i386-specific libcrypto build rules
CFLAGS+= -DVPAES_ASM
SSLASM+= aes vpaes-x86
SSLASM+= aes aesni-x86
+CFLAGS+= -DHAVE_AES_CBC_ENCRYPT_INTERNAL
+SRCS+= aes_cbc.c
# bn
CFLAGS+= -DOPENSSL_IA32_SSE2
SSLASM+= bn bn-586