-
Notifications
You must be signed in to change notification settings - Fork 0
/
Keccak1600.cpp
40 lines (32 loc) · 966 Bytes
/
Keccak1600.cpp
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
#include "Keccak1600.h"
#include <iostream>
extern "C" {
#include "sha3/hash_functions/Keccak64_common/KeccakF-1600-interface.h"
#include "sha3/hash_functions/Keccak64_common/KeccakSponge.h"
}
using namespace std;
Keccak1600::Keccak1600() : rounds(1) {
}
Keccak1600::~Keccak1600() {
}
int Keccak1600::setNumRounds(int rounds) {
if (rounds!=24 && (rounds<1 || rounds>8)){
return -1;
}
this->rounds=rounds;
return 1;
}
int Keccak1600::evaluate(const unsigned char* input, unsigned char* output) const {
spongeState state;
InitSponge(&state, 1024, 576);
Absorb(&state, input, 1022, rounds);
Squeeze(&state, output, 1024, rounds);
return 1;
}
int Keccak1600::evaluate(const unsigned char* input, const unsigned char* key, unsigned char* output) const {
spongeState state;
InitSponge(&state, 1024, 576);
Absorb(&state, input, 1022, rounds);
Squeeze(&state, output, 1024, rounds);
return 1;
}