| 120 | } |
| 121 | |
| 122 | void CTR_ModePolicy::OperateKeystream(KeystreamOperation /*operation*/, byte *output, const byte *input, size_t iterationCount) |
| 123 | { |
| 124 | CRYPTOPP_ASSERT(m_cipher->IsForwardTransformation()); // CTR mode needs the "encrypt" direction of the underlying block cipher, even to decrypt |
| 125 | unsigned int s = BlockSize(); |
| 126 | unsigned int inputIncrement = input ? s : 0; |
| 127 | |
| 128 | while (iterationCount) |
| 129 | { |
| 130 | byte lsb = m_counterArray[s-1]; |
| 131 | size_t blocks = UnsignedMin(iterationCount, 256U-lsb); |
| 132 | m_cipher->AdvancedProcessBlocks(m_counterArray, input, output, blocks*s, BlockTransformation::BT_InBlockIsCounter|BlockTransformation::BT_AllowParallel); |
| 133 | if ((m_counterArray[s-1] = lsb + (byte)blocks) == 0) |
| 134 | IncrementCounterBy256(); |
| 135 | |
| 136 | output += blocks*s; |
| 137 | input += blocks*inputIncrement; |
| 138 | iterationCount -= blocks; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length) |
| 143 | { |
nothing calls this directly
no test coverage detected