Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81536 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10841 invoked from network); 1 Feb 2015 17:57:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2015 17:57:09 -0000 Authentication-Results: pb1.pair.com header.from=jakub.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=jakub.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.179 as permitted sender) X-PHP-List-Original-Sender: jakub.php@gmail.com X-Host-Fingerprint: 209.85.213.179 mail-ig0-f179.google.com Received: from [209.85.213.179] ([209.85.213.179:39766] helo=mail-ig0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/D1-33325-3F86EC45 for ; Sun, 01 Feb 2015 12:57:08 -0500 Received: by mail-ig0-f179.google.com with SMTP id l13so12598180iga.0 for ; Sun, 01 Feb 2015 09:57:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=ciCzWKMv+mXkN5OOzHfKLpqdRjoKgn2ETIlBe5+ayH0=; b=Vv32k+9ToJW9UFEPq7qhQyPadXTOMk+VljTl8CanTnLiIg+75R5ShXlZdaB8KxBMF6 D3ST/yuEJIgtjmw0Hrb4y1nQuAX48DLk6D7PKJ1B6ulGqcQdYo4tiZQ3uiWii99HPb4a 8v826KapapdhD49tIYyKDNa4bTot9UHOJL6iJvibniLUbnUYY1GvK9vBgO8wZrlbwKZP /EOby+dFkolFzyVjcHwz9Cjm0JoNSr4UfQ0hRV+f1vXvFNwQ2DsohKQjsv/h/Rbr4uDA D41R4hKl6aRR5EltPoAnN4RXJMc2WIFYI8yLApWhPpJxUPheBwshccddLQkFC9VOKNeC TbVg== MIME-Version: 1.0 X-Received: by 10.42.235.80 with SMTP id kf16mr15561813icb.18.1422813424883; Sun, 01 Feb 2015 09:57:04 -0800 (PST) Sender: jakub.php@gmail.com Received: by 10.107.55.8 with HTTP; Sun, 1 Feb 2015 09:57:04 -0800 (PST) In-Reply-To: References: Date: Sun, 1 Feb 2015 17:57:04 +0000 X-Google-Sender-Auth: 8L5VL29pfXZ8nJfOP-8pBpCdZxk Message-ID: To: Leigh Cc: Jason Gerfen , PHP internals Content-Type: multipart/alternative; boundary=20cf302667fcc59e9f050e0a90a0 Subject: Re: [PHP-DEV] OpenSSL ext. improvements for authenticated cipher modes. From: bukka@php.net (Jakub Zelenka) --20cf302667fcc59e9f050e0a90a0 Content-Type: text/plain; charset=UTF-8 Hey On Sat, Jan 31, 2015 at 4:21 PM, Leigh wrote: > On 31 January 2015 at 16:13, Jason Gerfen wrote: > > On Sat, Jan 31, 2015 at 8:53 AM, Leigh wrote: > >> 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. > >> > > > > I think exposing this to the user will only cause confusion and allow > users > > to implement mistakes to the algorithm and mode usage. > > > > set/get tag functions are alto my least favourite options. > > > > > 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() > > > > That coupled with the use of the > > > > EVP_CIPHER_CTX_ctrl() > > > > should provide the needed functionality as described in > > > http://wiki.openssl.org/index.php/EVP_Authenticated_Encryption_and_Decryption > > the documentation for using the EVP authenticated modes for > > encryption/decryption. > > > > Thanks, I have done some cursory research into how it should be > implemented, but I wanted this discussion to be about how we should > present the functionality to the user. Implementation details can come > second once we have a consensus on what is/isn't too much, and what > method we should use to allow this functionality to be used. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Hey, I have already implemented all of this in crypto ext ( https://github.com/bukka/php-crypto ) and also added support for streams (e.g. https://github.com/bukka/php-crypto/blob/master/tests/stream_filters_cipher_gcm_dec_read.phpt ) and objective context. However crypto is and probably quite some time will be in the dev stability. I have put that work on hold for some time (due to php 7 api changes) but plan to resume it soon. Anyway this is a bit different as it is a bit more complex and bit too much for openssl ext. The thing is that the symmetric cypto functions are just openssl_encrypt and openssl_decrypt and they don't have any context. I'm not sure how the proposed openssl_*et_tag would work without context. The options array makes definitely more sense to me. It's basically what I used for stream context ( some doc can be found here: https://github.com/bukka/php-crypto/issues/8 ). The only problem is how to get the resulted tag. I used stream meta array for that in crypto streams. If we don't want to break BC, then we would probably need another ref param openssl_encrypt. Something like: string openssl_encrypt ( string $data , string $method , string $password [, mixed $options = NULL [, string $iv = "" [, string &$tag = NULL ] ] ] ) The options would be overloaded for BC (if it's int, then the same as before or you can use array for further options as AAD...). What's you thoughts? Btw. I think I could do or help with the implementation if there is an interest in that feature in PHP 7 . It would be sort of port from crypto where I also have bunch of test for that (supported are just ccm and gcm). Cheers --20cf302667fcc59e9f050e0a90a0--