#51146 [NEW]: mcrypt doesn't do OFB mode correctly

From: Date: Thu, 25 Feb 2010 18:01:52 +0000
Subject: #51146 [NEW]: mcrypt doesn't do OFB mode correctly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148050@lists.php.net to get a copy of this message
From:             zelnaga at gmail dot com
Operating system: Windows XP
PHP version:      5.3.1
PHP Bug Type:     mcrypt related
Bug description:  mcrypt doesn't do OFB mode correctly

Description:
------------
Correct me if I'm wrong, but shouldn't an ECB decryption of an OFB
encrypted string of null bytes produce a string whose first eight bytes
(assuming that that's the block size) are equal to the IV?  Certainly
that's the impression I get from wikipedia.org's discussion of OFB.

http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29



Reproduce code:
---------------
<?php
$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_OFB, '');
mcrypt_generic_init($td, 'aaaaaaaa', 'bbbbbbbb');
$ciphertext = mcrypt_generic($td, "\0\0\0\0\0\0\0\0");

$td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
mcrypt_generic_init($td, 'aaaaaaaa', "\0\0\0\0\0\0\0\0");
echo urlencode(mdecrypt_generic($td, $ciphertext));
?>

Expected result:
----------------
bbbbbbbb

Actual result:
--------------
5%FBdq%C7Y7%13

-- 
Edit bug report at http://bugs.php.net/?id=51146&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51146&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51146&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51146&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51146&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51146&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51146&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51146&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51146&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51146&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51146&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51146&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51146&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51146&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51146&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51146&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51146&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51146&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51146&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51146&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51146&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51146&r=mysqlcfg



Thread (18 messages)

« previous php.bugs (#148050) next »