mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-20 10:37:24 -07:00
Update the examples for libsodium 1.0.7
This commit is contained in:
parent
c7eec99d2f
commit
7354964b91
@ -91,7 +91,9 @@ box(void)
|
|||||||
|
|
||||||
/* encrypt and authenticate the message */
|
/* encrypt and authenticate the message */
|
||||||
printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive());
|
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;
|
ciphertext_len = crypto_box_MACBYTES + message_len;
|
||||||
|
|
||||||
/* send the nonce and the ciphertext */
|
/* send the nonce and the ciphertext */
|
||||||
|
@ -91,8 +91,10 @@ box_detached(void)
|
|||||||
|
|
||||||
/* encrypt and authenticate the message */
|
/* encrypt and authenticate the message */
|
||||||
printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive());
|
printf("Encrypting and authenticating with %s\n\n", crypto_box_primitive());
|
||||||
crypto_box_detached(ciphertext, mac, message, message_len, nonce,
|
if (crypto_box_detached(ciphertext, mac, message, message_len, nonce,
|
||||||
alice_pk, bob_sk);
|
alice_pk, bob_sk) != 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
/* send the nonce, the MAC and the ciphertext */
|
/* send the nonce, the MAC and the ciphertext */
|
||||||
puts("Bob sends the nonce, the MAC and the ciphertext...\n");
|
puts("Bob sends the nonce, the MAC and the ciphertext...\n");
|
||||||
|
@ -99,7 +99,9 @@ print_verification(int ret)
|
|||||||
static void
|
static void
|
||||||
init(void)
|
init(void)
|
||||||
{
|
{
|
||||||
sodium_init();
|
if (sodium_init() != 0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
printf("Using libsodium %s\n", sodium_version_string());
|
printf("Using libsodium %s\n", sodium_version_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user