| 186 | } |
| 187 | |
| 188 | void CBC_CTS_Encryption::ProcessLastBlock(byte *outString, const byte *inString, size_t length) |
| 189 | { |
| 190 | if (length <= BlockSize()) |
| 191 | { |
| 192 | if (!m_stolenIV) |
| 193 | throw InvalidArgument("CBC_Encryption: message is too short for ciphertext stealing"); |
| 194 | |
| 195 | // steal from IV |
| 196 | memcpy(outString, m_register, length); |
| 197 | outString = m_stolenIV; |
| 198 | } |
| 199 | else |
| 200 | { |
| 201 | // steal from next to last block |
| 202 | xorbuf(m_register, inString, BlockSize()); |
| 203 | m_cipher->ProcessBlock(m_register); |
| 204 | inString += BlockSize(); |
| 205 | length -= BlockSize(); |
| 206 | memcpy(outString+BlockSize(), m_register, length); |
| 207 | } |
| 208 | |
| 209 | // output last full ciphertext block |
| 210 | xorbuf(m_register, inString, length); |
| 211 | m_cipher->ProcessBlock(m_register); |
| 212 | memcpy(outString, m_register, BlockSize()); |
| 213 | } |
| 214 | |
| 215 | void CBC_Decryption::ResizeBuffers() |
| 216 | { |
no test coverage detected