php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Sec Bug #66050 Length units not documented.
Submitted: 2013-11-07 18:19 UTC Modified: 2013-12-09 11:18 UTC
From: havoc at defuse dot ca Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.5.5 OS: Everything
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: havoc at defuse dot ca
New email:
PHP Version: OS:

 

 [2013-11-07 18:19 UTC] havoc at defuse dot ca
Description:
------------
---
From manual page: http://www.php.net/function.hash-pbkdf2#refsect1-function.hash-pbkdf2-parameters
---

The units that the length parameter is in is not documented. It's nibbles if $raw_output is true, and bytes otherwise. That needs to be documented in the length parameter section AND in one of those red warning things. I've already seen someone pass the byte count they wanted with raw_output set to false, making their application use 64-bit keys instead of 128-bit keys. That is a huge security problem and I expect many more people will screw it up. It NEEDS to be documented CLEARLY.

This definition of the length parameter actually violates the PBKDF2 specification, since the RFC formally defines the length parameter to be the number of bytes, not bits or nibbles.

Test script:
---------------
<?php
  // http://www.ietf.org/rfc/rfc6070.txt
  // this should output: 
  // DK = ea 6c 01 4d c7 2d 6f 8c
  //        cd 1e d9 2a ce 1d 41 f0
  //        d8 de 89 57             (20 octets)

  echo hash_pbkdf2("sha1", "password", "salt", 2, 20, false);
  // actual: ea6c014dc72d6f8ccd1e
?>

Expected result:
----------------
The documentation should make it very clear that the length parameter is either bytes or nibbles depending on the raw_output parameter.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-09 11:18 UTC] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2013-12-09 11:18 UTC] krakjoe@php.net
Having discussed it, the behaviour of the length parameter is sufficiently documented we think, since you will have a good idea of what the function is for before you use it; the current description of behaviour tells you all you need to know.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 20:01:29 2024 UTC