From f438116b6ba4f99c6a7ccafc4ac92623715ae73a Mon Sep 17 00:00:00 2001 From: Jan Varho Date: Fri, 23 May 2014 10:22:52 +0300 Subject: [PATCH] Test crypto_box_seed_keypair --- .gitignore | 1 + test/default/Makefile.am | 6 ++++++ test/default/box_seed.c | 28 ++++++++++++++++++++++++++++ test/default/box_seed.exp | 8 ++++++++ 4 files changed, 43 insertions(+) create mode 100644 test/default/box_seed.c create mode 100644 test/default/box_seed.exp diff --git a/.gitignore b/.gitignore index 23139844..925e6a20 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,7 @@ test/default/box7 test/default/box8 test/default/box_easy test/default/box_easy2 +test/default/box_seed test/default/chacha20 test/default/core1 test/default/core2 diff --git a/test/default/Makefile.am b/test/default/Makefile.am index f4a4aab1..0b09a26d 100644 --- a/test/default/Makefile.am +++ b/test/default/Makefile.am @@ -14,6 +14,7 @@ EXTRA_DIST = \ box8.exp \ box_easy.exp \ box_easy2.exp \ + box_seed.exp \ chacha20.exp \ core1.exp \ core2.exp \ @@ -69,6 +70,7 @@ DISTCLEANFILES = \ box8.res \ box_easy.res \ box_easy2.res \ + box_seed.res \ chacha20.res \ core1.res \ core2.res \ @@ -132,6 +134,7 @@ TESTS_TARGETS = \ box8 \ box_easy \ box_easy2 \ + box_seed \ chacha20 \ core1 \ core2 \ @@ -217,6 +220,9 @@ box_easy_LDADD = $(TESTS_LDADD) box_easy2_SOURCE = cmptest.h box_easy2.c box_easy2_LDADD = $(TESTS_LDADD) +box_seed_SOURCE = cmptest.h box_seed.c +box_seed_LDADD = $(TESTS_LDADD) + chacha20_SOURCE = cmptest.h chacha20.c chacha20_LDADD = $(TESTS_LDADD) diff --git a/test/default/box_seed.c b/test/default/box_seed.c new file mode 100644 index 00000000..6533d8cb --- /dev/null +++ b/test/default/box_seed.c @@ -0,0 +1,28 @@ +#include + +#define TEST_NAME "box_seed" +#include "cmptest.h" + +unsigned char seed[32] = { + 0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d +,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 +,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a +,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a +}; + +int main(void) +{ + int i; + unsigned char sk[32]; + unsigned char pk[32]; + crypto_box_curve25519xsalsa20poly1305_seed_keypair(pk, sk, seed); + for (i = 0;i < 32;++i) { + printf(",0x%02x",(unsigned int) pk[i]); + if (i % 8 == 7) printf("\n"); + } + for (i = 0;i < 32;++i) { + printf(",0x%02x",(unsigned int) sk[i]); + if (i % 8 == 7) printf("\n"); + } + return 0; +} diff --git a/test/default/box_seed.exp b/test/default/box_seed.exp new file mode 100644 index 00000000..8a3803e4 --- /dev/null +++ b/test/default/box_seed.exp @@ -0,0 +1,8 @@ +,0x85,0x20,0xf0,0x09,0x89,0x30,0xa7,0x54 +,0x74,0x8b,0x7d,0xdc,0xb4,0x3e,0xf7,0x5a +,0x0d,0xbf,0x3a,0x0d,0x26,0x38,0x1a,0xf4 +,0xeb,0xa4,0xa9,0x8e,0xaa,0x9b,0x4e,0x6a +,0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d +,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 +,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a +,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a