From 07876950ceee6d28473f347ad2f0c4422c266e32 Mon Sep 17 00:00:00 2001 From: ian Date: Tue, 17 Sep 2002 17:25:29 +0000 Subject: [PATCH] Abolish serpent-l. Use PKCS#1 v1.5 RSA padding but without hash OID for secnet. --- base/chiark-tcl.h | 10 +++++----- crypto/algtables.c | 50 +++++++++------------------------------------- hbytes/hbytes.h | 10 +++++----- 3 files changed, 19 insertions(+), 51 deletions(-) diff --git a/base/chiark-tcl.h b/base/chiark-tcl.h index f482cc5..ce00dd9 100644 --- a/base/chiark-tcl.h +++ b/base/chiark-tcl.h @@ -220,15 +220,15 @@ typedef struct { const char *name; int hashsize, blocksize, statesize; void (*init)(void *state); - void (*update)(void *state, const Byte *data, int len); - void (*final)(void *state, Byte *digest); - void (*oneshot)(Byte *digest, const Byte *data, int len); + void (*update)(void *state, const void *data, int len); + void (*final)(void *state, void *digest); + void (*oneshot)(void *digest, const void *data, int len); } HashAlgInfo; extern const HashAlgInfo hashalginfos[]; typedef struct { - void (*make_schedule)(void *schedule, const Byte *key, int keylen); + void (*make_schedule)(void *schedule, const void *key, int keylen); void (*crypt)(const void *schedule, const void *in, void *out); /* in and out may be the same, but if they aren't they may not overlap */ /* in and out for crypt will have been through block_byteswap */ @@ -237,7 +237,7 @@ typedef struct { typedef struct { const char *name; int blocksize, schedule_size, key_min, key_max; - void (*byteswap)(Byte *block); + void (*byteswap)(void *block); BlockCipherDirectionInfo encrypt, decrypt; } BlockCipherAlgInfo; diff --git a/crypto/algtables.c b/crypto/algtables.c index 7a651f0..8fa24e4 100644 --- a/crypto/algtables.c +++ b/crypto/algtables.c @@ -9,35 +9,7 @@ #include "sha1.h" #include "md5.h" -static void alg_serpent_b_byteswap_block(Byte *b) { - uint32_t t, *a= (void*)b; - - t= htonl(a[0]); - a[0]= htonl(a[3]); - a[3]= t; - - t= htonl(a[1]); - a[1]= htonl(a[2]); - a[2]= t; -} - -static void alg_serpent_l_byteswap_block(Byte *b) { - uint32_t t, *a= (void*)b; - int i; - - if (htonl(0x01020304UL) == 0x04030201UL) /* little endian */ - return; - - for (i=0; i<4; i++) { - t= htonl(a[i]); - a[i]= ((t & 0x000000ffUL) << 24 | - (t & 0x0000ff00UL) << 8 | - (t & 0x00ff0000UL) >> 8 | - (t & 0xff000000UL) >> 24); - } -} - -static void alg_serpent_makekey(void *schedule, const Byte *key, int keylen) { +static void alg_serpent_makekey(void *schedule, const void *key, int keylen) { serpent_makekey(schedule, key, keylen); } @@ -50,36 +22,32 @@ static void alg_serpent_decrypt(const void *sch, const void *in, void *out) { } const BlockCipherAlgInfo blockcipheralginfos[]= { - { "serpent-l", 16, sizeof(SerpentKeySchedule), 16,32, - alg_serpent_l_byteswap_block, - { alg_serpent_makekey, alg_serpent_encrypt }, - { alg_serpent_makekey, alg_serpent_decrypt } }, - { "serpent-b", 16, sizeof(SerpentKeySchedule), 16,32, - alg_serpent_b_byteswap_block, + { "serpent", 16, sizeof(SerpentKeySchedule), 16,32, + serpent_byteswap_block, { alg_serpent_makekey, alg_serpent_encrypt }, { alg_serpent_makekey, alg_serpent_decrypt } }, { 0 } }; static void alg_sha1_init(void *state) { sha1_init(state); } -static void alg_sha1_update(void *state, const Byte *data, int len) { +static void alg_sha1_update(void *state, const void *data, int len) { sha1_update(state, data, len); } -static void alg_sha1_final(void *state, Byte *digest) { +static void alg_sha1_final(void *state, void *digest) { sha1_final(state, digest); } -static void alg_sha1_oneshot(Byte *digest, const Byte *data, int len) { +static void alg_sha1_oneshot(void *digest, const void *data, int len) { sha1(data,len,digest); } static void alg_md5_init(void *state) { MD5Init(state); } -static void alg_md5_update(void *state, const Byte *data, int len) { +static void alg_md5_update(void *state, const void *data, int len) { MD5Update(state, data, len); } -static void alg_md5_final(void *state, Byte *digest) { +static void alg_md5_final(void *state, void *digest) { MD5Final(digest, state); } -static void alg_md5_oneshot(Byte *digest, const Byte *data, int len) { +static void alg_md5_oneshot(void *digest, const void *data, int len) { struct MD5Context ctx; MD5Init(&ctx); MD5Update(&ctx,data,len); diff --git a/hbytes/hbytes.h b/hbytes/hbytes.h index f482cc5..ce00dd9 100644 --- a/hbytes/hbytes.h +++ b/hbytes/hbytes.h @@ -220,15 +220,15 @@ typedef struct { const char *name; int hashsize, blocksize, statesize; void (*init)(void *state); - void (*update)(void *state, const Byte *data, int len); - void (*final)(void *state, Byte *digest); - void (*oneshot)(Byte *digest, const Byte *data, int len); + void (*update)(void *state, const void *data, int len); + void (*final)(void *state, void *digest); + void (*oneshot)(void *digest, const void *data, int len); } HashAlgInfo; extern const HashAlgInfo hashalginfos[]; typedef struct { - void (*make_schedule)(void *schedule, const Byte *key, int keylen); + void (*make_schedule)(void *schedule, const void *key, int keylen); void (*crypt)(const void *schedule, const void *in, void *out); /* in and out may be the same, but if they aren't they may not overlap */ /* in and out for crypt will have been through block_byteswap */ @@ -237,7 +237,7 @@ typedef struct { typedef struct { const char *name; int blocksize, schedule_size, key_min, key_max; - void (*byteswap)(Byte *block); + void (*byteswap)(void *block); BlockCipherDirectionInfo encrypt, decrypt; } BlockCipherAlgInfo; -- 2.30.2