MCPcopy Create free account
hub / github.com/LUX-Core/lux / OperateKeystream

Method OperateKeystream

src/cryptopp/modes.cpp:122–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122void 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
142void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
143{

Callers

nothing calls this directly

Calls 4

UnsignedMinFunction · 0.85
AdvancedProcessBlocksMethod · 0.80
BlockSizeFunction · 0.70

Tested by

no test coverage detected