From 2c4b904165c76e4a935eb49b1fc889a9254af8cf Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Sat, 2 Nov 2013 10:55:25 +0100 Subject: [PATCH] bugfix in encryption key computing, added new feature: derived public keys --- tests/jot | 3 +++ tests/pwhashes.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 tests/jot create mode 100644 tests/pwhashes.c diff --git a/tests/jot b/tests/jot new file mode 100755 index 0000000..dbf78d9 --- /dev/null +++ b/tests/jot @@ -0,0 +1,3 @@ +#!/usr/bin/perl +my $rounds = shift; +foreach (0 .. $rounds) {print "$_\n";} \ No newline at end of file diff --git a/tests/pwhashes.c b/tests/pwhashes.c new file mode 100644 index 0000000..a8239af --- /dev/null +++ b/tests/pwhashes.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include +#include +#include + +#include "mem.h" +#include "defines.h" +#include "keyprint.h" +#include "key.h" + +struct _pw_t { + char hash[65]; + UT_hash_handle hh; +}; +typedef struct _pw_t pw; + +int main() { + int i, t, p; + char *pass = ucmalloc(4); + unsigned char *h; + char tmp[65]; + pw *item; + pw *list = NULL; + pw *have = NULL; + + for(i=97; i<126; ++i) { + pass[0] = i; + pass[1] = 0; + h = pcp_derivekey(pass); + + p =0; + for(t=0; t<32; ++t) { + sprintf(&tmp[p], "%02x", h[t]); + p += 2; + } + + have = NULL; + HASH_FIND_STR(list, tmp, have); + if(have == NULL) { + item = ucmalloc(sizeof(pw)); + memcpy(item->hash, tmp, 65); + HASH_ADD_STR( list, hash, item ); + } + else { + fprintf(stderr, "Error: collision found: %s!\n", have->hash); + return 1; + } + } + + fprintf(stderr, "ok\n"); + return 0; +}