MCPcopy Create free account
hub / github.com/Tencent/MMKV / decryptBuffer

Function decryptBuffer

Core/KeyValueHolder.cpp:133–153  ·  view source on GitHub ↗

get decrypt data with [position, -1)

Source from the content-addressed store, hash-verified

131
132// get decrypt data with [position, -1)
133static MMBuffer decryptBuffer(AESCrypt &crypter, const MMBuffer &inputBuffer, size_t position) {
134 size_t smallBuffer[16 / sizeof(size_t)];
135 auto basePtr = (uint8_t *) inputBuffer.getPtr();
136 auto ptr = basePtr;
137 for (size_t index = sizeof(smallBuffer); index < position; index += sizeof(smallBuffer)) {
138 crypter.decrypt(ptr, smallBuffer, sizeof(smallBuffer));
139 ptr += sizeof(smallBuffer);
140 }
141 if (ptr < basePtr + position) {
142 crypter.decrypt(ptr, smallBuffer, static_cast<size_t>(basePtr + position - ptr));
143 ptr = basePtr + position;
144 }
145 size_t length = inputBuffer.length() - position;
146 MMBuffer tmp(length);
147
148 auto input = ptr;
149 auto output = tmp.getPtr();
150 crypter.decrypt(input, output, length);
151
152 return tmp;
153}
154
155MMBuffer KeyValueHolderCrypt::toMMBuffer(const void *basePtr, const AESCrypt *crypter) const {
156 if (type == KeyValueHolderType_Direct) {

Callers 1

toMMBufferMethod · 0.85

Calls 1

decryptMethod · 0.80

Tested by

no test coverage detected