Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83903 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26503 invoked from network); 26 Feb 2015 16:12:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 16:12:23 -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 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:36554] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6F/45-32582-5E54FE45 for ; Thu, 26 Feb 2015 11:12:22 -0500 Received: by mail-vc0-f171.google.com with SMTP id kv19so4290779vcb.2 for ; Thu, 26 Feb 2015 08:12:18 -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=r+Pt/XPt+psViN8OM2GTtIb7iii0e4qbJYOg0eun0q0=; b=H+XzL9ejKSWoYnce1Bl4nWlvGpOlhBh/EroonCxCLFer7Do7XqKG/Mgv0ce+txRjvK /ULW4HWTpXu5kvSGMGc4IkYrRhZure059AP4sfzPM+PcvsZXbVl+71z7duVGOWYfxfJo v5H318TnwOhKc4ciFr04ZuCFjOday+W+xxD4cLjecwIFqnC4BuL/22FFJPpVJqwEcDTw n2QeCo1mEGq7PeQRYYcBPy0S0A6FPdNWB9mT+DBk7mx0OYExBy15kwd45QIMWWUZGkm5 +fBwZDhdAAJ5ig5rlzYn2+hVizqODMNcwfuIQ9i8m/JywftTSG5aKyjXo6zSmlJ2F6bI MQRg== MIME-Version: 1.0 X-Received: by 10.52.162.72 with SMTP id xy8mr9271475vdb.12.1424967138936; Thu, 26 Feb 2015 08:12:18 -0800 (PST) Received: by 10.52.177.10 with HTTP; Thu, 26 Feb 2015 08:12:18 -0800 (PST) In-Reply-To: References: Date: Thu, 26 Feb 2015 16:12:18 +0000 Message-ID: To: Tom Worster Cc: php-internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] crypto_something From: leight@gmail.com (Leigh) On 26 February 2015 at 15:37, Tom Worster wrote: > On 2/26/15, 3:48 AM, "Stanislav Malyshev" wrote: > >>The custom is that the first word names the function group (yes, I know >>old functions do not follow it, but this is new one). Unless we're going >>to introduce a group of functions called secure_*, random_* is a natural >>choice. > > This reminds me of the other problem. There is no one crypto lib that > is in good shape or really covers what's needed. > The problems with mcrypt have been discussed. > The limitations of OpenSSL became apparent Agree 100%. I've spoken with Anthony and a couple of others about something in the same vein as the new csprng functions. I think core needs a pair of functions that handles the needs of the 99%. Those functions are. aes_encrypt(string $data, string $key): string aes_decrypt(string $data, string $key): string I have discussed this briefly with Anthony and Nikita, and we haven't reached a consensus on whether AES-n would be determined by key-length (adding complexity for the user), or whether $key should be $passphrase and should have key-stretching performed (this would avoid the case where people pass in hex for a key), in which case we would default to AES-128. The default mode would be CTR An IV would be taken from the csprng random functions, and would be prepended to the result. A strong MAC would be calculated and appended to the result. This doesn't leave any room for interoperability where things are done differently, but it also doesn't leave any room for people to mess it up. I think it's important that when it comes to crypto, we give people the ability to "just get it right", without having to know about why something is right or wrong. I welcome any thoughts on this.