| 46 | |
| 47 | // Read a single block of size ENCRYPTION_BLOCK_SIZE bytes, and decrypt. |
| 48 | ACTOR static Future<Standalone<StringRef>> readBlock(AsyncFileEncrypted* self, uint32_t block) { |
| 49 | state Arena arena; |
| 50 | state unsigned char* encrypted = new (arena) unsigned char[FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE]; |
| 51 | int bytes = wait(uncancellable(holdWhile(arena, |
| 52 | self->file->read(encrypted, |
| 53 | FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE, |
| 54 | FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE * block)))); |
| 55 | StreamCipherKey const* cipherKey = StreamCipherKey::getGlobalCipherKey(); |
| 56 | DecryptionStreamCipher decryptor(cipherKey, self->getIV(block)); |
| 57 | auto decrypted = decryptor.decrypt(encrypted, bytes, arena); |
| 58 | return Standalone<StringRef>(decrypted, arena); |
| 59 | } |
| 60 | |
| 61 | ACTOR static Future<int> read(Reference<AsyncFileEncrypted> self, void* data, int length, int64_t offset) { |
| 62 | state const uint32_t firstBlock = offset / FLOW_KNOBS->ENCRYPTION_BLOCK_SIZE; |
nothing calls this directly
no test coverage detected