Mercurial > dropbear
diff libtomcrypt/src/mac/hmac/hmac_init.c @ 1056:a2bfd4374878 nocircbuffer
Avoid malloc in hmac
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 01 Mar 2015 14:46:04 +0800 |
parents | 0cbe8f6dbf9e |
children | f849a5ca2efc |
line wrap: on
line diff
--- a/libtomcrypt/src/mac/hmac/hmac_init.c Sun Mar 01 00:57:21 2015 +0800 +++ b/libtomcrypt/src/mac/hmac/hmac_init.c Sun Mar 01 14:46:04 2015 +0800 @@ -29,7 +29,7 @@ */ int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned long keylen) { - unsigned char *buf; + unsigned char buf[MAXBLOCKSIZE]; unsigned long hashsize; unsigned long i, z; int err; @@ -49,16 +49,9 @@ return CRYPT_INVALID_KEYSIZE; } - /* allocate ram for buf */ - buf = XMALLOC(HMAC_BLOCKSIZE); - if (buf == NULL) { - return CRYPT_MEM; - } - /* allocate memory for key */ hmac->key = XMALLOC(HMAC_BLOCKSIZE); if (hmac->key == NULL) { - XFREE(buf); return CRYPT_MEM; } @@ -101,7 +94,6 @@ zeromem(buf, HMAC_BLOCKSIZE); #endif - XFREE(buf); return err; }