| 1 | #include "rar.hpp" |
| 2 | |
| 3 | void HashValue::Init(HASH_TYPE Type) |
| 4 | { |
| 5 | HashValue::Type=Type; |
| 6 | |
| 7 | // Zero length data CRC32 is 0. It is important to set it when creating |
| 8 | // headers with no following data like directories or symlinks. |
| 9 | if (Type==HASH_RAR14 || Type==HASH_CRC32) |
| 10 | CRC32=0; |
| 11 | if (Type==HASH_BLAKE2) |
| 12 | { |
| 13 | // dd0e891776933f43c7d032b08a917e25741f8aa9a12c12e1cac8801500f2ca4f |
| 14 | // is BLAKE2sp hash of empty data. We init the structure to this value, |
| 15 | // so if we create a file or service header with no following data like |
| 16 | // "file copy" or "symlink", we set the checksum to proper value avoiding |
| 17 | // additional header type or size checks when extracting. |
| 18 | static byte EmptyHash[32]={ |
| 19 | 0xdd, 0x0e, 0x89, 0x17, 0x76, 0x93, 0x3f, 0x43, |
| 20 | 0xc7, 0xd0, 0x32, 0xb0, 0x8a, 0x91, 0x7e, 0x25, |
| 21 | 0x74, 0x1f, 0x8a, 0xa9, 0xa1, 0x2c, 0x12, 0xe1, |
| 22 | 0xca, 0xc8, 0x80, 0x15, 0x00, 0xf2, 0xca, 0x4f |
| 23 | }; |
| 24 | memcpy(Digest,EmptyHash,sizeof(Digest)); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | |
| 29 | bool HashValue::operator == (const HashValue &cmp) |
nothing calls this directly
no test coverage detected