From 5015dceee0717974f686ee194e72c0ff0f35b0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Tvrd=C3=ADk?= Date: Thu, 23 Apr 2015 12:52:36 +0200 Subject: [PATCH] SHA1: Remove original libucw unit tests --- lib/sha1.c | 25 ------------------------- lib/sha1_hmac.c | 38 -------------------------------------- 2 files changed, 63 deletions(-) diff --git a/lib/sha1.c b/lib/sha1.c index 2e221119..19c8d8ff 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -285,28 +285,3 @@ sha1_hash_buffer(byte *outbuf, const byte *buffer, uint length) sha1_update(&hd, buffer, length); memcpy(outbuf, sha1_final(&hd), SHA1_SIZE); } - -#ifdef TEST - -#include -#include -#include - -int main(void) -{ - sha1_context hd; - byte buf[3]; - int cnt; - - sha1_init(&hd); - while ((cnt = read(0, buf, sizeof(buf))) > 0) - sha1_update(&hd, buf, cnt); - - char text[SHA1_HEX_SIZE]; - mem_to_hex(text, sha1_final(&hd), SHA1_SIZE, 0); - puts(text); - - return 0; -} - -#endif diff --git a/lib/sha1_hmac.c b/lib/sha1_hmac.c index 58f0ca20..f183bcc2 100644 --- a/lib/sha1_hmac.c +++ b/lib/sha1_hmac.c @@ -74,41 +74,3 @@ sha1_hmac(byte *outbuf, const byte *key, uint keylen, const byte *data, uint dat byte *osha = sha1_hmac_final(&hd); memcpy(outbuf, osha, SHA1_SIZE); } - -#ifdef TEST - -#include -#include - -static uint rd(char *dest) -{ - char buf[1024]; - if (!fgets(buf, sizeof(buf), stdin)) - die("fgets()"); - *strchr(buf, '\n') = 0; - if (buf[0] == '0' && buf[1] == 'x') - { - const char *e = hex_to_mem(dest, buf+2, 1024, 0); - ASSERT(!*e); - return (e-buf-2)/2; - } - else - { - strcpy(dest, buf); - return strlen(dest); - } -} - -int main(void) -{ - char key[1024], data[1024]; - byte hmac[SHA1_SIZE]; - uint kl = rd(key); - uint dl = rd(data); - sha1_hmac(hmac, key, kl, data, dl); - mem_to_hex(data, hmac, SHA1_SIZE, 0); - puts(data); - return 0; -} - -#endif