Add randombytes submodule

This commit is contained in:
Daan Sprenkels
2017-06-05 16:59:09 +02:00
parent cc8de33cb6
commit 02282131fe
4 changed files with 6 additions and 34 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "randombytes"]
path = randombytes
url = https://github.com/dsprenkels/randombytes.git

1
randombytes Submodule

Submodule randombytes added at db49030e62

View File

@@ -1,20 +0,0 @@
#include "randombytes.h"
#include <assert.h>
#include <string.h>
#ifdef __linux__
# define _GNU_SOURCE
# include <sys/syscall.h>
#endif
void randombytes(void *buf, const size_t n)
{
#ifdef __linux__
int tmp = syscall(SYS_getrandom, buf, n, 0);
assert(tmp == n); /* Failure indicates a bug in the code */
#else
# warning "randombytes(...) is not supported on this platform. Using INSECURE dummy version."
memset(buf, 42, n);
#endif /* __linux__ */
}

1
randombytes.c Symbolic link
View File

@@ -0,0 +1 @@
randombytes/randombytes.c

View File

@@ -1,14 +0,0 @@
#ifndef sss_RANDOMBYTES_H
#define sss_RANDOMBYTES_H
#include <sys/syscall.h>
#include <unistd.h>
/*
* Write `n` bytes of high quality random bytes to `buf`
*/
void randombytes(void *buf, size_t n);
#endif /* sss_RANDOMBYTES_H */

1
randombytes.h Symbolic link
View File

@@ -0,0 +1 @@
randombytes/randombytes.h