5 #include <netinet/in.h>
12 static void alg_serpent_byteswap_block(Byte *b) {
13 uint32_t t, *a= (void*)b;
24 static void alg_serpent_makekey(void *schedule, const Byte *key, int keylen) {
25 serpent_makekey(schedule, keylen*8, key);
28 static void alg_serpent_encrypt(const void *sch, const void *in, void *out) {
29 serpent_encrypt(sch, in, out);
32 static void alg_serpent_decrypt(const void *sch, const void *in, void *out) {
33 serpent_decrypt(sch, in, out);
36 const BlockCipherAlgInfo blockcipheralginfos[]= {
37 { "serpent", 16, sizeof(struct SerpentKeyInstance), 16,32,
38 alg_serpent_byteswap_block,
39 { alg_serpent_makekey, alg_serpent_encrypt },
40 { alg_serpent_makekey, alg_serpent_decrypt } },
44 static void alg_sha1_init(void *state) { sha1_init(state); }
45 static void alg_sha1_update(void *state, const Byte *data, int len) {
46 sha1_update(state, data, len);
48 static void alg_sha1_final(void *state, Byte *digest) {
49 sha1_final(state, digest);
51 static void alg_sha1_oneshot(Byte *digest, const Byte *data, int len) {
52 sha1(data,len,digest);
55 static void alg_md5_init(void *state) { MD5Init(state); }
56 static void alg_md5_update(void *state, const Byte *data, int len) {
57 MD5Update(state, data, len);
59 static void alg_md5_final(void *state, Byte *digest) {
60 MD5Final(digest, state);
62 static void alg_md5_oneshot(Byte *digest, const Byte *data, int len) {
63 struct MD5Context ctx;
65 MD5Update(&ctx,data,len);
66 MD5Final(digest,&ctx);
69 const HashAlgInfo hashalginfos[]= {
70 { "sha1", 20, 64, sizeof(struct sha1_state),
71 alg_sha1_init, alg_sha1_update, alg_sha1_final, alg_sha1_oneshot },
72 { "md5", 16, 64, sizeof(struct MD5Context),
73 alg_md5_init, alg_md5_update, alg_md5_final, alg_md5_oneshot },