Sha256: 801dca32eca9383e0bd91d451ae78a1753efd158e27ffaff129698bf1cd73a82

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

#include <sys/types.h>

#include <assert.h>
#include <limits.h>
#include <stdint.h>

#include "randombytes.h"
#include "randombytes_sysrandom.h"

static const randombytes_implementation *implementation =
    &randombytes_sysrandom_implementation;

int
randombytes_set_implementation(randombytes_implementation *impl)
{
    implementation = impl;

    return 0;
}

const char *
randombytes_implementation_name(void)
{
    return implementation->implementation_name();
}

uint32_t
randombytes_random(void)
{
    return implementation->random();
}

void
randombytes_stir(void)
{
    implementation->stir();
}

uint32_t
randombytes_uniform(const uint32_t upper_bound)
{
    return implementation->uniform(upper_bound);
}

void
randombytes_buf(void * const buf, const size_t size)
{
    if (size > (size_t) 0U) {
        implementation->buf(buf, size);
    }
}

int
randombytes_close(void)
{
    return implementation->close();
}

void
randombytes(unsigned char * const buf, const unsigned long long buf_len)
{
    assert(buf_len <= SIZE_MAX);
    randombytes_buf(buf, (size_t) buf_len);
}

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rbnacl-libsodium-1.0.2 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-1.0.1 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-1.0.0 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-0.7.0 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-0.6.1 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-0.6.0 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-0.5.0.1 vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-0.5.0.1.pre vendor/libsodium/src/libsodium/randombytes/randombytes.c
rbnacl-libsodium-0.5.0 vendor/libsodium/src/libsodium/randombytes/randombytes.c