Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72921 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85192 invoked from network); 5 Mar 2014 13:15:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2014 13:15:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.160.177 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.160.177 mail-yk0-f177.google.com Received: from [209.85.160.177] ([209.85.160.177:42273] helo=mail-yk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F8/C0-15230-98327135 for ; Wed, 05 Mar 2014 08:15:54 -0500 Received: by mail-yk0-f177.google.com with SMTP id q200so2608493ykb.8 for ; Wed, 05 Mar 2014 05:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=yRcgpzALIodw3WDkTrrjA1ZUM1DJKgCj2+0sK9Nrzkw=; b=n530yadLPj6Pv7WqIOreYmrgLgDJuSqfTyZ8ClvWRESbD26lahJxBKM9AbH0D7+SaC NmOKUCEyEzbV33jVCNwkfYDRQfb2nElA4x1f4qF+5EON95zNK5drLgRfp+G3I16Epe/4 YxmOzN1AsveFKtKYLZGEPsqUY+RIL/sUv1nHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=yRcgpzALIodw3WDkTrrjA1ZUM1DJKgCj2+0sK9Nrzkw=; b=KKU0gbBkLTD3Yq/TyOBzBLh2StkorQePN4r8JAss7NNT3YsgsWzs9GI8HD6pkdaQqg sfEghzvOm5E2E/ERfzPzlRiwCGnC2dPQCpkYCS/FbfTYzcYC+jXwk1Fl2VspBlVV4wo9 DvjM8BDgNdNttdCFKsOhvDW0ON1n0G6HmWKWjlPdNGfM7sGDLr86SpKLz4MDe+mnFuwL cZzvmrx9l39aalfBQtRGqxFw2zLdTIR8ETdAjuIjUHcMStrtHrf3OGB+OqLW8NDrRA6Q AMM1EjgaZECXPndEWXDvZmPV3WutLbSXtbvUoYcNU7cveohqrkJnzWZVRXhSD/i7w9hP /XGg== X-Gm-Message-State: ALoCoQmRvBrK3HCXK6zIrodPxLO7XYeu1zm4gBDGFdNsbjzDATSD6GQGlNhL0BCfGstEC5ccn3BJ MIME-Version: 1.0 X-Received: by 10.236.133.46 with SMTP id p34mr29184yhi.157.1394025350522; Wed, 05 Mar 2014 05:15:50 -0800 (PST) Received: by 10.170.188.139 with HTTP; Wed, 5 Mar 2014 05:15:50 -0800 (PST) In-Reply-To: References: Date: Wed, 5 Mar 2014 15:15:50 +0200 Message-ID: To: Derick Rethans Cc: Nikita Popov , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Stricter error handling in mcrypt extension From: narf@devilix.net (Andrey Andreev) Yes, I'm speaking of the mcrypt_generic* functions and mcrypt_generic_init() in particular. However, without having looked at the code, I think the issue is with mcrypt_enc_get_iv_size() - it returns wrong values and mcrypt_generic_init() seems to be checking against them. On Wed, Mar 5, 2014 at 2:56 PM, Derick Rethans wrote: > 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