1RAND_LOAD_FILE(3)                   OpenSSL                  RAND_LOAD_FILE(3)
2
3
4

NAME

6       RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file
7

SYNOPSIS

9        #include <openssl/rand.h>
10
11        int RAND_load_file(const char *filename, long max_bytes);
12
13        int RAND_write_file(const char *filename);
14
15        const char *RAND_file_name(char *buf, size_t num);
16

DESCRIPTION

18       RAND_load_file() reads a number of bytes from file filename and adds
19       them to the PRNG. If max_bytes is nonnegative, up to max_bytes are
20       read; if max_bytes is -1, the complete file is read.  Do not load the
21       same file multiple times unless its contents have been updated by
22       RAND_write_file() between reads.  Also, note that filename should be
23       adequately protected so that an attacker cannot replace or examine the
24       contents.  If filename is not a regular file, then user is considered
25       to be responsible for any side effects, e.g. non-anticipated blocking
26       or capture of controlling terminal.
27
28       RAND_write_file() writes a number of random bytes (currently 128) to
29       file filename which can be used to initialize the PRNG by calling
30       RAND_load_file() in a later session.
31
32       RAND_file_name() generates a default path for the random seed file. buf
33       points to a buffer of size num in which to store the filename.
34
35       On all systems, if the environment variable RANDFILE is set, its value
36       will be used as the seed filename.  Otherwise, the file is called
37       ".rnd", found in platform dependent locations:
38
39       On Windows (in order of preference)
40            %HOME%, %USERPROFILE%, %SYSTEMROOT%, C:\
41
42       On VMS
43            SYS$LOGIN:
44
45       On all other systems
46            $HOME
47
48       If $HOME (on non-Windows and non-VMS system) is not set either, or num
49       is too small for the pathname, an error occurs.
50

RETURN VALUES

52       RAND_load_file() returns the number of bytes read or -1 on error.
53
54       RAND_write_file() returns the number of bytes written, or -1 if the
55       bytes written were generated without appropriate seeding.
56
57       RAND_file_name() returns a pointer to buf on success, and NULL on
58       error.
59

SEE ALSO

61       RAND_add(3), RAND_bytes(3), RAND(7)
62
64       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
65
66       Licensed under the OpenSSL license (the "License").  You may not use
67       this file except in compliance with the License.  You can obtain a copy
68       in the file LICENSE in the source distribution or at
69       <https://www.openssl.org/source/license.html>.
70
71
72
731.1.1l                            2021-09-15                 RAND_LOAD_FILE(3)
Impressum