MCPcopy Create free account
hub / github.com/c3d/tao3D / OperateKeystream

Method OperateKeystream

libcryptopp/cryptopp/modes.cpp:110–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void CTR_ModePolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
111{
112 assert(m_cipher->IsForwardTransformation()); // CTR mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
113 unsigned int s = BlockSize();
114 unsigned int inputIncrement = input ? s : 0;
115
116 while (iterationCount)
117 {
118 byte lsb = m_counterArray[s-1];
119 size_t blocks = UnsignedMin(iterationCount, 256U-lsb);
120 m_cipher->AdvancedProcessBlocks(m_counterArray, input, output, blocks*s, BlockTransformation::BT_InBlockIsCounter|BlockTransformation::BT_AllowParallel);
121 if ((m_counterArray[s-1] = lsb + (byte)blocks) == 0)
122 IncrementCounterBy256();
123
124 output += blocks*s;
125 input += blocks*inputIncrement;
126 iterationCount -= blocks;
127 }
128}
129
130void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
131{

Callers

nothing calls this directly

Calls 4

UnsignedMinFunction · 0.85
AdvancedProcessBlocksMethod · 0.80
BlockSizeFunction · 0.70

Tested by

no test coverage detected