X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fsha1-hmac.c;h=b52011b1b74dcf71cacf1ca8ec82f78c99ddcb46;hb=b8667492cf36a609939ee35ac42900ff0b0cc80f;hp=bc062ff5006637cd082d147b61c4ecc813e9758b;hpb=fa7aa6d9457616ce28f97c83eaa616d0ff276870;p=libucw.git diff --git a/ucw/sha1-hmac.c b/ucw/sha1-hmac.c index bc062ff5..b52011b1 100644 --- a/ucw/sha1-hmac.c +++ b/ucw/sha1-hmac.c @@ -13,7 +13,7 @@ #include void -sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uns keylen) +sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uint keylen) { byte keybuf[SHA1_BLOCK_SIZE], buf[SHA1_BLOCK_SIZE]; @@ -43,7 +43,7 @@ sha1_hmac_init(sha1_hmac_context *hd, const byte *key, uns keylen) } void -sha1_hmac_update(sha1_hmac_context *hd, const byte *data, uns datalen) +sha1_hmac_update(sha1_hmac_context *hd, const byte *data, uint datalen) { // Just update the inner digest sha1_update(&hd->ictx, data, datalen); @@ -60,7 +60,7 @@ byte *sha1_hmac_final(sha1_hmac_context *hd) } void -sha1_hmac(byte *outbuf, const byte *key, uns keylen, const byte *data, uns datalen) +sha1_hmac(byte *outbuf, const byte *key, uint keylen, const byte *data, uint datalen) { sha1_hmac_context hd; sha1_hmac_init(&hd, key, keylen); @@ -74,10 +74,11 @@ sha1_hmac(byte *outbuf, const byte *key, uns keylen, const byte *data, uns datal #include #include -static uns rd(char *dest) +static uint rd(char *dest) { char buf[1024]; - fgets(buf, sizeof(buf), stdin); + if (!fgets(buf, sizeof(buf), stdin)) + die("fgets()"); *strchr(buf, '\n') = 0; if (buf[0] == '0' && buf[1] == 'x') { @@ -96,8 +97,8 @@ int main(void) { char key[1024], data[1024]; byte hmac[SHA1_SIZE]; - uns kl = rd(key); - uns dl = rd(data); + 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);