Sha256: 9a0c5e646fcba32fd49a0f8a0bdda8784080942df6f66e202016798d4f2cdf4d

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

#include <stdio.h>
#include <string.h>

#define TEST_NAME "box_easy2"
#include "cmptest.h"

unsigned char m[10000];
unsigned char m2[10000];
unsigned char c[crypto_box_MACBYTES + 10000];
unsigned char nonce[crypto_box_NONCEBYTES];
unsigned char alicepk[crypto_box_PUBLICKEYBYTES];
unsigned char alicesk[crypto_box_SECRETKEYBYTES];
unsigned char bobpk[crypto_box_PUBLICKEYBYTES];
unsigned char bobsk[crypto_box_SECRETKEYBYTES];

int main(void)
{
    unsigned long long mlen;

    crypto_box_keypair(alicepk, alicesk);
    crypto_box_keypair(bobpk, bobsk);
    mlen = (unsigned long long) randombytes_uniform((uint32_t) sizeof m);
    randombytes_buf(m, mlen);
    randombytes_buf(nonce, sizeof nonce);
    crypto_box_easy(c, m, mlen, nonce, bobpk, alicesk);
    crypto_box_open_easy(m2, c, mlen + crypto_box_MACBYTES,
                         nonce, alicepk, bobsk);
    printf("%d\n", memcmp(m, m2, mlen));

    return 0;
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rbnacl-libsodium-0.6.0 vendor/libsodium/test/default/box_easy2.c
rbnacl-libsodium-0.5.0.1 vendor/libsodium/test/default/box_easy2.c
rbnacl-libsodium-0.5.0.1.pre vendor/libsodium/test/default/box_easy2.c
rbnacl-libsodium-0.5.0 vendor/libsodium/test/default/box_easy2.c