From dd4d5df42d20731f11f83e857fa24160ad1b4b5f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Tue, 28 Mar 2000 14:24:32 +0200
Subject: [PATCH] Renamed rc4 to arcfour.

Rev: lib/modules/Crypto/randomness.pmod:1.15
Rev: src/modules/_Crypto/StdCrypt.pike:1.5
Rev: src/modules/_Crypto/crypto.c:1.31
Rev: src/modules/_Crypto/crypto.h:1.4
Rev: src/modules/_Crypto/include/arcfour.h:1.4
Rev: src/modules/_Crypto/include/rc4.h:1.4(DEAD)
Rev: src/modules/_Crypto/lib/Makefile.in:1.21
Rev: src/modules/_Crypto/lib/arcfour.c:1.7
Rev: src/modules/_Crypto/lib/rc4.c:1.7(DEAD)
Rev: src/modules/_Crypto/testsuite.in:1.13
---
 .gitattributes                               |  2 ++
 lib/modules/Crypto/randomness.pmod           | 38 ++++++++++----------
 src/modules/_Crypto/StdCrypt.pike            |  4 +--
 src/modules/_Crypto/crypto.c                 |  6 ++--
 src/modules/_Crypto/crypto.h                 |  6 ++--
 src/modules/_Crypto/include/arcfour.h        | 22 ++++++++++++
 src/modules/_Crypto/include/rc4.h            | 22 ------------
 src/modules/_Crypto/lib/Makefile.in          |  4 +--
 src/modules/_Crypto/lib/{rc4.c => arcfour.c} | 10 +++---
 src/modules/_Crypto/testsuite.in             | 18 +++++-----
 10 files changed, 67 insertions(+), 65 deletions(-)
 create mode 100644 src/modules/_Crypto/include/arcfour.h
 delete mode 100644 src/modules/_Crypto/include/rc4.h
 rename src/modules/_Crypto/lib/{rc4.c => arcfour.c} (74%)

diff --git a/.gitattributes b/.gitattributes
index 9436fa25be..07f8033a05 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -367,6 +367,7 @@ testfont binary
 /src/modules/_Crypto/idea.pike foreign_ident
 /src/modules/_Crypto/include/.exportable_files foreign_ident
 /src/modules/_Crypto/include/RCSID.h foreign_ident
+/src/modules/_Crypto/include/arcfour.h foreign_ident
 /src/modules/_Crypto/include/cast.h foreign_ident
 /src/modules/_Crypto/include/crypto_types.h foreign_ident
 /src/modules/_Crypto/include/des.h foreign_ident
@@ -377,6 +378,7 @@ testfont binary
 /src/modules/_Crypto/invert.c foreign_ident
 /src/modules/_Crypto/lib/.exportable_files foreign_ident
 /src/modules/_Crypto/lib/Makefile.in foreign_ident
+/src/modules/_Crypto/lib/arcfour.c foreign_ident
 /src/modules/_Crypto/lib/cast.c foreign_ident
 /src/modules/_Crypto/lib/cast_sboxes.h foreign_ident
 /src/modules/_Crypto/lib/configure.in foreign_ident
diff --git a/lib/modules/Crypto/randomness.pmod b/lib/modules/Crypto/randomness.pmod
index b1879bad78..25bb65e735 100644
--- a/lib/modules/Crypto/randomness.pmod
+++ b/lib/modules/Crypto/randomness.pmod
@@ -1,4 +1,4 @@
-/* $Id: randomness.pmod,v 1.14 1999/12/01 22:37:22 marcus Exp $
+/* $Id: randomness.pmod,v 1.15 2000/03/28 12:24:32 grubba Exp $
  */
 
 //! module Crypto
