2020-03-02 16:50:34 +00:00
|
|
|
<?xml version="1.0" ?>
|
|
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<head>
|
|
|
|
<title>RAND_bytes</title>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
|
|
|
<link rev="made" href="mailto:root@localhost" />
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body style="background-color: white">
|
|
|
|
|
|
|
|
|
|
|
|
<!-- INDEX BEGIN -->
|
|
|
|
<div name="index">
|
|
|
|
<p><a name="__index__"></a></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li><a href="#name">NAME</a></li>
|
|
|
|
<li><a href="#synopsis">SYNOPSIS</a></li>
|
|
|
|
<li><a href="#description">DESCRIPTION</a></li>
|
|
|
|
<li><a href="#notes">NOTES</a></li>
|
|
|
|
<li><a href="#return_values">RETURN VALUES</a></li>
|
|
|
|
<li><a href="#see_also">SEE ALSO</a></li>
|
|
|
|
<li><a href="#history">HISTORY</a></li>
|
|
|
|
<li><a href="#copyright">COPYRIGHT</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<hr name="index" />
|
|
|
|
</div>
|
|
|
|
<!-- INDEX END -->
|
|
|
|
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="name">NAME</a></h1>
|
2020-03-02 17:19:21 +00:00
|
|
|
<p>RAND_bytes, RAND_priv_bytes, RAND_pseudo_bytes - generate random data</p>
|
2020-03-02 16:50:34 +00:00
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="synopsis">SYNOPSIS</a></h1>
|
|
|
|
<pre>
|
|
|
|
#include <openssl/rand.h></pre>
|
|
|
|
<pre>
|
|
|
|
int RAND_bytes(unsigned char *buf, int num);
|
|
|
|
int RAND_priv_bytes(unsigned char *buf, int num);</pre>
|
2020-03-02 17:19:21 +00:00
|
|
|
<p>Deprecated:</p>
|
2020-03-02 16:50:34 +00:00
|
|
|
<pre>
|
2020-03-02 17:19:21 +00:00
|
|
|
#if OPENSSL_API_COMPAT < 0x10100000L
|
|
|
|
int RAND_pseudo_bytes(unsigned char *buf, int num);
|
|
|
|
#endif</pre>
|
2020-03-02 16:50:34 +00:00
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="description">DESCRIPTION</a></h1>
|
|
|
|
<p><code>RAND_bytes()</code> puts <strong>num</strong> cryptographically strong pseudo-random bytes
|
|
|
|
into <strong>buf</strong>.</p>
|
|
|
|
<p><code>RAND_priv_bytes()</code> has the same semantics as <code>RAND_bytes()</code>. It is intended to
|
|
|
|
be used for generating values that should remain private. If using the
|
|
|
|
default RAND_METHOD, this function uses a separate "private" PRNG
|
|
|
|
instance so that a compromise of the "public" PRNG instance will not
|
|
|
|
affect the secrecy of these private values, as described in <em>RAND(7)</em>
|
|
|
|
and <em>RAND_DRBG(7)</em>.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="notes">NOTES</a></h1>
|
|
|
|
<p>Always check the error return value of <code>RAND_bytes()</code> and
|
|
|
|
<code>RAND_priv_bytes()</code> and do not take randomness for granted: an error occurs
|
|
|
|
if the CSPRNG has not been seeded with enough randomness to ensure an
|
|
|
|
unpredictable byte sequence.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="return_values">RETURN VALUES</a></h1>
|
|
|
|
<p><code>RAND_bytes()</code> and <code>RAND_priv_bytes()</code>
|
|
|
|
return 1 on success, -1 if not supported by the current
|
|
|
|
RAND method, or 0 on other failure. The error code can be
|
|
|
|
obtained by <em>ERR_get_error(3)</em>.</p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="see_also">SEE ALSO</a></h1>
|
|
|
|
<p><em>RAND_add(3)</em>,
|
|
|
|
<em>RAND_bytes(3)</em>,
|
|
|
|
<em>RAND_priv_bytes(3)</em>,
|
|
|
|
<em>ERR_get_error(3)</em>,
|
|
|
|
<em>RAND(7)</em>,
|
|
|
|
<em>RAND_DRBG(7)</em></p>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="history">HISTORY</a></h1>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<p><code>RAND_pseudo_bytes()</code> was deprecated in OpenSSL 1.1.0; use <code>RAND_bytes()</code> instead.</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>The <code>RAND_priv_bytes()</code> function was added in OpenSSL 1.1.1.</p>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p>
|
|
|
|
</p>
|
|
|
|
<hr />
|
|
|
|
<h1><a name="copyright">COPYRIGHT</a></h1>
|
|
|
|
<p>Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.</p>
|
2020-03-02 17:19:21 +00:00
|
|
|
<p>Licensed under the OpenSSL license (the "License"). You may not use
|
2020-03-02 16:50:34 +00:00
|
|
|
this file except in compliance with the License. You can obtain a copy
|
|
|
|
in the file LICENSE in the source distribution or at
|
|
|
|
<a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|