Re: openssl_(en|de)crypt missing IV
| From: | Pierre Joye | Date: | Tue, 18 May 2010 06:41:52 +0000 |
| Subject: | Re: openssl_(en|de)crypt missing IV | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-48307@lists.php.net to get a copy of this message | ||
hi Sara,
On Tue, May 18, 2010 at 3:53 AM, Sara Golemon <pollita@php.net> wrote:
> I was just looking through the implementation of openssl_encrypt() (and
> openssl_decrypt()) today because I need to make some encrypted payloads, but
> the prototype didn't have anywhere to place an initialization vector.
>
> On opening ext/openssl/openssl.c, I noticed line 4620 which simply hardcodes
> IV as a string of NULL bytes.
>
> This is a bad idea roughly equivalent to hashing passwords without salt;
> Worse, it prevents interoperability at the application layer by preventing
> the decryption of a data stream where the generator used an IV other than
> all-null.
>
> Fixing this is a simple matter, but I wanted to bounce approaches for BC (or
> lack thereof) off everyone else since this version of openssl_encrypt() is
> already "in the wild".
> I think it's worth a BC break. Comments?
To break BC is a no go, even if your arguments are appealing (even in
a major version).
I would suggest a new function:
openssl_encrypt_iv($data, $method, $key, $iv, $raw=false);
Which will use the same internal implementations internally but with a
different entry point. please note that I moved iv to the 4th position
as well.
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org