Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112616 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89148 invoked from network); 24 Dec 2020 16:38:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Dec 2020 16:38:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F62D1804D4 for ; Thu, 24 Dec 2020 08:11:53 -0800 (PST) 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 24 Dec 2020 08:11:52 -0800 (PST) Received: by mail-lf1-f49.google.com with SMTP id m12so5625003lfo.7 for ; Thu, 24 Dec 2020 08:11:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=qhQAVUXUsOTsiwCDxlYWpruAwY30+fOInT7gUycYfF4=; b=IT+z/j8ZrlKWH40L5mZXTqIkAwJ+MzoiA6B1gJRqa+91di7uC2HOqFRw8MBmOpfsuT fWfbH+02wvRjxncBzdlTTfxoiSs7YJhsajk5T3Fo6rFvJ1RMY91f25DIhW1H4lR4HTsM DMd39ZFJPOJ2kAGFrlvQQEpgsS4pf8fADL9x381qzMyyRswlB0tWyt9bF0jWy10lWamP 8xLaQPUUZ/UhSHPMQQavRciJfe4szp+jrq6eZR5O41A8v2sjQ0u6yNzVOu8luFPIvGxu igtVdywJsu6tFaleRx14VLuFdNKT+mPIxdyZWu76ajCZm3biuvE05GUCzGkloea4Omk5 8VzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=qhQAVUXUsOTsiwCDxlYWpruAwY30+fOInT7gUycYfF4=; b=LJFbaABs5s73jnjYHUWqkUqu50C+kTXfJjDnoioCZpsMq08JMkbt8n7xXm+tDnwLzZ mh0koWE61OcmxEOZ6mpLIQAHLmXxIU83vm/9kJMDim4RVIZyuvaKnINjIKpmYTUE3I8W ERBJ77NwErMWANZGAT1iSJQvjHnwgwQQfy9zwb3P0DpTDTNpqhHezzIkANaSokvqduIW G4ygYWzRXXk5fa9KrtpkG2f53YaXcwm5NEIOpDpj1/wRCx3Abr2VSkcXk9lElCNq7oZw P+8KEXvlLMRmTCAyCTwbXM1cZtBSLHqOdQYM5kjgDPZbK6Lh5qZvwD7xVuRNUYVdjKTe HKCQ== X-Gm-Message-State: AOAM533dTLsWC4b8DmzRg16/ZNCuhviHWNeOTE1H9NXCJipjhiJ+aRLa SZKBlqLkxCkUsi9N5tD0/CozBh3Mjdxa+1K4ukGZ6SsJ97rK2g== X-Google-Smtp-Source: ABdhPJxZ2n6+oy2rEDH1sRc2RFmuju063y+4AFFt9PEOUGzvwZPKoeT0jBCyJyEDqBVG8DtExdLp36Ie7lx0FAR+ECY= X-Received: by 2002:a2e:50c:: with SMTP id 12mr13992687ljf.226.1608826308578; Thu, 24 Dec 2020 08:11:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 25 Dec 2020 01:11:37 +0900 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000a0d29805b73810a3" Subject: Re: Improving PRNG implementation. From: zeriyoshi@gmail.com (zeriyoshi) --000000000000a0d29805b73810a3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I updated the RFC draft and changed it to a proposal to bifurcate the interface. https://wiki.php.net/rfc/object_scope_prng At the same time, I was looking into the RNG problem in Swoole and found out that the problem was actually occurring. https://www.easyswoole.com/En/Other/random.html The above problem with Swoole is only for child processes and can be fixed by the user, but as mentioned above, I think it will become more serious as PHP becomes more complex in the future. I hadn't thought of this before, but we might want to consider deprecating existing state-dependent RNG functions. I am seeking feedback on this proposal in order to take the RFC to the next step. Thank you in advance. Regards, Go Kudo 2020=E5=B9=B412=E6=9C=8816=E6=97=A5(=E6=B0=B4) 23:46 zeriyoshi : > Nice to meet you, internals. > > PHP 8.0 has been released. With the inclusion of JIT, PHP is about to be > extended beyond the web. > > So I'd like to make a few suggestions. > > First , PHP has the historical Mersenne Twister PRNG. However, this > implementation keeps its state in a global and cannot be handled as an > object like other languages (e.g. Java). > > So, I created a PHP Extension and proposed it to PECL. > > https://marc.info/?l=3Dpecl-dev&m=3D160795415604102&w=3D2 > https://github.com/zeriyoshi/php-ext-orng > > But, Then I looked at the mailing list archives and noticed that a simila= r > proposal had been made before. > > https://externals.io/message/98021#98130 > > I feel that this suggestion is needed now to expand PHP beyond the web. > > Second suggestion is to stop using the Combined LCG as the default seed > value for each function. > > PHP's Combined LCG only uses PID (or ZTS Thread ID) and time as entropy. > https://github.com/php/php-src/blob/master/ext/standard/lcg.c#L72 > > With the development of container technology, this problem seems to be > getting more serious. So I think we should use the random numbers provide= d > by the OS (getrandom on Linux) if available. > > I would like to hear your opinions. > > Regards > Go Kudo > --000000000000a0d29805b73810a3--