#include "sha1.h"
#include "md5.h"
-static void alg_serpent_byteswap_block(Byte *b) {
+static void alg_serpent_b_byteswap_block(Byte *b) {
uint32_t t, *a= (void*)b;
t= htonl(a[0]);
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) {
serpent_makekey(schedule, keylen*8, key);
}
}
const BlockCipherAlgInfo blockcipheralginfos[]= {
- { "serpent", 16, sizeof(struct SerpentKeyInstance), 16,32,
- alg_serpent_byteswap_block,
+ { "serpent-l", 16, sizeof(struct SerpentKeyInstance), 16,32,
+ alg_serpent_l_byteswap_block,
+ { alg_serpent_makekey, alg_serpent_encrypt },
+ { alg_serpent_makekey, alg_serpent_decrypt } },
+ { "serpent-b", 16, sizeof(struct SerpentKeyInstance), 16,32,
+ alg_serpent_b_byteswap_block,
{ alg_serpent_makekey, alg_serpent_encrypt },
{ alg_serpent_makekey, alg_serpent_decrypt } },
{ 0 }