Sha256: 41ee1f3ba4c1f0a2135959c0bf65e6d9e0fae7504ec75f9aa53d54c35e10e537

Contents?: true

Size: 742 Bytes

Versions: 3

Compression:

Stored size: 742 Bytes

Contents

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

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

unsigned char m[10000];
unsigned char m2[10000];
unsigned char c[crypto_secretbox_MACBYTES + 10000];
unsigned char nonce[crypto_secretbox_NONCEBYTES];
unsigned char k[crypto_secretbox_KEYBYTES];

int main(void)
{
    unsigned long long mlen;

    randombytes_buf(k, sizeof k);
    mlen = (unsigned long long) randombytes_uniform((uint32_t) sizeof m);
    randombytes_buf(m, mlen);
    randombytes_buf(nonce, sizeof nonce);
    crypto_secretbox_easy(c, m, mlen, nonce, k);
    crypto_secretbox_open_easy(m2, c, mlen + crypto_secretbox_MACBYTES,
                               nonce, k);
    printf("%d\n", memcmp(m, m2, mlen));

    return 0;
}

Version data entries

3 entries across 3 versions & 1 rubygems

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