From c3c6fc13b3d4640d7b85fb8dcfed3456783253e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Thu, 7 Nov 1996 20:30:18 +0100
Subject: [PATCH] Added IDEA. Added /precompiled/crypto.

Rev: src/modules/_Crypto/Makefile:1.2
Rev: src/modules/_Crypto/idea.c:1.2
Rev: src/modules/_Crypto/precompiled_crypto.h:1.2
---
 src/modules/_Crypto/Makefile             |  4 ++--
 src/modules/_Crypto/idea.c               | 22 +++++++++++++++++++++-
 src/modules/_Crypto/precompiled_crypto.h | 10 ++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/modules/_Crypto/Makefile b/src/modules/_Crypto/Makefile
index fb6315a8c2..d7ff8b3e21 100644
--- a/src/modules/_Crypto/Makefile
+++ b/src/modules/_Crypto/Makefile
@@ -2,10 +2,10 @@
 CC=gcc
 
 # You need the pike source somewhere
-PIKESRCDIR=../pike/src
+PIKESRCDIR=../../pike/src
 
 # And you need a dir where Pike was compiled (might be same as sourcedir)
-PIKEBUILDDIR=../pike/build/sol2.5
+PIKEBUILDDIR=../../pike/build/sol2.5
 
 # The SSLeay root is here
 SSLROOT=/usr/local/ssl/
diff --git a/src/modules/_Crypto/idea.c b/src/modules/_Crypto/idea.c
index 3c808d4d74..cc344dd19a 100644
--- a/src/modules/_Crypto/idea.c
+++ b/src/modules/_Crypto/idea.c
@@ -1,5 +1,5 @@
 /*
- * $Id: idea.c,v 1.1.1.1 1996/11/05 15:10:09 grubba Exp $
+ * $Id: idea.c,v 1.2 1996/11/07 19:30:17 grubba Exp $
  *
  * IDEA crypto module for Pike
  *
@@ -63,6 +63,24 @@ void exit_pike_idea(struct object *o)
  * efuns and the like
  */
 
+/* int query_block_size(void) */
+static void f_query_block_size(INT32 args)
+{
+  if (args) {
+    error("Too many arguments to idea->query_block_size()\n");
+  }
+  push_int(8);
+}
+
+/* int query_key_length(void) */
+static void f_query_key_length(INT32 args)
+{
+  if (args) {
+    error("Too many arguments to idea->query_key_length()\n");
+  }
+  push_int(16);
+}
+
 /* void set_key(string) */
 static void f_set_key(INT32 args)
 {
@@ -232,6 +250,8 @@ void init_idea_programs(void)
   start_new_program();
   add_storage(sizeof(struct pike_idea));
 
+  add_function("query_block_size", f_query_block_size, "function(void:int)", OPT_TRY_OPTIMIZE);
+  add_function("query_key_length", f_query_key_length, "function(void:int)", OPT_TRY_OPTIMIZE);
   add_function("set_key", f_set_key, "function(string:void)", OPT_SIDE_EFFECT);
   add_function("encrypt", f_encrypt, "function(string:string)", OPT_SIDE_EFFECT);
   add_function("decrypt", f_decrypt, "function(string:string)", OPT_SIDE_EFFECT);
diff --git a/src/modules/_Crypto/precompiled_crypto.h b/src/modules/_Crypto/precompiled_crypto.h
index efddaa738c..eb706c659a 100644
--- a/src/modules/_Crypto/precompiled_crypto.h
+++ b/src/modules/_Crypto/precompiled_crypto.h
@@ -29,6 +29,14 @@
  * Structures
  */
 
+struct pike_crypto {
+  struct object *object;
+  INT32 block_size;
+  INT32 overflow_len;
+  unsigned char *iv;
+  unsigned char *overflow;
+};
+
 struct pike_md2 {
   MD2_CTX ctx;
   unsigned char checksum[MD2_DIGEST_LENGTH];
@@ -59,6 +67,8 @@ struct pike_des {
  * Defines
  */
 
+#define PIKE_CRYPTO	((struct pike_crypto *)(fp->current_storage))
+
 #define PIKE_MD2	((struct pike_md2 *)(fp->current_storage))
 #define PIKE_MD5	((struct pike_md5 *)(fp->current_storage))
 
-- 
GitLab