-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_kyber.c
55 lines (44 loc) · 1.29 KB
/
test_kyber.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "kyber-pake.h"
#include "randombytes.h"
#include "polyvec.h"
#include "poly.h"
#include "cpucycles.h"
#include "speed_print.h"
#define NTESTS 1
static int test_keys()
{
uint8_t pk[CRYPTO_PUBLICKEYBYTES];
uint8_t sk[CRYPTO_SECRETKEYBYTES];
uint8_t ct[CRYPTO_CIPHERTEXTBYTES];
unsigned char pw[32] = "12345678";
unsigned char a_id[32] = "87654321";
unsigned char b_id[32] = "55555555";
const uint8_t ssid[ID_BYTES] = {0};
uint8_t k[CRYPTO_BYTES] = {0};
uint8_t auth_b[AUTH_SIZE] = {0};
uint8_t key_a[CRYPTO_BYTES] = {0};
uint8_t key_b[CRYPTO_BYTES] = {0};
uint8_t send_a0[PAKE_A0_SEND];
uint8_t send_b0[SHA3_256_HashSize];
pake_a0(pw, ssid, send_a0, pk, sk);
pake_b0(pw, ssid, a_id, b_id, send_a0, send_b0, ct, k, auth_b);
pake_a1(pw, sk, send_a0, send_b0, ssid, a_id, b_id, ct, key_a);
pake_b1(ssid, a_id, b_id, send_a0, ct, auth_b, k, key_b);
printf("\nsuccess...");
printf("\nSession Key A:");
printData(key_a, SHA3_256_HashSize);
printf("***************************************\n\n\n");
printf("\nsuccess...");
printf("\nSession Key B:");
printData(key_b, SHA3_256_HashSize);
printf("***************************************\n\n\n");
return 0;
}
int main(void)
{
test_keys();
return 0;
}