1RAND(7) OpenSSL RAND(7)
2
3
4
6 RAND - the OpenSSL random generator
7
9 Random numbers are a vital part of cryptography, they are needed to
10 provide unpredictability for tasks like key generation, creating salts,
11 and many more. Software-based generators must be seeded with external
12 randomness before they can be used as a cryptographically-secure
13 pseudo-random number generator (CSPRNG). The availability of common
14 hardware with special instructions and modern operating systems, which
15 may use items such as interrupt jitter and network packet timings, can
16 be reasonable sources of seeding material.
17
18 OpenSSL comes with a default implementation of the RAND API which is
19 based on the deterministic random bit generator (DRBG) model as
20 described in [NIST SP 800-90A Rev. 1]. The default random generator
21 will initialize automatically on first use and will be fully functional
22 without having to be initialized ('seeded') explicitly. It seeds and
23 reseeds itself automatically using trusted random sources provided by
24 the operating system.
25
26 As a normal application developer, you do not have to worry about any
27 details, just use RAND_bytes(3) to obtain random data. Having said
28 that, there is one important rule to obey: Always check the error
29 return value of RAND_bytes(3) and do not take randomness for granted.
30
31 For values that should remain secret, you can use RAND_priv_bytes(3)
32 instead. This method does not provide 'better' randomness, it uses the
33 same type of CSPRNG. The intention behind using a dedicated CSPRNG
34 exclusively for private values is that none of its output should be
35 visible to an attacker (e.g., used as salt value), in order to reveal
36 as little information as possible about its internal state, and that a
37 compromise of the "public" CSPRNG instance will not affect the secrecy
38 of these private values.
39
40 In the rare case where the default implementation does not satisfy your
41 special requirements, there are two options:
42
43 · Replace the default RAND method by your own RAND method using
44 RAND_set_rand_method(3).
45
46 · Modify the default settings of the OpenSSL RAND method by modifying
47 the security parameters of the underlying DRBG, which is described in
48 detail in RAND_DRBG(7).
49
50 Changing the default random generator or its default parameters should
51 be necessary only in exceptional cases and is not recommended, unless
52 you have a profound knowledge of cryptographic principles and
53 understand the implications of your changes.
54
56 RAND_add(3), RAND_bytes(3), RAND_priv_bytes(3),
57 RAND_get_rand_method(3), RAND_set_rand_method(3), RAND_OpenSSL(3),
58 RAND_DRBG(7)
59
61 Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
62
63 Licensed under the OpenSSL license (the "License"). You may not use
64 this file except in compliance with the License. You can obtain a copy
65 in the file LICENSE in the source distribution or at
66 <https://www.openssl.org/source/license.html>.
67
68
69
701.1.1c 2019-05-28 RAND(7)