aboutsummaryrefslogtreecommitdiffstats
path: root/cipher
diff options
context:
space:
mode:
Diffstat (limited to 'cipher')
-rw-r--r--cipher/ChangeLog5
-rw-r--r--cipher/Makefile.am1
-rw-r--r--cipher/blowfish.h10
-rw-r--r--cipher/cipher.c35
-rw-r--r--cipher/rijndael.c14
5 files changed, 56 insertions, 9 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 0c94910f4..c3fd15414 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,8 @@
+2000-10-12 Werner Koch <[email protected]>
+
+ * rijndael.c: New.
+ * cipher.c: Add Rijndael support.
+
Wed Oct 4 15:50:18 CEST 2000 Werner Koch <[email protected]>
* sha1.c (transform): Use rol() macro. Actually this is not needed
diff --git a/cipher/Makefile.am b/cipher/Makefile.am
index 81bc77c30..2fefe0904 100644
--- a/cipher/Makefile.am
+++ b/cipher/Makefile.am
@@ -41,6 +41,7 @@ libcipher_a_SOURCES = cipher.c \
blowfish.h \
cast5.c \
cast5.h \
+ rijndael.c \
elgamal.c \
elgamal.h \
rsa.c rsa.h \
diff --git a/cipher/blowfish.h b/cipher/blowfish.h
index 7c34bab3c..bed034c73 100644
--- a/cipher/blowfish.h
+++ b/cipher/blowfish.h
@@ -41,4 +41,14 @@ twofish_get_info( int algo, size_t *keylen,
void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
);
+/* this is just a kludge for the time we have not yet chnaged the cipher
+ * stuff to the scheme we use for random and digests */
+const char *
+rijndael_get_info( int algo, size_t *keylen,
+ size_t *blocksize, size_t *contextsize,
+ int (**setkeyf)( void *c, byte *key, unsigned keylen ),
+ void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
+ void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
+ );
+
#endif /*G10_BLOWFISH_H*/
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 990671fc5..870e854cc 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -34,7 +34,7 @@
#define MAX_BLOCKSIZE 16
-#define TABLE_SIZE 10
+#define TABLE_SIZE 14
struct cipher_table_s {
const char *name;
@@ -84,6 +84,39 @@ setup_cipher_table(void)
int i;
i = 0;
+ cipher_table[i].algo = CIPHER_ALGO_RIJNDAEL;
+ cipher_table[i].name = rijndael_get_info( cipher_table[i].algo,
+ &cipher_table[i].keylen,
+ &cipher_table[i].blocksize,
+ &cipher_table[i].contextsize,
+ &cipher_table[i].setkey,
+ &cipher_table[i].encrypt,
+ &cipher_table[i].decrypt );
+ if( !cipher_table[i].name )
+ BUG();
+ i++;
+ cipher_table[i].algo = CIPHER_ALGO_RIJNDAEL192;
+ cipher_table[i].name = rijndael_get_info( cipher_table[i].algo,
+ &cipher_table[i].keylen,
+ &cipher_table[i].blocksize,
+ &cipher_table[i].contextsize,
+ &cipher_table[i].setkey,
+ &cipher_table[i].encrypt,
+ &cipher_table[i].decrypt );
+ if( !cipher_table[i].name )
+ BUG();
+ i++;
+ cipher_table[i].algo = CIPHER_ALGO_RIJNDAEL256;
+ cipher_table[i].name = rijndael_get_info( cipher_table[i].algo,
+ &cipher_table[i].keylen,
+ &cipher_table[i].blocksize,
+ &cipher_table[i].contextsize,
+ &cipher_table[i].setkey,
+ &cipher_table[i].encrypt,
+ &cipher_table[i].decrypt );
+ if( !cipher_table[i].name )
+ BUG();
+ i++;
cipher_table[i].algo = CIPHER_ALGO_TWOFISH;
cipher_table[i].name = twofish_get_info( cipher_table[i].algo,
&cipher_table[i].keylen,
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 238866bfc..0284989c3 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -39,7 +39,8 @@
#include <string.h> /* for memcmp() */
#include "types.h" /* for byte and u32 typedefs */
-#include "g10lib.h"
+#include "util.h"
+#include "errors.h"
#include "dynload.h"
#define MAXKC (256/32)
@@ -1726,7 +1727,7 @@ rijndael_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
fprintf(stderr, "%s\n", selftest_failed );
}
if( selftest_failed )
- return GCRYERR_SELFTEST;
+ return G10ERR_SELFTEST_FAILED;
if( keylen == 128/8 ) {
ROUNDS = 10;
@@ -1741,7 +1742,7 @@ rijndael_setkey (RIJNDAEL_context *ctx, const byte *key, const unsigned keylen)
KC = 8;
}
else
- return GCRYERR_INV_KEYLEN;
+ return G10ERR_WRONG_KEYLEN;
ctx->ROUNDS = ROUNDS;
ctx->decryption_prepared = 0;
@@ -2121,9 +2122,8 @@ rijndael_get_info (int algo, size_t *keylen,
}
-#ifndef IS_MODULE
+#ifdef IS_MODULE
static
-#endif
const char * const gnupgext_version = "RIJNDAEL ($Revision$)";
static struct {
@@ -2155,9 +2155,7 @@ static struct {
* version = interface version of the function/pointer
* (currently this is 1 for all functions)
*/
-#ifndef IS_MODULE
static
-#endif
void *
gnupgext_enum_func ( int what, int *sequence, int *class, int *vers )
{
@@ -2186,7 +2184,7 @@ gnupgext_enum_func ( int what, int *sequence, int *class, int *vers )
*sequence = i;
return ret;
}
-
+#endif