
#use wml::openssl-macros area=docs page=RAND_load_file

<title>Documents, RAND_load_file(3)</title>

<h1>RAND_load_file(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
RAND_load_file, RAND_write_file, RAND_file_name - PRNG seed file

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/rand.h&gt;
</PRE>
<PRE> const char *RAND_file_name(char *buf, size_t num);
</PRE>
<PRE> int RAND_load_file(const char *filename, long max_bytes);
</PRE>
<PRE> int RAND_write_file(const char *filename);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
<CODE>RAND_file_name()</CODE> generates a default path for the random seed
file. <STRONG>buf</STRONG> points to a buffer of size <STRONG>num</STRONG> in which to store the filename. The seed file is <CODE>$RANDFILE</CODE> if
that environment variable is set, $HOME/.rnd otherwise. If
<CODE>$HOME</CODE> is not set either, or <STRONG>num</STRONG> is too small for the path name, an error occurs.

</P>
<P>
<CODE>RAND_load_file()</CODE> reads a number of bytes from file <STRONG>filename</STRONG> and adds them to the PRNG. If <STRONG>max_bytes</STRONG> is non-negative, up to to <STRONG>max_bytes</STRONG> are read; starting with OpenSSL 0.9.5, if <STRONG>max_bytes</STRONG> is -1, the complete file is read.

</P>
<P>
<CODE>RAND_write_file()</CODE> writes a number of random bytes (currently
1024) to file <STRONG>filename</STRONG> which can be used to initialize the PRNG by calling
<CODE>RAND_load_file()</CODE> in a later session.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>RAND_load_file()</CODE> returns the number of bytes read.

</P>
<P>
<CODE>RAND_write_file()</CODE> returns the number of bytes written, and -1
if the bytes written were generated without appropriate seed.

</P>
<P>
<CODE>RAND_file_name()</CODE> returns a pointer to <STRONG>buf</STRONG> on success, and NULL on error.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/rand.html#">rand(3)</A>, <A HREF="../crypto/RAND_add.html#">RAND_add(3)</A>, <A HREF="../crypto/RAND_cleanup.html#">RAND_cleanup(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>RAND_load_file(),</CODE> <CODE>RAND_write_file()</CODE> and
<CODE>RAND_file_name()</CODE> are available in all versions of SSLeay and
OpenSSL.

</P>
:}

