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

Method Resynchronize

src/cryptopp/vmac.cpp:120–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120void VMAC_Base::Resynchronize(const byte *nonce, int len)
121{
122 size_t length = ThrowIfInvalidIVLength(len);
123 size_t s = IVSize();
124 byte *storedNonce = m_nonce();
125
126 if (m_is128)
127 {
128 memset(storedNonce, 0, s-length);
129 memcpy(storedNonce+s-length, nonce, length);
130 AccessCipher().ProcessBlock(storedNonce, m_pad());
131 }
132 else
133 {
134 if (m_padCached && (storedNonce[s-1] | 1) == (nonce[length-1] | 1))
135 {
136 m_padCached = VerifyBufsEqual(storedNonce+s-length, nonce, length-1);
137 for (size_t i=0; m_padCached && i<s-length; i++)
138 m_padCached = (storedNonce[i] == 0);
139 }
140 if (!m_padCached)
141 {
142 memset(storedNonce, 0, s-length);
143 memcpy(storedNonce+s-length, nonce, length-1);
144 storedNonce[s-1] = nonce[length-1] & 0xfe;
145 AccessCipher().ProcessBlock(storedNonce, m_pad());
146 m_padCached = true;
147 }
148 storedNonce[s-1] = nonce[length-1];
149 }
150 m_isFirstBlock = true;
151 Restart();
152}
153
154void VMAC_Base::HashEndianCorrectedBlock(const word64 *data)
155{

Callers 6

ResyncMethod · 0.45
ResyncMethod · 0.45
SetCipherWithIVFunction · 0.45
TestModeIVFunction · 0.45
TestSymmetricCipherFunction · 0.45
ValidatePoly1305Function · 0.45

Calls 5

memcpyFunction · 0.85
VerifyBufsEqualFunction · 0.85
ProcessBlockMethod · 0.80
IVSizeFunction · 0.70
RestartFunction · 0.70

Tested by 2

TestModeIVFunction · 0.36
TestSymmetricCipherFunction · 0.36