From 7354964b917978a8439d031361232689c208a3bc Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 6 Dec 2015 23:08:44 +0100 Subject: [PATCH] Update the examples for libsodium 1.0.7 --- examples/box.c | 4 +++- examples/box_detached.c | 6 ++++-- examples/utils.h | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/box.c b/examples/box.c index 0f4ec7f5..d34d4f22 100644 --- a/examples/box.c +++ b/examples/box.c @@ -91,7 +91,9 @@ box(void) /* encrypt and authenticate the message */ printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive()); - crypto_box_easy(ciphertext, message, message_len, nonce, alice_pk, bob_sk); + if (crypto_box_easy(ciphertext, message, message_len, nonce, alice_pk, bob_sk) != 0) { + abort(); + } ciphertext_len = crypto_box_MACBYTES + message_len; /* send the nonce and the ciphertext */ diff --git a/examples/box_detached.c b/examples/box_detached.c index 3ea5a739..8de589a5 100644 --- a/examples/box_detached.c +++ b/examples/box_detached.c @@ -91,8 +91,10 @@ box_detached(void) /* encrypt and authenticate the message */ printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive()); - crypto_box_detached(ciphertext, mac, message, message_len, nonce, - alice_pk, bob_sk); + if (crypto_box_detached(ciphertext, mac, message, message_len, nonce, + alice_pk, bob_sk) != 0) { + abort(); + } /* send the nonce, the MAC and the ciphertext */ puts("Bob sends the nonce, the MAC and the ciphertext...\n"); diff --git a/examples/utils.h b/examples/utils.h index c9460474..70180370 100644 --- a/examples/utils.h +++ b/examples/utils.h @@ -99,7 +99,9 @@ print_verification(int ret) static void init(void) { - sodium_init(); + if (sodium_init() != 0) { + abort(); + } printf("Using libsodium %s\n", sodium_version_string()); }