-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_rubato.cpp
More file actions
69 lines (57 loc) · 1.27 KB
/
test_rubato.cpp
File metadata and controls
69 lines (57 loc) · 1.27 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include "Rubato.h"
using namespace std;
int main()
{
uint32_t key[BLOCKSIZE];
uint64_t nonce = 0x0123456789abcdef;
uint64_t counter = 0;
uint64_t coeffs[XOF_ELEMENT_COUNT];
uint64_t round_keys[XOF_ELEMENT_COUNT];
uint32_t keystream[BLOCKSIZE];
for (int i = 0; i < BLOCKSIZE; i++)
{
key[i] = i + 1;
}
cout << "Key: " << flush;
for (int i = 0; i < BLOCKSIZE; i++)
{
cout << hex << key[i] << " ";
}
cout << dec << endl;
Rubato cipher(key);
// Print coeffs
cout << "Get coeffs" << endl;
cipher.init(nonce, counter);
cipher.get_coeffs(coeffs);
for (int r = 0; r <= ROUNDS; r++)
{
cout << "----- Round " << r << " -----" << hex << endl;
for (int i = 0; i < BLOCKSIZE; i++)
{
cout << coeffs[r * BLOCKSIZE + i] << " ";
}
cout << dec << endl;
}
// Print round keys
cout << "Get round keys" << endl;
cipher.get_round_keys(round_keys);
for (int r = 0; r <= ROUNDS; r++)
{
cout << " Round " << r << " : " << hex << flush;
for (int i = 0; i < BLOCKSIZE; i++)
{
cout << round_keys[r * BLOCKSIZE + i]<< " ";
}
cout << dec << endl;
}
cout << "Keystream" << hex << endl;
cipher.crypt(keystream);
cout << hex;
for (int i = 0; i < OUTPUTSIZE; i++)
{
cout << keystream[i] << " ";
}
cout << dec << endl;
return 0;
}