8#include <botan/adler32.h>
9#include <botan/loadstor.h>
15void adler32_update(
const uint8_t input[],
size_t length,
16 uint16_t& S1, uint16_t& S2)
23 S1x += input[ 0]; S2x += S1x;
24 S1x += input[ 1]; S2x += S1x;
25 S1x += input[ 2]; S2x += S1x;
26 S1x += input[ 3]; S2x += S1x;
27 S1x += input[ 4]; S2x += S1x;
28 S1x += input[ 5]; S2x += S1x;
29 S1x += input[ 6]; S2x += S1x;
30 S1x += input[ 7]; S2x += S1x;
31 S1x += input[ 8]; S2x += S1x;
32 S1x += input[ 9]; S2x += S1x;
33 S1x += input[10]; S2x += S1x;
34 S1x += input[11]; S2x += S1x;
35 S1x += input[12]; S2x += S1x;
36 S1x += input[13]; S2x += S1x;
37 S1x += input[14]; S2x += S1x;
38 S1x += input[15]; S2x += S1x;
43 for(
size_t j = 0; j != length; ++j)
58void Adler32::add_data(
const uint8_t input[],
size_t length)
60 const size_t PROCESS_AMOUNT = 5552;
62 while(length >= PROCESS_AMOUNT)
64 adler32_update(input, PROCESS_AMOUNT, m_S1, m_S2);
65 input += PROCESS_AMOUNT;
66 length -= PROCESS_AMOUNT;
69 adler32_update(input, length, m_S1, m_S2);
75void Adler32::final_result(uint8_t output[])
83 return std::unique_ptr<HashFunction>(
new Adler32(*
this));
std::unique_ptr< HashFunction > copy_state() const override
void store_be(uint16_t in, uint8_t out[2])