php-doc-en/reference/mcrypt/functions/mcrypt-create-iv.xml

146 lines
4 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<refentry xml:id="function.mcrypt-create-iv" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mcrypt_create_iv</refname>
<refpurpose>Create an initialization vector (IV) from a random source</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>mcrypt_create_iv</methodname>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>source</parameter><initializer>MCRYPT_DEV_RANDOM</initializer></methodparam>
</methodsynopsis>
<para>
Create an initialization vector (IV) from a random source.
</para>
<para>
The IV is only meant to give an alternative seed to the encryption
routines. This IV does not need to be secret at all, though it can be
desirable. You even can send it along with your ciphertext without
losing security.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
Determines the size of the IV, parameter <parameter>source</parameter>
(defaults to random value) specifies the source of the IV.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>source</parameter></term>
<listitem>
<para>
The source can be <constant>MCRYPT_RAND</constant> (system random
number generator), <constant>MCRYPT_DEV_RANDOM</constant> (read
data from <filename>/dev/random</filename>) and
<constant>MCRYPT_DEV_URANDOM</constant> (read data from
<filename>/dev/urandom</filename>). Prior to 5.3.0,
<constant>MCRYPT_RAND</constant> was the only one supported on Windows.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the initialization vector, or &false; on error.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.0</entry>
<entry>
<constant>MCRYPT_DEV_RANDOM</constant> and
<constant>MCRYPT_DEV_URANDOM</constant> became available on Windows
platforms.
</entry>
</row>
<row>
<entry>5.3.0</entry>
<entry>
It is no longer required to call <function>srand</function> first. This
is now done automatically.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>mcrypt_create_iv</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB);
$iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><link xlink:href="&url.mcrypt.iv;">&url.mcrypt.iv;</link></member>
<member><link xlink:href="&url.mcrypt.bcm;">&url.mcrypt.bcm;</link></member>
<member>Chapter 9.3 of Applied Cryptography by Schneier (ISBN 0-471-11709-9)</member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->