Botan 3.6.1
Crypto and TLS for C&
adler32.h
Go to the documentation of this file.
1/*
2* Adler32
3* (C) 1999-2007 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_ADLER32_H_
9#define BOTAN_ADLER32_H_
10
11#include <botan/hash.h>
12
13namespace Botan {
14
15/**
16* The Adler32 checksum, used in zlib
17*/
18class Adler32 final : public HashFunction {
19 public:
20 std::string name() const override { return "Adler32"; }
21
22 size_t output_length() const override { return 4; }
23
24 std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<Adler32>(); }
25
26 std::unique_ptr<HashFunction> copy_state() const override;
27
28 void clear() override {
29 m_S1 = 1;
30 m_S2 = 0;
31 }
32
33 Adler32() { clear(); }
34
35 ~Adler32() override { clear(); }
36
37 private:
38 void add_data(std::span<const uint8_t>) override;
39 void final_result(std::span<uint8_t>) override;
40 uint16_t m_S1, m_S2;
41};
42
43} // namespace Botan
44
45#endif
size_t output_length() const override
Definition adler32.h:22
std::unique_ptr< HashFunction > new_object() const override
Definition adler32.h:24
void clear() override
Definition adler32.h:28
std::unique_ptr< HashFunction > copy_state() const override
Definition adler32.cpp:90
~Adler32() override
Definition adler32.h:35
std::string name() const override
Definition adler32.h:20
int(* final)(unsigned char *, CTX *)