@@ -35,7 +35,7 @@ static constant SYSTEM_COMMANDS = ({
 			
 #define PRIVATE
 			
-PRIVATE object global_rc4;
+PRIVATE object global_arcfour;
 
 // method string some_entropy()
 //	Executes several programs to generate some entropy from their output.
@@ -110,33 +110,33 @@ class pike_random {
   }
 }
 
-#if constant(Crypto.rc4)
-//! class rc4_random
-//!	A pseudo random generator based on the rc4 crypto.
-class rc4_random {
-  inherit Crypto.rc4 : rc4;
+#if constant(Crypto.arcfour)
+//! class arcfour_random
+//!	A pseudo random generator based on the arcfour crypto.
+class arcfour_random {
+  inherit Crypto.arcfour : arcfour;
 
   //! method void create(string secret)
-  //!	Initialize and seed the rc4 random generator.
+  //!	Initialize and seed the arcfour random generator.
   void create(string secret)
   {
     object hash = Crypto.sha();
     hash->update(secret);
     
-    rc4::set_encrypt_key(hash->digest());
+    arcfour::set_encrypt_key(hash->digest());
   }
 
   //! method string read(int len)
   //!	Return a string of the next len random characters from the
-  //!	rc4 random generator.
+  //!	arcfour random generator.
   string read(int len)
   {
     if (len > 16384) return read(len/2)+read(len-len/2);
-    return rc4::crypt("\47" * len);
+    return arcfour::crypt("\47" * len);
   }
 }
 
-#endif /* constant(Crypto.rc4) */
+#endif /* constant(Crypto.arcfour) */
 
 object reasonably_random()
 {
@@ -147,17 +147,17 @@ object reasonably_random()
       return res;
   }
 
-  if (global_rc4)
-    return global_rc4;
+  if (global_arcfour)
+    return global_arcfour;
 
-#if constant(Crypto.rc4)  
+#if constant(Crypto.arcfour)  
   string seed = some_entropy();
   if (strlen(seed) > 2000)
-    return (global_rc4 = rc4_random(sprintf("%4c%O%s", time(), _memory_usage(), seed)));
-#else /* !constant(Crypto.rc4) */
+    return (global_arcfour = arcfour_random(sprintf("%4c%O%s", time(), _memory_usage(), seed)));
+#else /* !constant(Crypto.arcfour) */
   /* Not very random, but at least a fallback... */
-  return global_rc4 = pike_random();
-#endif /* constant(Crypto.rc4) */
+  return global_arcfour = pike_random();
+#endif /* constant(Crypto.arcfour) */
   throw( ({ "Crypto.randomness.reasonably_random: No source found\n", backtrace() }) );
 }
 
diff --git a/src/modules/_Crypto/StdCrypt.pike b/src/modules/_Crypto/StdCrypt.pike
index a079d69128..faf9bf488f 100644
--- a/src/modules/_Crypto/StdCrypt.pike
+++ b/src/modules/_Crypto/StdCrypt.pike
@@ -1,4 +1,4 @@
-/* $Id: StdCrypt.pike,v 1.4 1997/05/31 22:04:07 grubba Exp $
+/* $Id: StdCrypt.pike,v 1.5 2000/03/28 12:22:49 grubba Exp $
  *
  * Cryptography module
  */
@@ -11,7 +11,7 @@
 constant DES = P("des");
 constant IDEA = P("idea");
 constant ROT256 = P("invert");
-constant RC4 = P("rc4");
+constant ARCFOUR = P("arcfour");
 constant SHA = P("sha");
 constant CBC = P("cbc");
 constant crypto_pipe = P("pipe");
diff --git a/src/modules/_Crypto/crypto.c b/src/modules/_Crypto/crypto.c
index ef5378c499..8bd07d0bb0 100644
--- a/src/modules/_Crypto/crypto.c
+++ b/src/modules/_Crypto/crypto.c
@@ -1,5 +1,5 @@
 /*
- * $Id: crypto.c,v 1.30 2000/02/21 01:21:22 hubbe Exp $
+ * $Id: crypto.c,v 1.31 2000/03/28 12:16:39 grubba Exp $
  *
  * A pike module for getting access to some common cryptos.
  *
@@ -519,7 +519,7 @@ void pike_module_init(void)
   pike_idea_init();
   pike_des_init();
   pike_cast_init();
-  pike_rc4_init();
+  pike_arcfour_init();
   pike_rsa_init();
 
   /* END NATIONAL SECURITY */
@@ -539,7 +539,7 @@ void pike_module_exit(void)
   pike_idea_exit();
   pike_des_exit();
   pike_cast_exit();
-  pike_rc4_exit();
+  pike_arcfour_exit();
   pike_rsa_exit();
 
   /* END NATIONAL SECURITY */
diff --git a/src/modules/_Crypto/crypto.h b/src/modules/_Crypto/crypto.h
index 0e9dfaaee4..26b95d0b1b 100644
--- a/src/modules/_Crypto/crypto.h
+++ b/src/modules/_Crypto/crypto.h
@@ -1,5 +1,5 @@
 /*
- * $Id: crypto.h,v 1.3 2000/01/26 19:50:11 grubba Exp $
+ * $Id: crypto.h,v 1.4 2000/03/28 12:20:01 grubba Exp $
  *
  * Prototypes for some functions.
  *
@@ -17,8 +17,8 @@ extern void pike_des_init(void);
 extern void pike_des_exit(void);
 extern void pike_cast_init(void);
 extern void pike_cast_exit(void);
-extern void pike_rc4_init(void);
-extern void pike_rc4_exit(void);
+extern void pike_arcfour_init(void);
+extern void pike_arcfour_exit(void);
 extern void pike_invert_init(void);
 extern void pike_invert_exit(void);
 extern void pike_sha_init(void);
diff --git a/src/modules/_Crypto/include/arcfour.h b/src/modules/_Crypto/include/arcfour.h
new file mode 100644
index 0000000000..7c0e1fbdf6
--- /dev/null
+++ b/src/modules/_Crypto/include/arcfour.h
@@ -0,0 +1,22 @@
+/*
+ * $Id: arcfour.h,v 1.4 2000/03/28 12:21:24 grubba Exp $
+ */
+
+#ifndef ARCFOUR_H_INCLUDED
+#define ARCFOUR_H_INCLUDED
+
+#include "crypto_types.h"
+
+struct arcfour_ctx {
+  unsigned INT8 S[256];
+  unsigned INT8 i, j;
+};
+
+#if 0
+void arcfour_init(struct arcfour_ctx *ctx);
+#endif
+
+void arcfour_set_key(struct arcfour_ctx *ctx, const unsigned INT8 *key, INT32 len);
+void arcfour_crypt(struct arcfour_ctx *ctx, unsigned INT8 *dest, const unsigned INT8 *src, INT32 len);
+
+#endif /* ARCFOUR_H_INCLUDED */
diff --git a/src/modules/_Crypto/include/rc4.h b/src/modules/_Crypto/include/rc4.h
deleted file mode 100644
index 9511c31d83..0000000000
--- a/src/modules/_Crypto/include/rc4.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * $Id: rc4.h,v 1.3 1998/03/28 14:25:55 grubba Exp $
- */
-
-#ifndef RC4_H_INCLUDED
-#define RC4_H_INCLUDED
-
-#include "crypto_types.h"
-
-struct rc4_ctx {
-  unsigned INT8 S[256];
-  unsigned INT8 i, j;
-};
-
-#if 0
-void rc4_init(struct rc4_ctx *ctx);
-#endif
-
-void rc4_set_key(struct rc4_ctx *ctx, const unsigned INT8 *key, INT32 len);
-void rc4_crypt(struct rc4_ctx *ctx, unsigned INT8 *dest, const unsigned INT8 *src, INT32 len);
-
-#endif /* RC4_H_INCLUDED */
diff --git a/src/modules/_Crypto/lib/Makefile.in b/src/modules/_Crypto/lib/Makefile.in
index 30bd75e832..8d43ca3a80 100644
--- a/src/modules/_Crypto/lib/Makefile.in
+++ b/src/modules/_Crypto/lib/Makefile.in
@@ -1,4 +1,4 @@
-# $Id: Makefile.in,v 1.20 1999/11/08 23:20:53 mast Exp $
+# $Id: Makefile.in,v 1.21 2000/03/28 12:22:01 grubba Exp $
 #
 # Makefile for low-level crypto library
 
@@ -146,7 +146,7 @@ desQuickCore.c:
 ### End of rules for desCore
 
 # BEGIN NATIONAL SECURITY
-MASS_DESTRUCTION_OBJS = idea.o rc4.o cast.o $(O)
+MASS_DESTRUCTION_OBJS = idea.o arcfour.o cast.o $(O)
 # END NATIONAL SECURITY
 
 OBJS = $(MASS_DESTRUCTION_OBJS) sha.o md5.o
diff --git a/src/modules/_Crypto/lib/rc4.c b/src/modules/_Crypto/lib/arcfour.c
similarity index 74%
rename from src/modules/_Crypto/lib/rc4.c
rename to src/modules/_Crypto/lib/arcfour.c
index 14f3868a17..bb241baa79 100644
--- a/src/modules/_Crypto/lib/rc4.c
+++ b/src/modules/_Crypto/lib/arcfour.c
@@ -1,17 +1,17 @@
-/* rc4.c
+/* arcfour.c
  *
  */
 
 #include "crypto_types.h"
-#include <rc4.h>
+#include <arcfour.h>
 
 #ifdef RCSID
-RCSID("$Id: rc4.c,v 1.6 1997/04/18 20:08:59 nisse Exp $");
+RCSID("$Id: arcfour.c,v 1.7 2000/03/28 12:19:22 grubba Exp $");
 #endif
 
 #define SWAP(a,b) do { int _t = a; a = b; b = _t; } while(0)
 
-void rc4_set_key(struct rc4_ctx *ctx, const unsigned INT8 *key, INT32 len)
+void arcfour_set_key(struct arcfour_ctx *ctx, const unsigned INT8 *key, INT32 len)
 {
   register unsigned INT8 j; /* Depends on the eight-bitness of these variables. */
   unsigned i;
@@ -32,7 +32,7 @@ void rc4_set_key(struct rc4_ctx *ctx, const unsigned INT8 *key, INT32 len)
   ctx->i = ctx->j = 0;
 }
 
-void rc4_crypt(struct rc4_ctx *ctx, unsigned INT8 *dest, const unsigned INT8 *src, INT32 len)
+void arcfour_crypt(struct arcfour_ctx *ctx, unsigned INT8 *dest, const unsigned INT8 *src, INT32 len)
 {
   register unsigned INT8 i, j; /* Depends on the eight-bitness of these variables */
 
diff --git a/src/modules/_Crypto/testsuite.in b/src/modules/_Crypto/testsuite.in
index 7edd9684b6..7f86a59810 100644
--- a/src/modules/_Crypto/testsuite.in
+++ b/src/modules/_Crypto/testsuite.in
@@ -23,7 +23,7 @@ test_true([[programp(xCrypto.sha)]])
 test_true([[programp(Crypto.des)]])
 test_true([[programp(Crypto.idea)]])
 test_true([[programp(Crypto.cast)]])
-test_true([[programp(Crypto.rc4)]])
+test_true([[programp(Crypto.arcfour)]])
 // END NATIONAL SECURITY
 
 // Functions
@@ -45,7 +45,7 @@ dnl test_true([[programp(Crypto.rsa)]])
 // Randomness submodule
 test_true([[objectp(Crypto.randomness)]])
 test_true([[programp(Crypto.randomness.pike_random)]])
-test_true([[programp(Crypto.randomness.rc4_random)]])
+test_true([[programp(Crypto.randomness.arcfour_random)]])
 test_true([[functionp(Crypto.randomness.reasonably_random)]])
 test_true([[functionp(Crypto.randomness.really_random)]])
 
@@ -117,18 +117,18 @@ test_eq([[Crypto.cast()
 	  ->crypt_block(xCrypto.hex_to_string("7AC816D16E9B302E"))]],
 	[[xCrypto.hex_to_string("0123456789ABCDEF")]])
 
-// RC4
-test_true([[objectp(Crypto.rc4())]])
-test_eq([[Crypto.rc4()->set_encrypt_key(xCrypto.hex_to_string("0123456789abcdef"))
+// ARCFOUR
+test_true([[objectp(Crypto.arcfour())]])
+test_eq([[Crypto.arcfour()->set_encrypt_key(xCrypto.hex_to_string("0123456789abcdef"))
 		->crypt(xCrypto.hex_to_string("0123456789abcdef"))]],
 	[[xCrypto.hex_to_string("75b7878099e0c596")]])
-test_eq([[Crypto.rc4()->set_encrypt_key(xCrypto.hex_to_string("0123456789abcdef"))
+test_eq([[Crypto.arcfour()->set_encrypt_key(xCrypto.hex_to_string("0123456789abcdef"))
 		->crypt(xCrypto.hex_to_string("0000000000000000"))]],
 	[[xCrypto.hex_to_string("7494c2e7104b0879")]])
-test_eq([[Crypto.rc4()->set_encrypt_key(xCrypto.hex_to_string("0000000000000000"))
+test_eq([[Crypto.arcfour()->set_encrypt_key(xCrypto.hex_to_string("0000000000000000"))
 		->crypt(xCrypto.hex_to_string("0000000000000000"))]],
 	[[xCrypto.hex_to_string("de188941a3375d3a")]])
-test_eq([[Crypto.rc4()->set_encrypt_key(xCrypto.hex_to_string("ef012345"))
+test_eq([[Crypto.arcfour()->set_encrypt_key(xCrypto.hex_to_string("ef012345"))
 		->crypt(xCrypto.hex_to_string("00000000000000000000"))]],
 	[[xCrypto.hex_to_string("d6a141a7ec3c38dfbd61")]])
 
@@ -136,7 +136,7 @@ test_eq([[Crypto.rc4()->set_encrypt_key(xCrypto.hex_to_string("ef012345"))
 cond( [[ master()->resolv("Gmp")->mpz ]],
 [[
 
-test_eq([[Crypto.rc4()->set_encrypt_key(xCrypto.hex_to_string("0123456789abcdef"))
+test_eq([[Crypto.arcfour()->set_encrypt_key(xCrypto.hex_to_string("0123456789abcdef"))
 		->crypt(xCrypto.hex_to_string(
 		  "0101010101010101010101010101010101010101010101010101010101010101"
 		  "0101010101010101010101010101010101010101010101010101010101010101"
-- 
GitLab