Index | Thread | Search

From:
Miod Vallat <miod@online.fr>
Subject:
dead code tells no tales, 3/16
To:
tech@openbsd.org
Date:
Sun, 20 Sep 2026 21:04:26 +0000

Download raw body.

Thread
  • Miod Vallat:

    dead code tells no tales, 3/16

None of these functions seem to be used in the kernel. They are used by
some boot blocks, but boot blocks use the libsa copy of this code.

Index: sys/crypto/arc4.c
===================================================================
RCS file: /OpenBSD/src/sys/crypto/arc4.c,v
diff -u -p -u -p -r1.3 arc4.c
--- sys/crypto/arc4.c	11 Sep 2007 12:07:05 -0000	1.3
+++ sys/crypto/arc4.c	20 Sep 2026 16:47:44 -0000
@@ -59,20 +59,6 @@ rc4_crypt(struct rc4_ctx *ctx, u_char *s
 }
 
 void
-rc4_getbytes(struct rc4_ctx *ctx, u_char *dst, u_int32_t len)
-{
-	u_int32_t i;
-
-	for (i = 0; i < len; i++) {
-		ctx->x = (ctx->x + 1) & (RC4STATE - 1);
-		ctx->y = (ctx->state[ctx->x] + ctx->y) & (RC4STATE - 1);
-		RC4SWAP(ctx->x, ctx->y);
-		dst[i] = ctx->state[
-		   (ctx->state[ctx->x] + ctx->state[ctx->y]) & (RC4STATE - 1)];
-	}
-}
-
-void
 rc4_skip(struct rc4_ctx *ctx, u_int32_t len)
 {
 	for (; len > 0; len--) {
Index: sys/crypto/arc4.h
===================================================================
RCS file: /OpenBSD/src/sys/crypto/arc4.h,v
diff -u -p -u -p -r1.3 arc4.h
--- sys/crypto/arc4.h	11 Sep 2007 12:07:05 -0000	1.3
+++ sys/crypto/arc4.h	20 Sep 2026 16:47:44 -0000
@@ -28,6 +28,4 @@ void	rc4_keysetup(struct rc4_ctx *, u_ch
 void	rc4_crypt(struct rc4_ctx *, u_char *, u_char *, u_int32_t)
     __attribute__((__bounded__(__buffer__,2,4)))
     __attribute__((__bounded__(__buffer__,3,4)));
-void	rc4_getbytes(struct rc4_ctx *, u_char *, u_int32_t)
-    __attribute__((__bounded__(__buffer__,2,3)));
 void	rc4_skip(struct rc4_ctx *, u_int32_t);
Index: sys/crypto/blf.c
===================================================================
RCS file: /OpenBSD/src/sys/crypto/blf.c,v
diff -u -p -u -p -r1.9 blf.c
--- sys/crypto/blf.c	28 Aug 2022 11:11:25 -0000	1.9
+++ sys/crypto/blf.c	20 Sep 2026 16:47:44 -0000
@@ -440,48 +440,6 @@ Blowfish_expand0state(blf_ctx *c, const 
 
 
 void
-Blowfish_expandstate(blf_ctx *c, const u_int8_t *data, u_int16_t databytes,
-    const u_int8_t *key, u_int16_t keybytes)
-{
-	u_int16_t i;
-	u_int16_t j;
-	u_int16_t k;
-	u_int32_t temp;
-	u_int32_t d[2];
-
-	j = 0;
-	for (i = 0; i < BLF_N + 2; i++) {
-		/* Extract 4 int8 to 1 int32 from keystream */
-		temp = Blowfish_stream2word(key, keybytes, &j);
-		c->P[i] = c->P[i] ^ temp;
-	}
-
-	j = 0;
-	d[0] = 0x00000000;
-	d[1] = 0x00000000;
-	for (i = 0; i < BLF_N + 2; i += 2) {
-		d[0] ^= Blowfish_stream2word(data, databytes, &j);
-		d[1] ^= Blowfish_stream2word(data, databytes, &j);
-		Blowfish_encipher(c, d);
-
-		c->P[i] = d[0];
-		c->P[i + 1] = d[1];
-	}
-
-	for (i = 0; i < 4; i++) {
-		for (k = 0; k < 256; k += 2) {
-			d[0]^= Blowfish_stream2word(data, databytes, &j);
-			d[1] ^= Blowfish_stream2word(data, databytes, &j);
-			Blowfish_encipher(c, d);
-
-			c->S[i][k] = d[0];
-			c->S[i][k + 1] = d[1];
-		}
-	}
-
-}
-
-void
 blf_key(blf_ctx *c, const u_int8_t *k, u_int16_t len)
 {
 	/* Initialize S-boxes and subkeys with Pi */
Index: sys/crypto/blf.h
===================================================================
RCS file: /OpenBSD/src/sys/crypto/blf.h,v
diff -u -p -u -p -r1.7 blf.h
--- sys/crypto/blf.h	29 Nov 2021 01:04:45 -0000	1.7
+++ sys/crypto/blf.h	20 Sep 2026 16:47:44 -0000
@@ -59,7 +59,6 @@ void Blowfish_encipher(blf_ctx *, u_int3
 void Blowfish_decipher(blf_ctx *, u_int32_t *);
 void Blowfish_initstate(blf_ctx *);
 void Blowfish_expand0state(blf_ctx *, const u_int8_t *, u_int16_t);
-void Blowfish_expandstate(blf_ctx *, const u_int8_t *, u_int16_t, const u_int8_t *, u_int16_t);
 
 /* Standard Blowfish */