Browse Source

Update the examples for libsodium 1.0.7

next
Frank Denis 9 years ago
parent
commit
7354964b91
  1. 4
      examples/box.c
  2. 6
      examples/box_detached.c
  3. 4
      examples/utils.h

4
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 */

6
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");

4
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());
}

Loading…
Cancel
Save