X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fsha1.C;h=17471f94588e528a43499688372c17d7193f6e05;hb=ccd23c15fae578be22d48b1a1e8b09cb43d593ae;hp=ad5becf899edc142b129c13658b6741a0a9a6be8;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/sha1.C b/cinelerra-5.1/cinelerra/sha1.C index ad5becf8..17471f94 100644 --- a/cinelerra-5.1/cinelerra/sha1.C +++ b/cinelerra-5.1/cinelerra/sha1.C @@ -3,10 +3,24 @@ void SHA1::addBytes(const uint8_t* input, size_t length) { - while (length--) { - m_buffer[m_cursor++] = *input++; - ++m_totalBytes; - if (m_cursor == 64) processBlock(); + m_totalBytes += length; + while (length > 0) { +#if 1 +// allow unaliged access + uint64_t *buf = (uint64_t*)&m_buffer[m_cursor]; + const uint64_t *inp = (const uint64_t*)input; + while (length >= sizeof(uint64_t) && m_cursor < 64) { + *buf++ = *inp++; + m_cursor += sizeof(uint64_t); + length -= sizeof(uint64_t); + } + input = (const uint8_t *)inp; +#endif + while (length > 0 && m_cursor < 64) { + m_buffer[m_cursor++] = *input++; + --length; + } + if( m_cursor >= 64 ) processBlock(); } }