svn: /phpdoc/en/trunk/reference/hash/ functions/hash-equals.xml versions.xml

From: Date: Mon, 25 Aug 2014 20:17:58 +0000
Subject: svn: /phpdoc/en/trunk/reference/hash/ functions/hash-equals.xml versions.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-12728@lists.php.net to get a copy of this message
salathe Mon, 25 Aug 2014 20:17:58 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=334601 Log: initial hash_equals() page Changed paths: A phpdoc/en/trunk/reference/hash/functions/hash-equals.xml U phpdoc/en/trunk/reference/hash/versions.xml Added: phpdoc/en/trunk/reference/hash/functions/hash-equals.xml =================================================================== --- phpdoc/en/trunk/reference/hash/functions/hash-equals.xml (rev 0) +++ phpdoc/en/trunk/reference/hash/functions/hash-equals.xml 2014-08-25 20:17:58 UTC (rev 334601) @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision$ --> + +<refentry xml:id="function.hash-equals" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> + <refnamediv> + <refname>hash_equals</refname> + <refpurpose>Timing attack safe string comparison</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>bool</type><methodname>hash_equals</methodname> + <methodparam><type>string</type><parameter>known_string</parameter></methodparam> + <methodparam><type>string</type><parameter>user_string</parameter></methodparam> + </methodsynopsis> + <para> + Compares two strings using the same time whether they're equal or not. + </para> + <para> + This function should be used to mitigate timing attacks; for instance, + when testing <function>crypt</function> password hashes. + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <variablelist> + <varlistentry> + <term><parameter>known_string</parameter></term> + <listitem> + <para> + The <type>string</type> of known length to compare against + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>user_string</parameter></term> + <listitem> + <para> + The user-supplied string + </para> + </listitem> + </varlistentry> + </variablelist> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + Returns &true; when the two strings are equal, &false; otherwise. + </para> + </refsect1> + + <refsect1 role="errors"> + &reftitle.errors; + <para> + Emits an <constant>E_WARNING</constant> message when either of the + supplied parameters is not a string. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example xml:id="foobar.examples.basic"> + <title><methodname></methodname> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$expected = crypt('12345', '$2a$07$usesomesillystringforsalt$'); +$correct = crypt('12345', '$2a$07$usesomesillystringforsalt$'); +$incorrect = crypt('apple', '$2a$07$usesomesillystringforsalt$'); + +var_dump(hash_equals($expected, $correct)); +var_dump(hash_equals($expected, $incorrect)); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +bool(true) +bool(false) +]]> + </screen> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + Both arguments must be of the same length to be compared successfully. + When arguments of differing length are supplied, &false; is returned. + </para> + </note> + <note> + <para> + It is important to provide the user-supplied string as the second + parameter, rather than the first. + </para> + </note> + </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 +--> Property changes on: phpdoc/en/trunk/reference/hash/functions/hash-equals.xml ___________________________________________________________________ Added: svn:keywords + Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL Added: svn:eol-style + native Modified: phpdoc/en/trunk/reference/hash/versions.xml =================================================================== --- phpdoc/en/trunk/reference/hash/versions.xml 2014-08-25 17:00:30 UTC (rev 334600) +++ phpdoc/en/trunk/reference/hash/versions.xml 2014-08-25 20:17:58 UTC (rev 334601) @@ -7,6 +7,7 @@ <function name='hash' from='PHP 5 &gt;= 5.1.2, PECL hash &gt;= 1.1'/> <function name='hash_algos' from='PHP 5 &gt;= 5.1.2, PECL hash &gt;= 1.1'/> <function name='hash_copy' from='PHP 5 &gt;= 5.3.0'/> + <function name='hash_equals' from='PHP 5 &gt;= 5.6.0'/> <function name='hash_file' from='PHP 5 &gt;= 5.1.2, PECL hash &gt;= 1.1'/> <function name='hash_final' from='PHP 5 &gt;= 5.1.2, PECL hash &gt;= 1.1'/> <function name='hash_hmac' from='PHP 5 &gt;= 5.1.2, PECL hash &gt;= 1.1'/>

« previous php.doc.cvs (#12728) next »