summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rc4/rc4.c
diff options
context:
space:
mode:
authorjsing <>2024-03-28 01:49:29 +0000
committerjsing <>2024-03-28 01:49:29 +0000
commitefdc2fdd7e31b41f518a70445b050722a765ff02 (patch)
treeca5f083b55057a8157b330fc459a97936af57f81 /src/lib/libcrypto/rc4/rc4.c
parent852ce4f4fa6a26ebd4801907061f85fb0c1f4e99 (diff)
downloadopenbsd-efdc2fdd7e31b41f518a70445b050722a765ff02.tar.gz
openbsd-efdc2fdd7e31b41f518a70445b050722a765ff02.tar.bz2
openbsd-efdc2fdd7e31b41f518a70445b050722a765ff02.zip
Use C functions for RC4 public API.
Rather than having public API switch between C and assembly, always use C functions as entry points, which then call an assembly implementation (if available). This makes it significantly easier to deal with symbol aliasing/namespaces and it also means we benefit from vulnerability prevention provided by the C compiler. Rename the assembly generated functions from RC4() to rc4_internal() and RC4_set_key() to rc4_set_key_internal(). Always include rc4.c and change it to use defines that are similar to those used in BN. ok beck@ joshua@ tb@
Diffstat (limited to 'src/lib/libcrypto/rc4/rc4.c')
-rw-r--r--src/lib/libcrypto/rc4/rc4.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/lib/libcrypto/rc4/rc4.c b/src/lib/libcrypto/rc4/rc4.c
index bbf7c3ae4e..8ff8191a51 100644
--- a/src/lib/libcrypto/rc4/rc4.c
+++ b/src/lib/libcrypto/rc4/rc4.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rc4.c,v 1.8 2024/03/27 12:54:42 jsing Exp $ */ 1/* $OpenBSD: rc4.c,v 1.9 2024/03/28 01:49:29 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -68,8 +68,13 @@
68 * Date: Wed, 14 Sep 1994 06:35:31 GMT 68 * Date: Wed, 14 Sep 1994 06:35:31 GMT
69 */ 69 */
70 70
71void 71#ifdef HAVE_RC4_INTERNAL
72RC4(RC4_KEY *key, size_t len, const unsigned char *indata, 72void rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata,
73 unsigned char *outdata);
74
75#else
76static void
77rc4_internal(RC4_KEY *key, size_t len, const unsigned char *indata,
73 unsigned char *outdata) 78 unsigned char *outdata)
74{ 79{
75 RC4_INT *d; 80 RC4_INT *d;
@@ -251,9 +256,14 @@ RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
251 key->x = x; 256 key->x = x;
252 key->y = y; 257 key->y = y;
253} 258}
259#endif
254 260
255void 261#ifdef HAVE_RC4_SET_KEY_INTERNAL
256RC4_set_key(RC4_KEY *key, int len, const unsigned char *data) 262void rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data);
263
264#else
265static void
266rc4_set_key_internal(RC4_KEY *key, int len, const unsigned char *data)
257{ 267{
258 RC4_INT tmp; 268 RC4_INT tmp;
259 int id1, id2; 269 int id1, id2;
@@ -281,3 +291,17 @@ RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
281 SK_LOOP(d, i + 3); 291 SK_LOOP(d, i + 3);
282 } 292 }
283} 293}
294#endif
295
296void
297RC4(RC4_KEY *key, size_t len, const unsigned char *indata,
298 unsigned char *outdata)
299{
300 rc4_internal(key, len, indata, outdata);
301}
302
303void
304RC4_set_key(RC4_KEY *key, int len, const unsigned char *data)
305{
306 rc4_set_key_internal(key, len, data);
307}