-# $OpenBSD: Makefile.inc,v 1.16 2024/03/28 01:41:16 jsing Exp $
+# $OpenBSD: Makefile.inc,v 1.17 2024/03/28 01:49:29 jsing Exp $
# amd64-specific libcrypto build rules
CFLAGS+= -DGHASH_ASM
SSLASM+= modes ghash-x86_64
# rc4
+CFLAGS+= -DHAVE_RC4_INTERNAL
+CFLAGS+= -DHAVE_RC4_SET_KEY_INTERNAL
SSLASM+= rc4 rc4-x86_64
+SRCS+= rc4.c
# ripemd
# sha
CFLAGS+= -DSHA1_ASM
-# $OpenBSD: Makefile.inc,v 1.13 2024/03/28 01:41:16 jsing Exp $
+# $OpenBSD: Makefile.inc,v 1.14 2024/03/28 01:49:29 jsing Exp $
# i386-specific libcrypto build rules
CFLAGS+= -DGHASH_ASM
SSLASM+= modes ghash-x86
# rc4
+CFLAGS+= -DHAVE_RC4_INTERNAL
+CFLAGS+= -DHAVE_RC4_SET_KEY_INTERNAL
SSLASM+= rc4 rc4-586
+SRCS+= rc4.c
# sha
CFLAGS+= -DSHA1_ASM
SSLASM+= sha sha1-586
&external_label("OPENSSL_ia32cap_P");
-# void RC4(RC4_KEY *key,size_t len,const unsigned char *inp,unsigned char *out);
-&function_begin("RC4");
+# void rc4_internal(RC4_KEY *key, size_t len, const unsigned char *inp,
+# unsigned char *out);
+&function_begin("rc4_internal");
&mov ($dat,&wparam(0)); # load key schedule pointer
&mov ($ty, &wparam(1)); # load len
&mov ($inp,&wparam(2)); # load inp
&mov (&DWP(-4,$dat),$yy); # save key->y
&mov (&BP(-8,$dat),&LB($xx)); # save key->x
&set_label("abort");
-&function_end("RC4");
+&function_end("rc4_internal");
########################################################################
$ido="ecx";
$idx="edx";
-# void RC4_set_key(RC4_KEY *key,int len,const unsigned char *data);
-&function_begin("RC4_set_key");
+# void rc4_set_key_internal(RC4_KEY *key,int len,const unsigned char *data);
+&function_begin("rc4_set_key_internal");
&mov ($out,&wparam(0)); # load key
&mov ($idi,&wparam(1)); # load len
&mov ($inp,&wparam(2)); # load data
&xor ("eax","eax");
&mov (&DWP(-8,$out),"eax"); # key->x=0;
&mov (&DWP(-4,$out),"eax"); # key->y=0;
-&function_end("RC4_set_key");
+&function_end("rc4_set_key_internal");
&asm_finish();
.extern OPENSSL_ia32cap_P
.hidden OPENSSL_ia32cap_P
-.globl RC4
-.type RC4,\@function,4
+.globl rc4_internal
+.type rc4_internal,\@function,4
.align 16
-RC4:
+rc4_internal:
_CET_ENDBR
or $len,$len
jne .Lentry
add \$24,%rsp
.Lepilogue:
ret
-.size RC4,.-RC4
+.size rc4_internal,.-rc4_internal
___
}
$ido="%r9";
$code.=<<___;
-.globl RC4_set_key
-.type RC4_set_key,\@function,3
+.globl rc4_set_key_internal
+.type rc4_set_key_internal,\@function,3
.align 16
-RC4_set_key:
+rc4_set_key_internal:
_CET_ENDBR
lea 8($dat),$dat
lea ($inp,$len),$inp
mov %eax,-8($dat)
mov %eax,-4($dat)
ret
-.size RC4_set_key,.-RC4_set_key
+.size rc4_set_key_internal,.-rc4_set_key_internal
___
sub reg_part {
-/* $OpenBSD: rc4.c,v 1.8 2024/03/27 12:54:42 jsing Exp $ */
+/* $OpenBSD: rc4.c,v 1.9 2024/03/28 01:49:29 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* Date: Wed, 14 Sep 1994 06:35:31 GMT
*/
-void
-RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
+#ifdef HAVE_RC4_INTERNAL
+void rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata,
+ unsigned char *outdata);
+
+#else
+static void
+rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata,
unsigned char *outdata)
{
RC4_INT *d;
key->x = x;
key->y = y;
}
+#endif
-void
-RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
+#ifdef HAVE_RC4_SET_KEY_INTERNAL
+void rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data);
+
+#else
+static void
+rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data)
{
RC4_INT tmp;
int id1, id2;
SK_LOOP(d, i + 3);
}
}
+#endif
+
+void
+RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
+ unsigned char *outdata)
+{
+ rc4_internal(key, len, indata, outdata);
+}
+
+void
+RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
+{
+ rc4_set_key_internal(key, len, data);
+}