1 1.1 christos =pod 2 1.1 christos {- OpenSSL::safe::output_do_not_edit_headers(); -} 3 1.1 christos 4 1.1 christos =head1 NAME 5 1.1 christos 6 1.1 christos openssl-rand - generate pseudo-random bytes 7 1.1 christos 8 1.1 christos =head1 SYNOPSIS 9 1.1 christos 10 1.1 christos B<openssl rand> 11 1.1 christos [B<-help>] 12 1.1 christos [B<-out> I<file>] 13 1.1 christos [B<-base64>] 14 1.1 christos [B<-hex>] 15 1.1 christos {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_r_synopsis -} 16 1.1 christos {- $OpenSSL::safe::opt_provider_synopsis -} 17 1.1 christos I<num>[K|M|G|T] 18 1.1 christos 19 1.1 christos =head1 DESCRIPTION 20 1.1 christos 21 1.1 christos This command generates I<num> random bytes using a cryptographically 22 1.1 christos secure pseudo random number generator (CSPRNG). A suffix [K|M|G|T] may be 23 1.1 christos appended to the num value to indicate the requested value be scaled as a 24 1.1 christos multiple of KiB/MiB/GiB/TiB respectively. Note that suffixes are case 25 1.1 christos sensitive, and that the suffixes represent binary multiples 26 1.1 christos (K = 1024 bytes, M = 1024*1024 bytes, etc). 27 1.1 christos 28 1.1 christos The string 'max' may be substituted for a numerical value in num, to request the 29 1.1 christos maximum number of bytes the CSPRNG can produce per instantiation. Currently, 30 1.1 christos this is restricted to 2^61 bytes as per NIST SP 800-90C. 31 1.1 christos 32 1.1 christos The random bytes are generated using the L<RAND_bytes(3)> function, 33 1.1 christos which provides a security level of 256 bits, provided it managed to 34 1.1 christos seed itself successfully from a trusted operating system entropy source. 35 1.1 christos Otherwise, the command will fail with a nonzero error code. 36 1.1 christos For more details, see L<RAND_bytes(3)>, L<RAND(7)>, and L<EVP_RAND(7)>. 37 1.1 christos 38 1.1 christos =head1 OPTIONS 39 1.1 christos 40 1.1 christos =over 4 41 1.1 christos 42 1.1 christos =item B<-help> 43 1.1 christos 44 1.1 christos Print out a usage message. 45 1.1 christos 46 1.1 christos =item B<-out> I<file> 47 1.1 christos 48 1.1 christos Write to I<file> instead of standard output. 49 1.1 christos 50 1.1 christos =item B<-base64> 51 1.1 christos 52 1.1 christos Perform base64 encoding on the output. 53 1.1 christos 54 1.1 christos =item B<-hex> 55 1.1 christos 56 1.1 christos Show the output as a hex string. 57 1.1 christos 58 1.1 christos {- $OpenSSL::safe::opt_engine_item -} 59 1.1 christos 60 1.1 christos {- $OpenSSL::safe::opt_r_item -} 61 1.1 christos 62 1.1 christos {- $OpenSSL::safe::opt_provider_item -} 63 1.1 christos 64 1.1 christos =back 65 1.1 christos 66 1.1 christos =head1 SEE ALSO 67 1.1 christos 68 1.1 christos L<openssl(1)>, 69 1.1 christos L<RAND_bytes(3)>, 70 1.1 christos L<RAND(7)>, 71 1.1 christos L<EVP_RAND(7)> 72 1.1 christos 73 1.1 christos =head1 HISTORY 74 1.1 christos 75 1.1 christos The B<-engine> option was deprecated in OpenSSL 3.0. 76 1.1 christos 77 1.1 christos =head1 COPYRIGHT 78 1.1 christos 79 1.1 christos Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 80 1.1 christos 81 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 82 1.1 christos this file except in compliance with the License. You can obtain a copy 83 1.1 christos in the file LICENSE in the source distribution or at 84 1.1 christos L<https://www.openssl.org/source/license.html>. 85 1.1 christos 86 1.1 christos =cut 87