Commit 0dc88245 authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: src/testsuite/md5-test.c:1.1
Rev: src/testsuite/sha1-test.c:1.1
Rev: src/testsuite/string-test.c:1.1
Rev: src/testsuite/testutils.c:1.3
Rev: src/testsuite/testutils.h:1.3
parent b46a759e
#include "testutils.h"
int
test_main(void)
{
struct mac_algorithm *hmac
= make_hmac_algorithm(&crypto_md5_algorithm);
/* Test vectors from RFC 1321 */
test_hash("MD5-1", &crypto_md5_algorithm,
S(""),
H("D41D8CD98F00B204 E9800998ECF8427E"));
test_hash("MD5-2", &crypto_md5_algorithm,
S("a"),
H("0CC175B9C0F1B6A8 31C399E269772661"));
test_hash("MD5-3", &crypto_md5_algorithm,
S("abc"),
H("900150983cd24fb0 D6963F7D28E17F72"));
test_hash("MD5-4", &crypto_md5_algorithm,
S("message digest"),
H("F96B697D7CB7938D 525A2F31AAF161D0"));
test_hash("MD5-5", &crypto_md5_algorithm,
S("abcdefghijklmnopqrstuvwxyz"),
H("C3FCD3D76192E400 7DFB496CCA67E13B"));
test_hash("MD5-6", &crypto_md5_algorithm,
S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
H("D174AB98D277D9F5 A5611C2C9F419D9F"));
test_hash("MD5-7", &crypto_md5_algorithm,
S("1234567890123456789012345678901234567890"
"1234567890123456789012345678901234567890"),
H("57EDF4A22BE3C955 AC49DA2E2107B67A"));
/* Test vectors for md5 from RFC-2202 */
test_mac("HMAC-MD5-1", hmac,
H("0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b"),
S("Hi There"),
H("9294727A3638BB1C 13F48EF8158BFC9D"));
test_mac("HMAC-MD5-2", hmac,
S("Jefe"),
S("what do ya want for nothing?"),
H("750C783E6AB0B503 EAA86E310A5DB738"));
test_mac("HMAC-MD5-3", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"),
H("DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDD"),
H("56BE34521D144C88 DBB8C733F0E8B3F6"));
test_mac("HMAC-MD5-4", hmac,
H("0102030405060708 090A0B0C0D0E0F10 1112131415161718 19"),
H("CDCDCDCDCDCDCDCD CDCDCDCDCDCDCDCD"
"CDCDCDCDCDCDCDCD CDCDCDCDCDCDCDCD"
"CDCDCDCDCDCDCDCD CDCDCDCDCDCDCDCD"
"CDCD"),
H("697EAF0ACA3A3AEA 3A75164746FFAA79"));
test_mac("HMAC-MD5-5", hmac,
H("0C0C0C0C0C0C0C0C 0C0C0C0C0C0C0C0C"),
S("Test With Truncation"),
H("56461EF2342EDC00 F9BAB995690EFD4C"));
test_mac("HMAC-MD5-6", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"),
S("Test Using Larger Than Block-Size Key - Hash Key First"),
H("6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"));
test_mac("HMAC-MD5-7", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"),
S("Test Using Larger Than Block-Size Key an"
"d Larger Than One Block-Size Data"),
H("6f630fad67cda0ee1fb1f562db3aa53e"));
SUCCESS();
}
#include "testutils.h"
int
test_main(void)
{
struct mac_algorithm *hmac
= make_hmac_algorithm(&crypto_sha1_algorithm);
test_hash("SHA1", &crypto_sha1_algorithm,
S("abc"),
H("A9993E364706816A BA3E25717850C26C 9CD0D89D"));
/* Test vectors for sha1 from RFC-2202, and some more */
test_mac("HMAC-SHA1-0", hmac,
H("0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b"),
S("Hi There"),
H("675B0B3A1B4DDF4E 124872DA6C2F632B FED957E9"));
test_mac("HMAC-SHA1-1", hmac,
H("0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b 0b0b0b0b"),
S("Hi There"),
H("B617318655057264 E28BC0B6FB378C8E F146BE00"));
test_mac("HMAC-SHA1-2", hmac,
S("Jefe"),
S("what do ya want for nothing?"),
H("EFFCDF6AE5EB2FA2 D27416D5F184DF9C 259A7C79"));
test_mac("HMAC-SHA1-3a", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"),
H("DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDD"),
H("D730594D167E35D5 956FD8003D0DB3D3 F46DC7BB"));
test_mac("HMAC-SHA1-3", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA AAAAAAAA"),
H("DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD"
"DDDD"),
H("125D7342B9AC11CD 91A39AF48AA17B4F 63F175D3"));
test_mac("HMAC-SHA1-4", hmac,
H("0102030405060708 090A0B0C0D0E0F10 1112131415161718 19"),
H("CDCDCDCDCDCDCDCD CDCDCDCDCDCDCDCD"
"CDCDCDCDCDCDCDCD CDCDCDCDCDCDCDCD"
"CDCDCDCDCDCDCDCD CDCDCDCDCDCDCDCD"
"CDCD"),
H("4C9007F4026250C6 BC8414F9BF50C86C 2D7235DA"));
test_mac("HMAC-SHA1-5", hmac,
H("0C0C0C0C0C0C0C0C 0C0C0C0C0C0C0C0C 0C0C0C0C"),
S("Test With Truncation"),
H("4C1A03424B55E07F E7F27BE1D58BB932 4A9A5A04"));
test_mac("HMAC-SHA1-6", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"),
S("Test Using Larger Than Block-Size Key - Hash Key First"),
H("AA4AE5E15272D00E 95705637CE8A3B55 ED402112"));
test_mac("HMAC-SHA1-7", hmac,
H("AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA"),
S("Test Using Larger Than Block-Size Key an"
"d Larger Than One Block-Size Data"),
H("E8E99D0F45237D78 6D6BBAA7965C7808 BBFF1A91"));
SUCCESS();
}
#include "testutils.h"
int
test_main(void)
{
struct lsh_string *s;
const char *p;
s = S("foo");
p = lsh_get_cstring(s);
ASSERT(p && !strcmp(p, "foo")) ;
s = H("66006f");
ASSERT(!lsh_get_cstring(s));
s = H("6600");
ASSERT(!lsh_get_cstring(s));
s = H("");
p = lsh_get_cstring(s);
ASSERT(p && !*p);
SUCCESS();
}
......@@ -52,7 +52,7 @@ decode_hex_length(const char *h)
return count / 2;
}
const struct lsh_string *
struct lsh_string *
decode_hex(const char *h)
{
const unsigned char *hex = (const unsigned char *) h;
......
......@@ -9,8 +9,9 @@
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
const struct lsh_string *
struct lsh_string *
decode_hex(const char *);
/* The main program */
......@@ -50,4 +51,6 @@ test_sign(const char *name,
#define SKIP() exit(77)
#define SUCCESS() return EXIT_SUCCESS
#define ASSERT(x) do { if (!(x)) FAIL(); } while(0)
#endif /* LSH_TESTUTILS_H_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment