Пример #1
0
void SHA3::TruncatedFinal(byte *hash, size_t size)
{
	ThrowIfInvalidTruncatedSize(size);
	m_state.BytePtr()[m_counter] ^= 1;
	m_state.BytePtr()[r()-1] ^= 0x80;
	KeccakF1600(m_state);
	memcpy(hash, m_state, size);
	Restart();
}
Пример #2
0
void Keccak::TruncatedFinal(byte *hash, size_t size)
{
	CRYPTOPP_ASSERT(hash != NULLPTR);
    ThrowIfInvalidTruncatedSize(size);

    m_state.BytePtr()[m_counter] ^= 1;
    m_state.BytePtr()[r()-1] ^= 0x80;
    KeccakF1600(m_state);
    memcpy(hash, m_state, size);
    Restart();
}
Пример #3
0
void SHA3::TruncatedFinal(byte *hash, size_t size)
{
	ThrowIfInvalidTruncatedSize(size);

#if defined(CRYPTOPP_USE_FIPS_202_SHA3)
	m_state.BytePtr()[m_counter] ^= 0x06;
#else
	m_state.BytePtr()[m_counter] ^= 1;
#endif

	m_state.BytePtr()[r()-1] ^= 0x80;
	KeccakF1600(m_state);
	memcpy(hash, m_state, size);
	Restart();
}
Пример #4
0
void SHA3::Update(const byte *input, size_t length)
{
	size_t spaceLeft;
	while (length >= (spaceLeft = r() - m_counter))
	{
		xorbuf(m_state.BytePtr() + m_counter, input, spaceLeft);
		KeccakF1600(m_state);
		input += spaceLeft;
		length -= spaceLeft;
		m_counter = 0;
	}

	xorbuf(m_state.BytePtr() + m_counter, input, length);
	m_counter += (unsigned int)length;
}
Пример #5
0
void SHA3::Update(const byte *input, size_t length)
{
    CRYPTOPP_ASSERT((input && length) || !(input || length));
    if (!length) { return; }

    size_t spaceLeft;
    while (length >= (spaceLeft = r() - m_counter))
    {
        if (spaceLeft)
            xorbuf(m_state.BytePtr() + m_counter, input, spaceLeft);
        KeccakF1600(m_state);
        input += spaceLeft;
        length -= spaceLeft;
        m_counter = 0;
    }

    if (length)
        xorbuf(m_state.BytePtr() + m_counter, input, length);
    m_counter += (unsigned int)length;
}