Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118302 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74423 invoked from network); 25 Jul 2022 10:25:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Jul 2022 10:25:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E1EB21804AB; Mon, 25 Jul 2022 05:23:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS; Mon, 25 Jul 2022 05:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1658751804; bh=ApEg2wkJDnDv3Rl1WT67cLWfVTj1VdIA9C/uTuwHthw=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=Aa9tFTaRPju5MwUoEOcYylUghViFTG/KflUj6WYghXuw9tGBkTO8qBypYOpfKweD9 f+QZWjkz0HDTxv1pPL78Sv3OR45GOeGs1dxKU0qvGbpiBdNi+n20o0bQtif2caEOqr s/InTdOpZbeoL5LRa+s+bWM7Ex7JhpHQqwP06cO0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([79.220.70.20]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MKbg4-1nv7Pb3XBs-00L1Pu; Mon, 25 Jul 2022 14:23:23 +0200 Message-ID: <76f9b0be-85c1-5f09-3034-b4dc6f9cf22e@gmx.de> Date: Mon, 25 Jul 2022 14:23:23 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: de-DE To: Jakub Zelenka , Go Kudo Cc: =?UTF-8?Q?Tim_D=c3=bcsterhus?= , PHP internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:yXgp7BD+s1DjkuYVIJrJ5KxVMkPh71KzabnBHI5iFDVG2R0gK+I uDY2PxvCigAHfcCUgzG2p0SGOeEvC8JSBjhKd/BaSYamAqcHklrI4oIzQpab/X77eS3XbcE PDb0OYKJCFMr58ewsAq/wymREQOSCrBLl++WeJTJRO7s+ePTZO6oGAqj/Q2d/SJnKkPHZaO wqF6+dAGp2l1aKM7edppw== X-UI-Out-Filterresults: notjunk:1;V03:K0:wcUpqv5Ppm8=:s6U8mIpi6C6qWzUhZwBn27 6aQ0NVocIn6MkQ0sjwy4h4iEjPws9SPcP1hIbJcP3NK8z6QprLqjpDVE5mkYtzt4/1TLKbACj V+YZmM18ipK3jleEcDiti2F8gYbQ86XXk8p7fznZj1xjTx3PpZfrexmyTPRL//MXbzXEO+0UX PJg+K2VdRhT+rvQvdFJTQKcoHz+HdkpkFIBfzJZYpYneU0nL9Jy6ARpJP/oFAf1/4eI0H/5Tf IdhwNN79v9E5O0n5hziR7LmPHu5Wj6zPSCSgtVz0rLHrs5NREy2KecJMIocXxfBQ6MUDDqlFm d+E9604XzGEUA12En3fDgHuZqWcTYa96qLlAsmfX16kHGD7WYo+rV+QoG0LHRzyYX559wv+LR lXHvp3xd3eQo1ulLW7KQwdbWWzQyFC1R3STZvtztHZSdnq1x9Ikc9t5xisjwkk5bWulZg6w6Y S7/2Ajf5CpLy0jYStf83RSdEw759NzD77FoInsK9Y/K3M1IkGWxJcCNxxw54aSpy31fjnlYcg bJt5Q9pRv/zbdF3gnxpgR9a+108cZmD39f4qyK66imY/a0X2+lpKGAfZuGlCzUH5o5HutUasn qV6keIKToTltqTRqF5kl4RWW12PcohzY8ftDTeLSYqs/bMzKIPc3ER25v0cuUyPTHqmG0NsNN 2t+k0nM1CzhkGjwiF0nlFw9e65UkIJUpPqI9uYW5Y+nI8wR23E240EXAkjvceuZznBGGOT46A +rjPdKNN33DEgGv3k/GlhkrjFACQHgYW4x+w7/8iz0LIIfABMDKoIEBjk2pJXhFg4qpukQTvi x0TTPwvrFwf4gDL7OoWGwJXb0iRvSYFO69aceOAzVkt7cXGMWlpLNvQFvMozKQdmv8UJmgweZ +Wy4EPQi2HbIXricPn4r7l+b8oX+c5jwt0OjKKVuJOf2jhesFPpa/u/wIhpoTtSJPi2ABH8Qq Jnx/Nf8zB0128vwdgcCJVGLFYmuUdSrT83hYKWA93RvvL8CvyHQS9aCktPJuvSj04CpHyG6FU tQNLHyeubiUMmllQpoWhoCwAmB5FbxjPxb2qzzexNpfZVctsu6u2wB0nJnn4esYLoMqUsf8dX 6CzDttdBYSrm7I9s/9NJAny20OleEf3Yd8N8uPisWqSB8mX1QUz8f3WHQ== Subject: Re: [PHP-DEV] What do you think CSPRNG in PHP From: cmbecker69@gmx.de ("Christoph M. Becker") On 25.07.2022 at 13:32, Jakub Zelenka wrote: > On Mon, Jul 25, 2022 at 12:14 PM Go Kudo wrote: > >> 2022=E5=B9=B47=E6=9C=8817=E6=97=A5(=E6=97=A5) 6:33 Tim D=C3=BCsterhus <= tim@bastelstu.be>: >> >>> On 7/15/22 17:54, Go Kudo wrote: >>>> However, there are several challenges to this. >>>> >>>> - Increased maintenance costs >>>> - Requires optimization for CPU architecture >>>> - Requires familiarity with CSPRNG >>>> >>>> PHP already bundles xxHash and appears ready to make this happen. >>>> >>>> Also, an appropriate CSPRNG implementation may be able to resolve the >>>> current complex macro branching. >>>> >>>> What do you think about this? >>> >>> This would be a strong no from my side. There's all types of failure >>> modes that decrease the security of the CSPRNG (i.e. making it insecur= e) >>> and we really don't want to be the ones to blame if something goes >>> wrong. And historically many non-kernel CSPRNGs later proved to be >>> insecure in specific situations. >>> >>> I also would assume that for a typical PHP application both of the >>> following is true: >>> - The majority of the requests don't need any randomness. >>> - The majority of the requests that *need* randomness don't need any >>> significant amount of randomness. >>> - The majority of the requests that need significant amounts of >>> randomness are fine with a regular PRNG (e.g. Xoshiro or Pcg). >>> - The cost of a few getrandom() syscalls is not really measurable >>> compared to the time spent waiting for the database, file IO or templa= te >>> rendering. >>> >>> Attempting to optimize the speed of the CSPRNG is premature >>> optimization. That also the reason why I suggested to use the 'Secure' >>> engine by default in the Randomizer: It's a safe default choice for th= e >>> vast majority of users. >>> >>> Personally I likely wouldn't have merged the PR in question for the sa= me >>> reasons. But at least in that case glibc is at fault :-) >> >> You are right. Implementing a CSPRNG on your own obviously increases >> maintenance costs and security risks. >> >> However, I still think the overhead of the getrandom syscall in a Linux >> environment is significant and should be considered. > > There is already a good CSPRNG available in OpenSSL which we expose > with openssl_random_pseudo_bytes (except on Windows which is historical = and > should change) TIL! Yes, that should change. > so for those that are impacted by the syscall overhead, this > might be the best option considering that most users are using at least > OpenSSL version 1.1.1 where the new CSPRNG is available. We cannot, however, rely on any OpenSSL functionality in the core or ext/standard, since OpenSSL *might* not be available. =2D- Christoph M. Becker