-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDSHA_sha3.h
41 lines (31 loc) · 922 Bytes
/
DSHA_sha3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef DSHA_SHA3_H
#define DSHA_SHA3_H
#include <stdlib.h>
#include "../../Sha3Interface.h"
class DSHA : public Sha3Interface {
#define DSHA_DEFAULT_ROUNDS 16 /* from 0 to 15 */
#define DSHA_ROTR64(x,n) (((x) >> (n)) | ((x) << (64 - (n))))
#define DSHA_ROTR32(x,n) (((x) >> (n)) | ((x) << (32 - (n))))
typedef enum { SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2 } HashReturn;
typedef struct
{
DataLength databitlen[2];
unsigned int hashbitlen;
unsigned int blocksize;
BitSequence block[129];
unsigned long hashval[16];
} hashState;
private:
int dshaNumRounds;
hashState dshaState;
public:
DSHA(const int numRounds);
int Init(int hashbitlen);
int Update(const BitSequence *data, DataLength databitlen);
int Final(BitSequence *hashval);
int Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval);
private:
int sha32_compile();
int sha64_compile();
};
#endif