Req #66650 [Com]: Support for CTR mode
| From: | narf at devilix dot net | Date: | Thu, 06 Mar 2014 11:55:03 +0000 |
| Subject: | Req #66650 [Com]: Support for CTR mode | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-184557@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66650&edit=1
ID: 66650
Comment by: narf at devilix dot net
Reported by: clicky at erebot dot net
Summary: Support for CTR mode
Status: Open
Type: Feature/Change Request
Package: mcrypt related
Operating System: Any
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
You can use ctr mode by just passing 'ctr' to mcrypt_encrypt(). All of the MCRYPT_MODE_*
constants just define strings and are not actually necessary. In fact they don't help you with
anything.
MCRYPT_MODE_CBC = 'cbc'
MCRYPT_MODE_ECB = 'ecb'
etc.
I'd rather suggest to deprecate usage of the MCRYPT_MODE_* constants.
Previous Comments:
------------------------------------------------------------------------
[2014-02-05 21:36:23] clicky at erebot dot net
Description:
------------
Please add support for the CTR encryption mode (MCRYPT_MODE_CTR).
See also attached patch against PHP 5.5.x which adds the necessary code and also defines a
deprecated function mcrypt_ctr() (for consistency with other modes).
Test script:
---------------
<?php
$key = "FooBar";
$secret = "PHP Testfest 2008";
$cipher = MCRYPT_RIJNDAEL_128;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher, MCRYPT_MODE_CTR), MCRYPT_RAND);
$enc_data = mcrypt_ctr($cipher, $key, $secret, MCRYPT_ENCRYPT, $iv);
var_dump(bin2hex($enc_data));
?>
Expected result:
----------------
string(34) "5e42855e8236dacdb8fafbdaa12d176f13"
Actual result:
--------------
Bunch of errors due to lack of MCRYPT_MODE_CTR constant and undefined function mcrypt_ctr().
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66650&edit=1