Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81591 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42903 invoked from network); 2 Feb 2015 15:44:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 15:44:08 -0000 Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-we0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:63416] helo=mail-we0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 58/61-34915-84B9FC45 for ; Mon, 02 Feb 2015 10:44:08 -0500 Received: by mail-we0-f170.google.com with SMTP id w55so34370980wes.1 for ; Mon, 02 Feb 2015 07:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ElDlDilAzU9U/iVZu804P64SesqDoeT+sNaI5ZkSpGA=; b=Z2/iw/sOL7LGbq56B6gSrgszDztjK5+lg9tEr4s91HD3AyERNslvXH6rm0zgriOLc/ 6GdUg9fLb7skwG2/uFsXWZR9jnAbBQbcmQdVn508KwnfZ+B0qioUT2xZF78nAmxWubbo efnHi0pgQiMiaUZah13ojkh/qe6k6CkZPIv4Bu+/eibv4yXO9+DOjEP/CcQ2I+9Wllmj AaLbs9hJzc4O0mEFxjvDHVIpMGGn1PHU645L39b4YWaOQYNrfiYSUd7Iia0jOThfdn9d z++pmJQPlWEmsdx1xuI6NNECcXvB6F1pl16b7AlvcJN0Hu1MqY5Ry67zKVOt/UFjhwMj pvXg== MIME-Version: 1.0 X-Received: by 10.180.5.131 with SMTP id s3mr25762981wis.82.1422891845299; Mon, 02 Feb 2015 07:44:05 -0800 (PST) Received: by 10.216.50.139 with HTTP; Mon, 2 Feb 2015 07:44:05 -0800 (PST) In-Reply-To: References: Date: Mon, 2 Feb 2015 15:44:05 +0000 Message-ID: To: Daniel Lowrey Cc: "internals@lists.php.net" , Jakub Zelenka Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: OpenSSL ext. improvements for authenticated cipher modes. From: leight@gmail.com (Leigh) On 2 February 2015 at 14:30, Daniel Lowrey wrote: >> The extra params aren't really _that_ bad. > > Okay, I'd like to reset the conversation a bit here. It's clear that the > current API does not fit the problem domain very well. Tacking on more > parameters only creates a bigger mess. Six parameters to a stateless > function call is a completely incoherent API. It's unusable without > consulting the manual. I think we need a completely different approach. Let > me propose something else that won't break BC in any release and results in > an API that's actually sane: > > class CryptoContext { > private $mode; > private $password; > function __construct($mode, $password) { > $this->mode = $mode; > $this->password = $password; > } > function encrypt($data) { > // ... > return $encryptedData; > } > function decrypt($data) { > // ... > return $decryptedData; > } > function setOption($option, $value) { > // ... > } > // more methods here to do anything you need > } > > Thoughts on a stateful object API here? Personally I find this much more > coherent than anything that's been proposed so far and it could be > implemented without affecting existing functionality. I'd really love to move to a context based crypto API. I'd go one further and say I'd really love to see an extensible crypto API, where extensions could provide ciphers or modes not available in core. That works for me going forward, but I'd still like a solution that can go into 5.x