Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72920 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83261 invoked from network); 5 Mar 2014 12:56:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2014 12:56:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:45530] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DB/60-15230-AEE17135 for ; Wed, 05 Mar 2014 07:56:11 -0500 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 62EF0E203D; Wed, 5 Mar 2014 12:56:07 +0000 (GMT) Date: Wed, 5 Mar 2014 12:56:07 +0000 (GMT) X-X-Sender: derick@whisky.home.derickrethans.nl To: Nikita Popov cc: Andrey Andreev , "internals@lists.php.net" In-Reply-To: Message-ID: References: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Stricter error handling in mcrypt extension From: derick@php.net (Derick Rethans) On Wed, 5 Mar 2014, Nikita Popov wrote: > On Tue, Mar 4, 2014 at 9:32 PM, Andrey Andreev wrote: > > > Speaking of bugs in MCrypt and IVs ... in ECB mode it complains if > > you don't pass an IV, even though it is ignored afterwards. > > You're probably referring to mcrypt_generic here, rather than > mcrypt_encrypt. I can bring that function in line with mcrypt_encrypt, > i.e. add the same error checks and make the IV only required if the > mode requires it. > > However I'm not sure what kind of return value I should use with this > function. Currently it returns a long result, which is 0 on success > and a negative number on error. However mcrypt does not define error > codes for all possible error conditions, e.g. while it has a code for > invalid key sizes, it doesn't have a code for invalid IV sizes. > > Personally I'd just switch it to true/false for success/error, as the > warnings already tell you what kind of error occurred. Would that be > okay with you, Derick? No - as that is a BC break of a deliberate (though crappy ;-)) API. The result values of mcrypt_generic_init() (which is I think what you're refering too) are documented too: The function returns a negative value on error: -3 when the key length was incorrect, -4 when there was a memory allocation problem and any other return value is an unknown error. If an error occurs a warning will be displayed accordingly. FALSE is returned if incorrect parameters were passed. cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug Posted with an email client that doesn't mangle email: alpine