X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=hmac.c;h=bd97ba43fd2c7321d6d5229e80c98c4c0a27b01e;hb=e2ca60e84ef1525d1b097548534e6ab1c96885b2;hp=372921d7a096a8786e3e652b9c988f574ace53c2;hpb=c7eea28ff1214ea7c198be1bda5638e1df314ab1;p=xonotic%2Fdarkplaces.git diff --git a/hmac.c b/hmac.c index 372921d7..bd97ba43 100644 --- a/hmac.c +++ b/hmac.c @@ -1,29 +1,29 @@ #include "quakedef.h" #include "hmac.h" -void hmac( +qboolean hmac( hashfunc_t hfunc, int hlen, int hblock, unsigned char *out, unsigned char *in, int n, unsigned char *key, int k ) { - unsigned char hashbuf[32]; - unsigned char k_xor_ipad[128]; - unsigned char k_xor_opad[128]; - unsigned char catbuf[256]; + static unsigned char hashbuf[32]; + static unsigned char k_xor_ipad[128]; + static unsigned char k_xor_opad[128]; + static unsigned char catbuf[4096]; int i; if(sizeof(hashbuf) < (size_t) hlen) - Host_Error("Invalid hash function used for HMAC - too long hash length"); + return false; if(sizeof(k_xor_ipad) < (size_t) hblock) - Host_Error("Invalid hash function used for HMAC - too long hash block length"); + return false; if(sizeof(k_xor_ipad) < (size_t) hlen) - Host_Error("Invalid hash function used for HMAC - too long hash length"); + return false; if(sizeof(catbuf) < (size_t) hblock + (size_t) hlen) - Host_Error("Invalid hash function used for HMAC - too long hash block length"); + return false; if(sizeof(catbuf) < (size_t) hblock + (size_t) n) - Host_Error("Invalid hash function used for HMAC - too long message length"); + return false; if(k > hblock) { @@ -56,4 +56,5 @@ void hmac( memcpy(catbuf, k_xor_opad, hblock); memcpy(catbuf + hblock, hashbuf, hlen); hfunc(out, catbuf, hblock + hlen); + return true; }