From 198a6debffeaf49b1fdb04135717231cbcc52f0d Mon Sep 17 00:00:00 2001 From: Shane Bryldt Date: Wed, 23 Nov 2016 20:20:26 +0000 Subject: [PATCH] FS-9767: Fixed the size of the keys to use crypto_sign_XXXXBYTES for proper key size Also added parsing of identity in message_mutable to force directing test messages which are now recieved by the designated peer --- libs/libks/test/dht-example.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libs/libks/test/dht-example.c b/libs/libks/test/dht-example.c index 3b6f29a583..323f541590 100644 --- a/libs/libks/test/dht-example.c +++ b/libs/libks/test/dht-example.c @@ -99,8 +99,8 @@ main(int argc, char **argv) static ks_thread_t *threads[1]; /* Main dht event thread */ ks_pool_t *pool; int err = 0; - unsigned char alice_publickey[crypto_box_PUBLICKEYBYTES] = {0}; - unsigned char alice_secretkey[crypto_box_SECRETKEYBYTES] = {0}; + unsigned char alice_publickey[crypto_sign_PUBLICKEYBYTES] = {0}; + unsigned char alice_secretkey[crypto_sign_SECRETKEYBYTES] = {0}; ks_init(); @@ -285,11 +285,21 @@ main(int argc, char **argv) /* usage: print_identity_key [identity key] */ } else if (!strncmp(line, "message_mutable", 15)) { char *input = strdup(line); - char *message_id = input + 16; + char *identity_key = input + 16; + char *identities[2] = { identity_key, NULL }; + char *message_id = NULL; char *message = NULL; cJSON *output = NULL; int idx = 17; /* this should be the start of the message_id */ for ( idx = 17; idx < 100 && input[idx] != '\0'; idx++ ) { + if ( input[idx] == ' ' ) { + input[idx] = '\0'; + message_id = input + 1 + idx; + break; + } + } + + for ( idx++; idx < 100 && input[idx] != '\0'; idx++ ) { if ( input[idx] == ' ' ) { input[idx] = '\0'; message = input + 1 + idx; @@ -310,7 +320,7 @@ main(int argc, char **argv) output = cJSON_CreateString(message); ks_dht_send_message_mutable_cjson(h, alice_secretkey, alice_publickey, - NULL, message_id, 1, output, 600); + identities, message_id, 1, output, 600); free(input); cJSON_Delete(output); } else if (!strncmp(line, "message_immutable", 15)) {