Debian Codegraph @

md5/md5.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef MD5_H
20 #define MD5_H
21
22 #include <array>
23 #include <cstdint>
24
25 class MD5 {
26 private:
27 std::array<std::uint32_t, 4> sums_{0x67452301UL, 0XEFCDAB89UL, 0x98BADCFEUL, 0x10325476UL};
28 std::array<uint8_t, 64> tmpbuf_;
29 std::size_t tmpbuf_n_{0};
30 std::uint64_t message_len_{0};
31
32 void round(const uint8_t *block) noexcept;
33 void round(std::array<std::uint32_t, 4> &sums, const uint8_t *block) const noexcept;
34 void place_length(uint8_t *destination) const noexcept;
35
36 public:
37 void update(const uint8_t *data, std::size_t n) noexcept;
38 void update(float val) noexcept;
39 void update(int val) noexcept;
40 void update(uint32_t val) noexcept;
41 void update(uint8_t val) noexcept;
42 void update(int16_t val) noexcept;
43 std::array<uint8_t, 16> digest() const noexcept;
44 void digest(uint8_t *destination) const noexcept;
45 };
46
47 #endif // MD5_H