Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93723 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4276 invoked from network); 2 Jun 2016 17:37:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jun 2016 17:37:20 -0000 Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 77.244.243.85 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 77.244.243.85 mx104.easyname.com Received: from [77.244.243.85] ([77.244.243.85:49477] helo=mx206.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5D/76-62101-FCE60575 for ; Thu, 02 Jun 2016 13:37:19 -0400 Received: from cable-81-173-133-15.netcologne.de ([81.173.133.15] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1b8WYV-0006B1-J6; Thu, 02 Jun 2016 17:37:16 +0000 Reply-To: internals@lists.php.net References: <295c09d5-01af-1528-8e61-00dc6ee6c69e@fleshgrinder.com> To: Niklas Keller , internals@lists.php.net, Scott Arciszewski Message-ID: <52b8417d-4d23-338c-0737-562ddc7476b5@fleshgrinder.com> Date: Thu, 2 Jun 2016 19:36:59 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6kL8PujVQaE7xAVT9rbbIIcquENeIWr0s" X-ACL-Warn: X-DNSBL-BARRACUDACENTRAL Subject: Re: [PHP-DEV] [RFC] Libsodium - Discussion From: php@fleshgrinder.com (Fleshgrinder) --6kL8PujVQaE7xAVT9rbbIIcquENeIWr0s Content-Type: multipart/mixed; boundary="1ivAPO56BbLQhnMv1glCWkMKihNLk9U48" From: Fleshgrinder Reply-To: internals@lists.php.net To: Niklas Keller , internals@lists.php.net, Scott Arciszewski Message-ID: <52b8417d-4d23-338c-0737-562ddc7476b5@fleshgrinder.com> Subject: Re: [PHP-DEV] [RFC] Libsodium - Discussion References: <295c09d5-01af-1528-8e61-00dc6ee6c69e@fleshgrinder.com> In-Reply-To: --1ivAPO56BbLQhnMv1glCWkMKihNLk9U48 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 6/1/2016 9:25 PM, Niklas Keller wrote: > Why does it directly extend throwable? >=20 > Just a short node: the keys shouldn't be responsible for signing / > verification. >=20 This was not a real proposal, I only wanted to illustrate the potential for a nice OO implementation. The goal is it to make crypto simpler for userland. Well, having dedicated classes and everything type hinting against those makes it very easy. For instance nonce arguments ... $nonce =3D randombytes_buf(CRYPTO_SECRETBOX_NONCEBYTES); crypto_secretbox(... $message_nonce =3D randombytes_buf(CRYPTO_BOX_NONCEBYTES); crypto_box(... $nonce =3D randombytes_buf(CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES); crypto_aead_chacha20poly1305_encrypt(... $nonce =3D randombytes_buf(CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES)= ; crypto_aead_chacha20poly1305_ietf_encrypt(... $nonce =3D randombytes_buf(CRYPTO_AEAD_AES256GCM_NPUBBYTES); crypto_aead_aes256gcm_encrypt(... ... This is not only super annoying, it also requires you to perform the same fixtures all the time and allows users to make mistakes, e.g. reusing the same nonce. namespace Php\Sodium { class Nonce { function __construct(int $bytes); function __toString(): string; function getBytes(): int; } } namespace Php\Sodium\Asymmetric { class EncryptedMessage { function decrypt(PrivateKey $private_key): Message; function getNonce(): Nonce; } class Message { function __construct(string $plain_text); function encrypt(PublicKey $public_key): EncryptedMessage; } } Of course some of the provided stuff is not well suited for OO but those could be implemented normally as procedural functions. However, I question the names and the functionality of some. For instance: Isn't randombytes_buf() pretty much the same as random_bytes()? randombytes_uniform() has a weird name that does not really tell what it does. random_int_uniform() would be better and match the existing random_int() function. Why does randombytes_random16() even exist? It does exactly the same as randombytes_uniform(65536)? Again, I really like the goal but I don't think that the current proposal meets it. I also understand the desire to have it in 7.1 but it is the same problem as in every company: rushing is bad! Once released we're done. We cannot remove it anymore, we cannot change it anymore, we have to live with it. All because we wanted something better but too fast= =2E Let's give it some time to come up with a simpler solution that integrates nicely into existing PHP. Without confusion over functions that are doing what already existing functions to. With classes that encapsulate complicated stuff and make it hard to get things wrong. --=20 Richard "Fleshgrinder" Fussenegger --1ivAPO56BbLQhnMv1glCWkMKihNLk9U48-- --6kL8PujVQaE7xAVT9rbbIIcquENeIWr0s Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXUG6+AAoJEOKkKcqFPVVrUAcQAIYp8Ag/owix8zlo/igGCG+O 9zrO32tyv7AHCthSoCuLB7G0TleyxOXAQkgBW5cwS8kNAIXOUdT8PqsVZeWno/uo 2QiLUUUs1rHBz3ONM/9NrfBqYr0qR+e9xS3TgoOQdduw+6JsI2XTZKFMr6Ds9Grb ptitzLgKfiDWmeRFlAxiMPso8uT9j3btEfDY8ymc8/bF8WTH89ZPjfiP9BbbfbP9 +L2wU3fXC6ooD/451egTqGhPQ290AXjPeFr5hKJITWxdAM+nEX3cv1UpdDWKCEm8 A4ULzqQMQ10osvj2BTqmp6GPJhBBkUX5w6xtPM3CZTaxQZth8ntcchd1QNpvhae6 1soofm2wY0eSskBUgu3Teswn83D8oEtUmsFxGhlqk/3zJ3HimfnoTDtdNFKTlS7c /wdRYgqB7C0sCOdBLEA1MTaE3qHGFy3v9YFwEoaBZzRsqJVqYVUAdxJUiirodvFC AAMnEOoRZ6FH0ZYft0d1vv3Kw1jnpMLs4nCL7SaXczgdfePWywK8rchASwSGHe4q 3lK6K70r66nd4cY94vPHV1KliazB8lEIhctE/rzTV8lGXi6Z7lI+3/xzhHYG7bLH 013tCoTkAZlZ3ND9tBgP+XLGk7KxnqWyZO/tLDYLLPVK08SxAAvM576XZgb5vRi1 cMudxXFc3WVYLuOHIyDl =qWoE -----END PGP SIGNATURE----- --6kL8PujVQaE7xAVT9rbbIIcquENeIWr0s--