libmobi
C library for handling MOBI format ebook documents
|
Portable function for generating random data. More...
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include "config.h"
#include "randombytes.h"
#include "debug.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
Data Structures | |
struct | MOBIRandom |
Macros | |
#define | UNUSED(x) (void)(x) |
#define | NEEDS_INIT |
#define | NEEDS_CLOSE |
Functions | |
MOBI_RET | mobi_randombytes (void *buf, const size_t size) |
Fill buffer with random bytes. More... | |
Portable function for generating random data.
Copyright (c) 2022 Bartek Fabiszewski http://www.fabiszewski.net
This file is part of libmobi. Licensed under LGPL, either version 3, or any later. See http://www.gnu.org/licenses/
This code is based on libsodium's randombytes_buf function We just extract the single function we need from libsodium and adjust it for our use. Most of the code originates from: https://github.com/jedisct1/libsodium/blob/d250858c7445b7de94e912b529b81defe20d4aaa/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c Original code uses following license:
ISC License
Copyright (c) 2013-2022 Frank Denis <j at pureftpd dot org>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
MOBI_RET mobi_randombytes | ( | void * | buf, |
const size_t | size | ||
) |
Fill buffer with random bytes.
Write n random bytes of high quality to buf.
[in,out] | buf | Buffer |
[in] | size | Buffer size (up to 256 bytes) |