MCPcopy Create free account
hub / github.com/apple/foundationdb / readBlock

Method readBlock

fdbrpc/AsyncFileEncrypted.actor.cpp:48–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 4

uncancellableFunction · 0.85
getIVMethod · 0.80
readMethod · 0.65
decryptMethod · 0.45

Tested by

no test coverage detected