Mercurial > hg > quicktun
diff src/nacltest.c @ 0:65c01f57bdce V2.1.2
Initial commit
author | ivo <ivo@UFO-Net.nl> |
---|---|
date | Thu, 07 Oct 2010 15:53:01 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/nacltest.c Thu Oct 07 15:53:01 2010 +0200 @@ -0,0 +1,30 @@ +#include "crypto_box.h" + +int main() { + unsigned char n[crypto_box_NONCEBYTES]; + unsigned char m[32+crypto_box_ZEROBYTES]; + unsigned char c[32+crypto_box_ZEROBYTES]; + + unsigned char pk[crypto_box_PUBLICKEYBYTES]; + unsigned char sk[crypto_box_SECRETKEYBYTES]; + //crypto_box_keypair(pk, sk); + //randombytes(sk,32); + sk[0]=1; + crypto_scalarmult_curve25519_base(pk,sk); + + + int r; + + unsigned char* buffer1offset = m + crypto_box_ZEROBYTES; + + strcpy(buffer1offset, "hello world"); + printf("in=$s\n", buffer1offset); + memset(m, 0, crypto_box_ZEROBYTES); + r=crypto_box(c, m, 32+crypto_box_ZEROBYTES, n, pk, sk); + printf("ret=%d\n", r); + + memset(c, 0, crypto_box_BOXZEROBYTES); + r=crypto_box_open(m, c, 32+crypto_box_ZEROBYTES, n, pk, sk); + printf("ret=%d\n", r); + printf("out=$s\n", buffer1offset); +}