From 13e6e4ab1290cda9426eaedfeda70f7491b6b083 Mon Sep 17 00:00:00 2001 From: Perberos Date: Sun, 6 Nov 2011 17:13:49 -0300 Subject: initial --- src/skey/skey.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/skey/skey.c (limited to 'src/skey/skey.c') diff --git a/src/skey/skey.c b/src/skey/skey.c new file mode 100644 index 0000000..2517842 --- /dev/null +++ b/src/skey/skey.c @@ -0,0 +1,37 @@ +#include + +#include +#include +#include +#include + +#include "md4.h" +#include "md5.h" +#include "sha1.h" +#include "skey.h" +#include "btoe.h" + +struct skey_hash { + int (*Keycrunch) (char *, const char *, const char *); + void (*Skey) (char *); +}; +static struct skey_hash hash_table[] = { + { MD4Keycrunch, MD4SKey }, + { MD5Keycrunch, MD5SKey }, + { SHA1Keycrunch, SHA1SKey } +}; + + +char *skey(SKeyAlgorithm algorithm, int seq, const char *seed, const char *passphrase) +{ + char key[SKEY_SIZE]; + int i; + g_assert (algorithm < G_N_ELEMENTS (hash_table)); + if (hash_table[algorithm].Keycrunch(key, seed, passphrase) == -1) + return NULL; + + for (i = 0; i < seq; i++) + hash_table[algorithm].Skey(key); + + return strdup(btoe((unsigned char *)key)); +} -- cgit v1.2.1