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

Method ProcessData

src/cryptopp/strciphr.cpp:67–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66template <class S>
67void AdditiveCipherTemplate<S>::ProcessData(byte *outString, const byte *inString, size_t length)
68{
69 if (m_leftOver > 0)
70 {
71 size_t len = STDMIN(m_leftOver, length);
72 xorbuf(outString, inString, KeystreamBufferEnd()-m_leftOver, len);
73 length -= len;
74 m_leftOver -= len;
75 inString += len;
76 outString += len;
77
78 if (!length)
79 return;
80 }
81 CRYPTOPP_ASSERT(m_leftOver == 0);
82
83 PolicyInterface &policy = this->AccessPolicy();
84 unsigned int bytesPerIteration = policy.GetBytesPerIteration();
85
86 if (policy.CanOperateKeystream() && length >= bytesPerIteration)
87 {
88 size_t iterations = length / bytesPerIteration;
89 unsigned int alignment = policy.GetAlignment();
90 KeystreamOperation operation = KeystreamOperation((IsAlignedOn(inString, alignment) * 2) | (int)IsAlignedOn(outString, alignment));
91
92 policy.OperateKeystream(operation, outString, inString, iterations);
93
94 inString += iterations * bytesPerIteration;
95 outString += iterations * bytesPerIteration;
96 length -= iterations * bytesPerIteration;
97
98 if (!length)
99 return;
100 }
101
102 size_t bufferByteSize = m_buffer.size();
103 size_t bufferIterations = bufferByteSize / bytesPerIteration;
104
105 while (length >= bufferByteSize)
106 {
107 policy.WriteKeystream(m_buffer, bufferIterations);
108 xorbuf(outString, inString, KeystreamBufferBegin(), bufferByteSize);
109 length -= bufferByteSize;
110 inString += bufferByteSize;
111 outString += bufferByteSize;
112 }
113
114 if (length > 0)
115 {
116 bufferByteSize = RoundUpToMultipleOf(length, bytesPerIteration);
117 bufferIterations = bufferByteSize / bytesPerIteration;
118
119 policy.WriteKeystream(KeystreamBufferEnd()-bufferByteSize, bufferIterations);
120 xorbuf(outString, inString, KeystreamBufferEnd()-bufferByteSize, length);
121 m_leftOver = bufferByteSize - length;
122 }
123}
124

Callers

nothing calls this directly

Calls 15

xorbufFunction · 0.85
KeystreamBufferEndFunction · 0.85
KeystreamOperationEnum · 0.85
IsAlignedOnFunction · 0.85
KeystreamBufferBeginFunction · 0.85
RoundUpToMultipleOfFunction · 0.85
GetCipherDirFunction · 0.85
memcpyFunction · 0.85
WriteKeystreamMethod · 0.80
MandatoryBlockSizeMethod · 0.80
TransformRegisterMethod · 0.80
GetAlignmentMethod · 0.45

Tested by

no test coverage detected