random.c (806B)
1 /* 2 Implementation of the Lilliput-AE tweakable block cipher. 3 4 Authors, hereby denoted as "the implementer": 5 Kévin Le Gouguec, 6 2019. 7 8 For more information, feedback or questions, refer to our website: 9 https://paclido.fr/lilliput-ae 10 11 To the extent possible under law, the implementer has waived all copyright 12 and related or neighboring rights to the source code in this file. 13 http://creativecommons.org/publicdomain/zero/1.0/ 14 15 --- 16 17 This file provides a system-specific function to generate random bytes. 18 */ 19 20 /* glibc < 2.25 does not provide getrandom(2): use the system call. */ 21 22 #define _GNU_SOURCE 23 24 #include <stddef.h> 25 #include <stdint.h> 26 27 #include <unistd.h> 28 #include <sys/syscall.h> 29 30 #include "random.h" 31 32 33 void randombytes(size_t nb, uint8_t out[nb]) 34 { 35 syscall(SYS_getrandom, out, nb, 0); 36 }