MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ConvertHashToMAC

Function ConvertHashToMAC

Libraries/unrar/crypt5.cpp:192–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190
191
192void ConvertHashToMAC(HashValue *Value,byte *Key)
193{
194 if (Value->Type==HASH_CRC32)
195 {
196 byte RawCRC[4];
197 RawPut4(Value->CRC32,RawCRC);
198 byte Digest[SHA256_DIGEST_SIZE];
199 hmac_sha256(Key,SHA256_DIGEST_SIZE,RawCRC,sizeof(RawCRC),Digest,NULL,NULL,NULL,NULL);
200 Value->CRC32=0;
201 for (uint I=0;I<ASIZE(Digest);I++)
202 Value->CRC32^=Digest[I] << ((I & 3) * 8);
203 }
204 if (Value->Type==HASH_BLAKE2)
205 {
206 byte Digest[BLAKE2_DIGEST_SIZE];
207 hmac_sha256(Key,BLAKE2_DIGEST_SIZE,Value->Digest,sizeof(Value->Digest),Digest,NULL,NULL,NULL,NULL);
208 memcpy(Value->Digest,Digest,sizeof(Value->Digest));
209 }
210}
211
212
213#if 0

Callers 1

CmpMethod · 0.85

Calls 2

RawPut4Function · 0.85
hmac_sha256Function · 0.85

Tested by

no test coverage detected