summaryrefslogtreecommitdiff
path: root/src/skey/skey.c
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-06 17:13:49 -0300
committerPerberos <[email protected]>2011-11-06 17:13:49 -0300
commit13e6e4ab1290cda9426eaedfeda70f7491b6b083 (patch)
tree2b9b2e1eac4cc6a161bea6f2197de4513ff1ddf7 /src/skey/skey.c
downloadmate-terminal-13e6e4ab1290cda9426eaedfeda70f7491b6b083.tar.bz2
mate-terminal-13e6e4ab1290cda9426eaedfeda70f7491b6b083.tar.xz
initial
Diffstat (limited to 'src/skey/skey.c')
-rw-r--r--src/skey/skey.c37
1 files changed, 37 insertions, 0 deletions
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 <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#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));
+}