| 398 | # ifndef MMKV_DISABLE_CRYPT |
| 399 | |
| 400 | pair<bool, KeyValueHolder> |
| 401 | MMKV::appendDataWithKey(const MMBuffer &data, MMKVKey_t key, const KeyValueHolderCrypt &kvHolder, bool isDataHolder) { |
| 402 | if (kvHolder.type != KeyValueHolderType_Offset) { |
| 403 | return appendDataWithKey(data, key, isDataHolder); |
| 404 | } |
| 405 | SCOPED_LOCK(m_exclusiveProcessLock); |
| 406 | |
| 407 | uint32_t keyLength = kvHolder.keySize; |
| 408 | // size needed to encode the key |
| 409 | size_t rawKeySize = keyLength + pbRawVarint32Size(keyLength); |
| 410 | |
| 411 | auto basePtr = (uint8_t *) m_file->getMemory() + Fixed32Size; |
| 412 | MMBuffer keyData(rawKeySize); |
| 413 | AESCrypt decrypter = m_crypter->cloneWithStatus(kvHolder.cryptStatus); |
| 414 | decrypter.decrypt(basePtr + kvHolder.offset, keyData.getPtr(), rawKeySize); |
| 415 | |
| 416 | return doAppendDataWithKey(data, keyData, isDataHolder, keyLength); |
| 417 | } |
| 418 | |
| 419 | pair<bool, KeyValueHolder> |
| 420 | MMKV::overrideDataWithKey(const MMBuffer &data, MMKVKey_t key, const KeyValueHolderCrypt &kvHolder, bool isDataHolder) { |
nothing calls this directly
no test coverage detected