diff options
author | lloyd <[email protected]> | 2010-10-12 20:29:01 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-10-12 20:29:01 +0000 |
commit | 21d94214fda80487b6119b15f530608ece5f597d (patch) | |
tree | 78d6fded366f791ed87bedcf53c7523c52f61b99 /src/checksum | |
parent | 6385602fcccfd9c561b1c097095ddd2edf1a2357 (diff) |
Remove Alder32::hash, replace by anon namespace function
Diffstat (limited to 'src/checksum')
-rw-r--r-- | src/checksum/adler32/adler32.cpp | 33 | ||||
-rw-r--r-- | src/checksum/adler32/adler32.h | 1 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/checksum/adler32/adler32.cpp b/src/checksum/adler32/adler32.cpp index c66943b88..09e42b8db 100644 --- a/src/checksum/adler32/adler32.cpp +++ b/src/checksum/adler32/adler32.cpp @@ -10,12 +10,14 @@ namespace Botan { -/* -* Adler32 Checksum -*/ -void Adler32::hash(const byte input[], u32bit length) +namespace { + +void adler32_update(const byte input[], size_t length, + u16bit& S1, u16bit& S2) { - u32bit S1x = S1, S2x = S2; + u32bit S1x = S1; + u32bit S2x = S2; + while(length >= 16) { S1x += input[ 0]; S2x += S1x; @@ -37,29 +39,34 @@ void Adler32::hash(const byte input[], u32bit length) input += 16; length -= 16; } - for(u32bit j = 0; j != length; ++j) + + for(size_t j = 0; j != length; ++j) { - S1x += input[j]; S2x += S1x; + S1x += input[j]; + S2x += S1x; } - S1x %= 65521; - S2x %= 65521; - S1 = S1x; - S2 = S2x; + + S1 = S1x % 65521; + S2 = S2x % 65521; } +} + /* * Update an Adler32 Checksum */ void Adler32::add_data(const byte input[], u32bit length) { const u32bit PROCESS_AMOUNT = 5552; + while(length >= PROCESS_AMOUNT) { - hash(input, PROCESS_AMOUNT); + adler32_update(input, PROCESS_AMOUNT, S1, S2); input += PROCESS_AMOUNT; length -= PROCESS_AMOUNT; } - hash(input, length); + + adler32_update(input, length, S1, S2); } /* diff --git a/src/checksum/adler32/adler32.h b/src/checksum/adler32/adler32.h index 8cbd67f10..4993e601b 100644 --- a/src/checksum/adler32/adler32.h +++ b/src/checksum/adler32/adler32.h @@ -26,7 +26,6 @@ class BOTAN_DLL Adler32 : public HashFunction private: void add_data(const byte[], u32bit); void final_result(byte[]); - void hash(const byte[], u32bit); u16bit S1, S2; }; |