0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 10:11:53 +00:00

SHA1: Remove original libucw unit tests

This commit is contained in:
Pavel Tvrdík 2015-04-23 12:52:36 +02:00
parent 24ff638db2
commit 5015dceee0
2 changed files with 0 additions and 63 deletions

View File

@ -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 <stdio.h>
#include <unistd.h>
#include <ucw/string.h>
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

View File

@ -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 <stdio.h>
#include <ucw/string.h>
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