Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
Sha1.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_CRYPTO_SHA1_HPP_
2#define IV_SRC_CRYPTO_SHA1_HPP_
3
4#include <cstdint>
5#include <vector>
6
7//https://github.com/CommanderBubble/sha1/blob/master/src/sha1.cpp extraído de aquí
8constexpr unsigned int SHA1_SIZE = (5 * sizeof(unsigned int)); /* 20 */
9constexpr unsigned int BLOCK_SIZE = 64;
10
11class Sha1 final
12{
13public:
14 Sha1();
15
16 std::vector<std::byte> digest(void *input, uint32_t input_length);
17
18private:
19 void initialise();
20
21 void process_block(const unsigned char *block);
22
23 unsigned int H0;
24 unsigned int H1;
25 unsigned int H2;
26 unsigned int H3;
27 unsigned int H4;
28
29 unsigned char stored[BLOCK_SIZE * 2];
30 unsigned int stored_size;
31 unsigned int message_length[2];
32
33 unsigned char signature[SHA1_SIZE];
34
36 void process(void *input, uint32_t length);
37 void finish(void *signature_);
38};
39
40#endif//IV_SRC_CRYPTO_SHA1_HPP_
constexpr unsigned int BLOCK_SIZE
Definition Sha1.hpp:9
constexpr unsigned int SHA1_SIZE
Definition Sha1.hpp:8
Definition Sha1.hpp:12
std::vector< std::byte > digest(void *input, uint32_t input_length)
Definition Sha1.cpp:42
unsigned int message_length[2]
Definition Sha1.hpp:31
void finish(void *signature_)
Definition Sha1.cpp:185
Sha1()
Definition Sha1.cpp:20
unsigned int H1
Definition Sha1.hpp:24
void process(void *input, uint32_t length)
Definition Sha1.cpp:139
void process_block(const unsigned char *block)
Definition Sha1.cpp:59
unsigned int H0
Definition Sha1.hpp:23
unsigned char stored[BLOCK_SIZE *2]
Definition Sha1.hpp:29
unsigned char signature[SHA1_SIZE]
Definition Sha1.hpp:33
unsigned int H4
Definition Sha1.hpp:27
void initialise()
Definition Sha1.cpp:25
unsigned int stored_size
Definition Sha1.hpp:30
unsigned int H3
Definition Sha1.hpp:26
bool finished
Definition Sha1.hpp:35
unsigned int H2
Definition Sha1.hpp:25