summaryrefslogtreecommitdiff
path: root/cipher/sha1.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2008-09-09 18:06:38 +0000
committerWerner Koch <wk@gnupg.org>2008-09-09 18:06:38 +0000
commitce7846ac4d2f69d910d86b5b2370a11ffa3ffb9e (patch)
tree90ebd61387e72b00d2ec20529936802e0a9d543d /cipher/sha1.c
parent15d48e486e6b289562b81d731292d79580beb3ed (diff)
downloadlibgcrypt-ce7846ac4d2f69d910d86b5b2370a11ffa3ffb9e.tar.gz
Add more selftests.
Diffstat (limited to 'cipher/sha1.c')
-rw-r--r--cipher/sha1.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/cipher/sha1.c b/cipher/sha1.c
index caf1c9a0..be3bd940 100644
--- a/cipher/sha1.c
+++ b/cipher/sha1.c
@@ -40,6 +40,7 @@
#include "memory.h"
#include "bithelp.h"
#include "cipher.h"
+#include "hash-common.h"
/* A macro to test whether P is properly aligned for an u32 type.
@@ -385,12 +386,32 @@ selftests_sha1 (selftest_report_func_t report)
const char *what;
const char *errtxt;
- what = "low-level";
- errtxt = NULL; /*selftest ();*/
+ what = "short string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA1, 0,
+ "abc", 3,
+ "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E"
+ "\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D", 20);
if (errtxt)
goto failed;
- /* FIXME: need more tests. */
+ what = "long string";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA1, 0,
+ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56,
+ "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE"
+ "\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1", 20);
+ if (errtxt)
+ goto failed;
+
+ what = "one million \"a\"";
+ errtxt = _gcry_hash_selftest_check_one
+ (GCRY_MD_SHA1, 1,
+ NULL, 0,
+ "\x34\xAA\x97\x3C\xD4\xC4\xDA\xA4\xF6\x1E"
+ "\xEB\x2B\xDB\xAD\x27\x31\x65\x34\x01\x6F", 20);
+ if (errtxt)
+ goto failed;
return 0; /* Succeeded. */