Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36279 invoked from network); 31 Jan 2015 16:13:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2015 16:13:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=jason.gerfen@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=jason.gerfen@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.173 as permitted sender) X-PHP-List-Original-Sender: jason.gerfen@gmail.com X-Host-Fingerprint: 209.85.213.173 mail-ig0-f173.google.com Received: from [209.85.213.173] ([209.85.213.173:59418] helo=mail-ig0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/03-16633-34FFCC45 for ; Sat, 31 Jan 2015 11:13:56 -0500 Received: by mail-ig0-f173.google.com with SMTP id a13so9747134igq.0 for ; Sat, 31 Jan 2015 08:13:52 -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=xMVwmxcqkymCEZ3an/idZE6AQrXcabnI8Aap7vUviN8=; b=zD2TW1HEkhCUk5Yd6I4EALcqqRMfu6gRRznjb9geLJe3mTgsKJtGR0iYg/GIIQhglW t24LNnuB2Gq6m27SVtGPfY8VNnpaUEaUZKdiO5FeGr3ukM44dKqrv5/cySU4J6KMV/i5 wpnwNxxb8juDse6QrcCTIynfYh0OHLgRLLaPBXakivmzxBELmVPKt/CR2Bojx9uI2uzc VSiD89ThYLm37Gs/8Eye6MkDQrcCLFTOax9NSYSEVDONAGulXIoy/d5ASqR56iGs/Tns G/qQtC7sNwvVxZOu5pb4F4/foPSuXsPoT301WN0ISG0KHhwwoC3F9dbVUYzD0Tp4B6vg WIjA== MIME-Version: 1.0 X-Received: by 10.43.79.129 with SMTP id zq1mr11445458icb.28.1422720832846; Sat, 31 Jan 2015 08:13:52 -0800 (PST) Received: by 10.64.26.200 with HTTP; Sat, 31 Jan 2015 08:13:52 -0800 (PST) In-Reply-To: References: Date: Sat, 31 Jan 2015 09:13:52 -0700 Message-ID: To: Leigh Cc: PHP internals Content-Type: multipart/alternative; boundary=001a11332018db40ee050df50103 Subject: Re: [PHP-DEV] OpenSSL ext. improvements for authenticated cipher modes. From: jason.gerfen@gmail.com (Jason Gerfen) --001a11332018db40ee050df50103 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Jan 31, 2015 at 8:53 AM, Leigh wrote: > Hi list, > > A couple of bug reports have highlighted the fact that our > openssl_encrypt and openssl_decrupt functions have no way of getting > or setting tags required for authenticated cipher modes (i.e. GCM, > CCM, OCB (not sure if this is available in OpenSSL)). > > https://bugs.php.net/bug.php?id=3D68962 > https://bugs.php.net/bug.php?id=3D67304 > > Further to this, we have no way of setting any associated data. > > I think we absolutely must provide a method for users to be able to > use authenticated encryption, and would like some opinions on how much > flexibility we give users, and the best method for exposing this > functionality. > > At the very basic end of the spectrum, we could have openssl_get_tag > and openssl_set_tag, or add an extra parameter to the end of > openssl_encrypt and openssl_decrypt (pass by ref for encrypt, like > preg $matches) this would cover the majority of use cases. > > =E2=80=8BI think exposing this to the user will only cause confusion and al= low users to implement mistakes to the algorithm and mode usage.=E2=80=8B > However I absolutely think that the associated data also needs to be > supported, and possibly the ability to change the tag length. > > At this point we're starting to get into the territory where an > $options array is needed, or we add a lot of parameters to the end of > functions. I don't really think it's good to add up to 3 more params > to these functions. > > What do you guys and girls think is the best way of tackling this? > > Cheers, > > Leigh. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > According to the OpenSSL documentation regarding encryption/decryption using CCM, GCM & OCB modes for authenticated usage would require the additions of the following constants: EVP_CTRL_OCB_SET_TAGLEN EVP_CTRL_SET_IVLEN EVP_CTRL_GET_TAG EVP_CTRL_CCM_SET_L EVP_CTRL_CCM_SET_IVLEN EVP_aes_256_gcm() EVP_aes_128_gcm() =E2=80=8B =E2=80=8BThat coupled with the use of the =E2=80=8B EVP_CIPHER_CTX_ctrl() =E2=80=8Bshould provide the needed functionality =E2=80=8Bas described in http://wiki.openssl.org/index.php/EVP_Authenticated_Encryption_and_Decrypti= on the documentation for using the EVP authenticated modes for encryption/decryption. --001a11332018db40ee050df50103--