summaryrefslogtreecommitdiffstats
path: root/test/tst-sha.c
diff options
context:
space:
mode:
authorunknown <unknown@unknown>2009-10-23 04:29:39 +0000
committerunknown <unknown@unknown>2009-10-23 04:29:39 +0000
commitddf5c42f67757000d6ec7686b92a667c2a252dca (patch)
treee070b352fab4b285b7a4ea547d0cbfff9b7fb4d1 /test/tst-sha.c
downloadiksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.tar.gz
iksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.tar.xz
iksemel-ddf5c42f67757000d6ec7686b92a667c2a252dca.zip
Imported from iksemel-1.3.tar.gz.
Diffstat (limited to 'test/tst-sha.c')
-rw-r--r--test/tst-sha.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/tst-sha.c b/test/tst-sha.c
new file mode 100644
index 0000000..ff6b3e3
--- /dev/null
+++ b/test/tst-sha.c
@@ -0,0 +1,38 @@
+/* iksemel (XML parser for Jabber)
+** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>
+** This code is free software; you can redistribute it and/or
+** modify it under the terms of GNU Lesser General Public License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "iksemel.h"
+
+int main (int argc, char *argv[])
+{
+ struct lala {
+ char *str;
+ char *hash;
+ } known_hashes[] = {
+ { "abc", "a9993e364706816aba3e25717850c26c9cd0d89d" },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ "84983e441c3bd26ebaae4aa1f95129e5e54670f1" },
+ { NULL, NULL }
+ };
+ int i = 0;
+ char buf[42];
+
+ while (known_hashes[i].str) {
+ iks_sha (known_hashes[i].str, buf);
+ if (strcmp (buf, known_hashes[i].hash) != 0) {
+ printf("SHA1 hash of \"%s\"\n", known_hashes[i].str);
+ printf(" Result: %s\n", buf);
+ printf(" Expected: %s\n", known_hashes[i].hash);
+ return 1;
+ }
+ i++;
+ }
+ return 0;
+}