blob: 68243ca279c06e065cec36be6b97b9174694dd85 [file] [log] [blame]
Harald Weltee72cf552016-04-28 07:18:49 +02001/* (C) 2012 by Harald Welte <laforge@gnumonks.org>
2 *
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20
21#include <stdio.h>
22#include <fcntl.h>
23#include <stdint.h>
24#include <unistd.h>
25#include <sys/stat.h>
26
27static int rand_fd = -1;
28int rand_init(void)
29{
30 rand_fd = open("/dev/urandom", O_RDONLY);
31
32 return rand_fd;
33}
34
35int rand_get(uint8_t *rand, unsigned int len)
36{
37 return read(rand_fd, rand, len);
38}