mirror of
https://github.com/AtHeartEngineer/sss.git
synced 2026-01-08 20:28:04 -05:00
Add randombytes submodule
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "randombytes"]
|
||||
path = randombytes
|
||||
url = https://github.com/dsprenkels/randombytes.git
|
||||
1
randombytes
Submodule
1
randombytes
Submodule
Submodule randombytes added at db49030e62
@@ -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
1
randombytes.c
Symbolic link
@@ -0,0 +1 @@
|
||||
randombytes/randombytes.c
|
||||
@@ -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
1
randombytes.h
Symbolic link
@@ -0,0 +1 @@
|
||||
randombytes/randombytes.h
|
||||
Reference in New Issue
Block a user