get decrypt data with [position, -1)
| 131 | |
| 132 | // get decrypt data with [position, -1) |
| 133 | static 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 | |
| 155 | MMBuffer KeyValueHolderCrypt::toMMBuffer(const void *basePtr, const AESCrypt *crypter) const { |
| 156 | if (type == KeyValueHolderType_Direct) { |