2 Unix SMB/CIFS implementation.
4 Functions to create reasonable random numbers for crypto use.
6 Copyright (C) Jeremy Allison 2001
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "system/filesys.h"
24 #include "lib/util/genrand.h"
25 #include "sys_rw_data.h"
26 #include "lib/util/blocking.h"
28 static int urand_fd
= -1;
30 static void open_urandom(void)
35 urand_fd
= open( "/dev/urandom", O_RDONLY
,0);
39 smb_set_close_on_exec(urand_fd
);
42 _PUBLIC_
void generate_random_buffer(uint8_t *out
, int len
)
48 rw_ret
= read_data(urand_fd
, out
, len
);
55 * Keep generate_secret_buffer in case we ever want to do something
58 _PUBLIC_
void generate_secret_buffer(uint8_t *out
, int len
)
60 generate_random_buffer(out
, len
);