chiark / gitweb /
Abolish serpent-l. Use PKCS#1 v1.5 RSA padding but without hash OID for secnet.
[chiark-tcl.git] / crypto / algtables.c
index 7a651f06aa66e0a9d90529dea2ea7dd564fbd413..8fa24e4d626742c22fe92be35b9949f35ad5ba2d 100644 (file)
@@ -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);