| 118 | } |
| 119 | |
| 120 | void 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 | |
| 154 | void VMAC_Base::HashEndianCorrectedBlock(const word64 *data) |
| 155 | { |