-
Notifications
You must be signed in to change notification settings - Fork 80
/
test_sss.c
35 lines (29 loc) · 998 Bytes
/
test_sss.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
#include "sss.h"
#include <assert.h>
#include <string.h>
int main(void)
{
unsigned char data[sss_MLEN] = { 42 }, restored[sss_MLEN];
sss_Share shares[256];
int tmp;
/* Normal operation */
sss_create_shares(shares, data, 1, 1);
tmp = sss_combine_shares(restored, (const sss_Share*) shares, 1);
assert(tmp == 0);
assert(memcmp(restored, data, sss_MLEN) == 0);
/* A lot of shares */
sss_create_shares(shares, data, 255, 255);
tmp = sss_combine_shares(restored, (const sss_Share*) shares, 255);
assert(tmp == 0);
assert(memcmp(restored, data, sss_MLEN) == 0);
/* Not enough shares to restore secret */
sss_create_shares(shares, data, 100, 100);
tmp = sss_combine_shares(restored, (const sss_Share*) shares, 99);
assert(tmp == -1);
/* Too many secrets should also restore the secret */
sss_create_shares(shares, data, 200, 100);
tmp = sss_combine_shares(restored, (const sss_Share*) shares, 200);
assert(tmp == 0);
assert(memcmp(restored, data, sss_MLEN) == 0);
return 0;
}