Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- void hashlib_HMACSha256Init(hmac_ctx *hmac, const uint8_t* key, size_t keylen){
- size_t i;
- uint8_t sum[64] = {0};
- if(keylen > 64){
- hashlib_Sha256Init(&hmac->sha256_ctx);
- hashlib_Sha256Update(&hmac->sha256_ctx, key, keylen);
- hashlib_Sha256Final(&hmac->sha256_ctx, sum);
- keylen = 32;
- }
- else memcpy(sum, key, keylen);
- memset( hmac->ipad, 0x36, 64 );
- memset( hmac->opad, 0x5C, 64 );
- for( i = 0; i < 64; i++ ){
- hmac->ipad[i] ^= sum[i];
- hmac->opad[i] ^= sum[i];
- }
- hashlib_Sha256Init(&hmac->sha256_ctx);
- hashlib_Sha256Update(&hmac->sha256_ctx, hmac->ipad, 64);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement