| 334 | } |
| 335 | |
| 336 | void KeyBlock::Load(const void* buf) { |
| 337 | // Layout of key (764 bytes) |
| 338 | // random-data: `offset' bytes |
| 339 | // key-data: 128 bytes |
| 340 | // random-data: 764 - `offset' - 128 - 4 bytes |
| 341 | // offset: 4 bytes |
| 342 | _offset_data = ReadBigEndian4Bytes((const char*)buf + SIZE - 4); |
| 343 | const uint8_t* p = (const uint8_t*)&_offset_data; |
| 344 | _offset = ((uint32_t)p[0] + p[1] + p[2] + p[3]) % (SIZE - KEY_SIZE - 4); |
| 345 | memcpy(_buf, buf, SIZE - 4); |
| 346 | } |
| 347 | |
| 348 | void KeyBlock::Save(void* buf) const { |
| 349 | memcpy(buf, _buf, SIZE - 4); |
no test coverage detected