forked from dsprenkels/sss
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_hazmat.c
38 lines (29 loc) · 940 Bytes
/
test_hazmat.c
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
#include "hazmat.h"
#include <assert.h>
#include <string.h>
static void test_key_shares(void)
{
uint8_t key[32], restored[32];
sss_Keyshare key_shares[256];
size_t idx;
for (idx = 0; idx < 32; idx++) {
key[idx] = idx;
}
sss_create_keyshares(key_shares, key, 1, 1);
sss_combine_keyshares(restored, (const sss_Keyshare*) key_shares, 1);
assert(memcmp(key, restored, 32) == 0);
sss_create_keyshares(key_shares, key, 3, 2);
sss_combine_keyshares(restored, (const sss_Keyshare*) key_shares[1], 2);
assert(memcmp(key, restored, 32) == 0);
sss_create_keyshares(key_shares, key, 255, 127);
sss_combine_keyshares(restored, (const sss_Keyshare*) key_shares[128], 127);
assert(memcmp(key, restored, 32) == 0);
sss_create_keyshares(key_shares, key, 255, 255);
sss_combine_keyshares(restored, (const sss_Keyshare*) key_shares, 255);
assert(memcmp(key, restored, 32) == 0);
}
int main(void)
{
test_key_shares();
return 0;
}