0
|
1 #include "crypto_box.h" |
|
2 |
|
3 int main() { |
|
4 unsigned char n[crypto_box_NONCEBYTES]; |
|
5 unsigned char m[32+crypto_box_ZEROBYTES]; |
|
6 unsigned char c[32+crypto_box_ZEROBYTES]; |
|
7 |
|
8 unsigned char pk[crypto_box_PUBLICKEYBYTES]; |
|
9 unsigned char sk[crypto_box_SECRETKEYBYTES]; |
|
10 //crypto_box_keypair(pk, sk); |
|
11 //randombytes(sk,32); |
|
12 sk[0]=1; |
|
13 crypto_scalarmult_curve25519_base(pk,sk); |
|
14 |
|
15 |
|
16 int r; |
|
17 |
|
18 unsigned char* buffer1offset = m + crypto_box_ZEROBYTES; |
|
19 |
|
20 strcpy(buffer1offset, "hello world"); |
|
21 printf("in=$s\n", buffer1offset); |
|
22 memset(m, 0, crypto_box_ZEROBYTES); |
|
23 r=crypto_box(c, m, 32+crypto_box_ZEROBYTES, n, pk, sk); |
|
24 printf("ret=%d\n", r); |
|
25 |
|
26 memset(c, 0, crypto_box_BOXZEROBYTES); |
|
27 r=crypto_box_open(m, c, 32+crypto_box_ZEROBYTES, n, pk, sk); |
|
28 printf("ret=%d\n", r); |
|
29 printf("out=$s\n", buffer1offset); |
|
30 } |