php-doc-en/reference/mcrypt/functions/mcrypt-create-iv.xml
Derick Rethans baf0dab17e - Overhaul of the mcrypt docs, including new examples, corrected entries and
newly documented functions


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@82020 c90b9560-bf6c-de11-be94-00142212c4b1
2002-05-12 21:00:20 +00:00

81 lines
2.6 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/mcrypt.xml, last change in rev 1.2 -->
<refentry id="function.mcrypt-create-iv">
<refnamediv>
<refname>mcrypt_create_iv</refname>
<refpurpose>
Create an initialization vector (IV) from a random source
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>mcrypt_create_iv</methodname>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
<methodparam><type>int</type><parameter>source</parameter></methodparam>
</methodsynopsis>
<para>
<function>mcrypt_create_iv</function> is used to create an IV.
</para>
<para>
<function>mcrypt_create_iv</function> takes two arguments,
<parameter>size</parameter> determines the size of the IV,
<parameter>source</parameter> specifies the source of the IV.
</para>
<para>
The source can be MCRYPT_RAND (system random number generator),
MCRYPT_DEV_RANDOM (read data from /dev/random) and
MCRYPT_DEV_URANDOM (read data from /dev/urandom). If you use
MCRYPT_RAND, make sure to call srand() before to initialize the
random number generator.
</para>
<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>
<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
loosing security.
</para>
<para>
More information can be found at <ulink
url="&url.mcrypt.iv;">&url.mcrypt.iv;</ulink>, <ulink
url="&url.mcrypt.bcm;">&url.mcrypt.bcm;</ulink> and in chapter 9.3 of
Applied Cryptography by Schneier (ISBN 0-471-11709-9) for a discussion of
this topic.
</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:"../../../../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
-->