comparison libtomcrypt/src/mac/hmac/hmac_init.c @ 1710:1ff2a1034c52

Fix whitespace changes vs upstream libtomcrypt
author Matt Johnston <matt@ucc.asn.au>
date Wed, 10 Jun 2020 23:01:33 +0800
parents 6dba84798cd5
children
comparison
equal deleted inserted replaced
1709:04155ce30759 1710:1ff2a1034c52
18 #define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize 18 #define LTC_HMAC_BLOCKSIZE hash_descriptor[hash].blocksize
19 19
20 /** 20 /**
21 Initialize an HMAC context. 21 Initialize an HMAC context.
22 @param hmac The HMAC state 22 @param hmac The HMAC state
23 @param hash The index of the hash you want to use 23 @param hash The index of the hash you want to use
24 @param key The secret key 24 @param key The secret key
25 @param keylen The length of the secret key (octets) 25 @param keylen The length of the secret key (octets)
26 @return CRYPT_OK if successful 26 @return CRYPT_OK if successful
27 */ 27 */
28 int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned long keylen) 28 int hmac_init(hmac_state *hmac, int hash, const unsigned char *key, unsigned long keylen)
62 keylen = hashsize; 62 keylen = hashsize;
63 } else { 63 } else {
64 XMEMCPY(hmac->key, key, (size_t)keylen); 64 XMEMCPY(hmac->key, key, (size_t)keylen);
65 } 65 }
66 66
67 if(keylen < LTC_HMAC_BLOCKSIZE) { 67 if(keylen < LTC_HMAC_BLOCKSIZE) {
68 zeromem((hmac->key) + keylen, (size_t)(LTC_HMAC_BLOCKSIZE - keylen)); 68 zeromem((hmac->key) + keylen, (size_t)(LTC_HMAC_BLOCKSIZE - keylen));
69 } 69 }
70 70
71 /* Create the initialization vector for step (3) */ 71 /* Create the initialization vector for step (3) */
72 for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) { 72 for(i=0; i < LTC_HMAC_BLOCKSIZE; i++) {
73 buf[i] = hmac->key[i] ^ 0x36; 73 buf[i] = hmac->key[i] ^ 0x36;
74 } 74 }
87 XFREE(hmac->key); 87 XFREE(hmac->key);
88 done: 88 done:
89 #ifdef LTC_CLEAN_STACK 89 #ifdef LTC_CLEAN_STACK
90 zeromem(buf, LTC_HMAC_BLOCKSIZE); 90 zeromem(buf, LTC_HMAC_BLOCKSIZE);
91 #endif 91 #endif
92 92
93 return err; 93 return err;
94 } 94 }
95 95
96 #endif 96 #endif
97 97
98 /* ref: $Format:%D$ */ 98 /* ref: $Format:%D$ */