-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpu.h
More file actions
22 lines (16 loc) · 821 Bytes
/
Copy pathcpu.h
File metadata and controls
22 lines (16 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once
#include <algorithm>
#include <cstring>
#include <cstdint>
namespace cpu {
// swaps the endian of any datatype. Source: http://stackoverflow.com/a/4956493
template <typename T> T swap_endian(T u);
// implementation of the s function as described in section 3. of spec
std::uint32_t sha1_helper_s(std::uint32_t input, unsigned char offset);
// implementation of the f function as described in section 5. of spec
std::uint32_t sha1_helper_f(unsigned char nr, const std::uint32_t& b, const std::uint32_t& c, const std::uint32_t& d);
// representation of the K variables as described in section 5. of spec
std::uint32_t sha1_helper_K(unsigned char nr);
// calculates the sha1 sum
void sha1(void* input_buffer, const unsigned int& input_buffer_size, void* output, std::uint32_t* current_block);
}