Commit 5015dcee authored by Pavel Tvrdík's avatar Pavel Tvrdík
Browse files

SHA1: Remove original libucw unit tests

parent 24ff638d
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
@@ -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
+0 −38
Original line number Diff line number Diff line
@@ -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