rand.pod 2.4 KB
Newer Older
B
Bodo Möller 已提交
1 2 3 4
=pod

=head1 NAME

R
Rich Salz 已提交
5
openssl-rand,
B
Bodo Möller 已提交
6 7 8 9 10
rand - generate pseudo-random bytes

=head1 SYNOPSIS

B<openssl rand>
11
[B<-help>]
B
Bodo Möller 已提交
12
[B<-out> I<file>]
R
Rich Salz 已提交
13 14
[B<-rand file...>]
[B<-writerand file>]
B
Bodo Möller 已提交
15
[B<-base64>]
B
Bodo Möller 已提交
16
[B<-hex>]
B
Bodo Möller 已提交
17 18 19 20
I<num>

=head1 DESCRIPTION

21 22 23 24 25 26 27 28
This command generates I<num> random bytes using a cryptographically
secure pseudo random number generator (CSPRNG).

The random bytes are generated using the L<RAND_bytes(3)> function,
which provides a security level of 256 bits, provided it managed to
seed itself successfully from a trusted operating system entropy source.
Otherwise, the command will fail with a nonzero error code.
For more details, see L<RAND_bytes(3)>, L<RAND(7)>, and L<RAND_DRBG(7)>.
B
Bodo Möller 已提交
29 30 31 32 33

=head1 OPTIONS

=over 4

34 35 36 37
=item B<-help>

Print out a usage message.

R
Rich Salz 已提交
38
=item B<-out file>
B
Bodo Möller 已提交
39 40 41

Write to I<file> instead of standard output.

R
Rich Salz 已提交
42
=item B<-rand file...>
B
Bodo Möller 已提交
43

R
Rich Salz 已提交
44 45
A file or files containing random data used to seed the random number
generator.
A
Alex Gaynor 已提交
46
Multiple files can be specified separated by an OS-dependent character.
R
Richard Levitte 已提交
47
The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
B
Bodo Möller 已提交
48
all others.
49 50
Explicitly specifying a seed file is in general not necessary, see the
L</NOTES> section for more information.
B
Bodo Möller 已提交
51

R
Rich Salz 已提交
52 53 54 55 56
=item [B<-writerand file>]

Writes random data to the specified I<file> upon exit.
This can be used with a subsequent B<-rand> flag.

B
Bodo Möller 已提交
57 58 59 60
=item B<-base64>

Perform base64 encoding on the output.

B
Bodo Möller 已提交
61 62 63 64
=item B<-hex>

Show the output as a hex string.

B
Bodo Möller 已提交
65 66
=back

67 68 69 70 71 72 73 74 75 76 77 78 79
=head1 NOTES

Prior to OpenSSL 1.1.1, it was common for applications to store information
about the state of the random-number generator in a file that was loaded
at startup and rewritten upon exit. On modern operating systems, this is
generally no longer necessary as OpenSSL will seed itself from a trusted
entropy source provided by the operating system. The B<-rand>  and
B<-writerand>  flags are still supported for special platforms or
circumstances that might require them.

It is generally an error to use the same seed file more than once and
every use of B<-rand> should be paired with B<-writerand>.

B
Bodo Möller 已提交
80 81
=head1 SEE ALSO

82 83 84
L<RAND_bytes(3)>,
L<RAND(7)>,
L<RAND_DRBG(7)>
B
Bodo Möller 已提交
85

R
Rich Salz 已提交
86 87
=head1 COPYRIGHT

88
Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
R
Rich Salz 已提交
89 90 91 92 93 94 95

Licensed under the OpenSSL license (the "License").  You may not use
this file except in compliance with the License.  You can obtain a copy
in the file LICENSE in the source distribution or at
L<https://www.openssl.org/source/license.html>.

=cut