Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95969 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87939 invoked from network); 13 Sep 2016 02:49:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2016 02:49:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:38978] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/C4-60695-42967D75 for ; Mon, 12 Sep 2016 22:49:09 -0400 Received: (qmail 90255 invoked by uid 89); 13 Sep 2016 02:49:05 -0000 Received: from unknown (HELO mail-qt0-f177.google.com) (yohgaki@ohgaki.net@209.85.216.177) by 0 with ESMTPA; 13 Sep 2016 02:49:05 -0000 Received: by mail-qt0-f177.google.com with SMTP id 38so82901784qte.1 for ; Mon, 12 Sep 2016 19:49:04 -0700 (PDT) X-Gm-Message-State: AE9vXwMMjCavT6y3RI2g3VQnl/qJP51J95Dt0ClTRlx471iKhV1S9iXqucWl10sela3DS4pFIZzjgLHv4Ix49Q== X-Received: by 10.200.33.183 with SMTP id 52mr24170015qty.128.1473734938761; Mon, 12 Sep 2016 19:48:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.84.168 with HTTP; Mon, 12 Sep 2016 19:48:18 -0700 (PDT) In-Reply-To: <877fagczci.fsf@lil.giraffy.jp> References: <878tuxenl4.fsf@lil.giraffy.jp> <87twdlcs2j.fsf@lil.giraffy.jp> <87h99lch13.fsf@lil.giraffy.jp> <877fagczci.fsf@lil.giraffy.jp> Date: Tue, 13 Sep 2016 11:48:18 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Kazuo Oishi Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Improve uniqid() uniqueness From: yohgaki@ohgaki.net (Yasuo Ohgaki) On Tue, Sep 13, 2016 at 11:23 AM, Kazuo Oishi wrote: >>>>> IMO, improving it (generate better semi-unique ID) is not important >>>>> enoungh to introduce unnecessary BC break. (Why returning string length >>>>> is changed?) >>>> >>>> It cannot not produce unique ID by default as name "uniqid()" implies. >>>> Reason is described in the RFC. Please read RFC because it's the >>>> official proposal. >>> >>> I had read it, of course. But I could not understand why you chose BC >>> break way. >> >> IMHO, 10 bits (about a million) entropy is not considered enough >> entropy, do you? > > Do you say about extra part which is added by "more_entropy" option? > > Current "more_entropy" part (10 bytes) pattern is "n.nnnnnnnn" and its > variation is 10^9 (1 billion) as written in your RFC. (about 30bits?) > > I think it is enough to avoid collision in the same usec, for > non-security purpose. Oops. Thank you for the correction :) I'll fix the RFC. Actually not with current implementation. If time is rewined, the same ID could be generated by chance. Because, both ID part and entropy part is generated based on the current system time. Collision would be rare, but it's not rare as it should be at all. I think minimum would be 64 bits, 128 at least, 256 bits recommended. How about use 2nd parameter for entropy length? 0 for none, 1 for default, 10 to 255 chars. Then user can have choice for prefered number of entropy chars. > >> How serious BC is? > > You should already know that this BC-breack breaks existing > valid PHP codes in some situation. (DB error, test failure, etc.) > > BC-breack may be acceptable if the change is clearly greate improvement > or obviously necessary. But this change is not, I think. I do think this is needed. Let's not please security audit companies. Use of current uniqid() in security sensitive context is fatal because it is too easy to predict generated ID even with "more_entropy". Letting make such mistake moderate is worth the change. > >> It's much less impact than using mt_rand() all over >> the code. i.e. rand() and mt_rand() is predictable random generator. > > Sorry, I cannot understand what you say... (Why mt_rand?) The change have been done. https://wiki.php.net/rfc/rng_fixes IMHO, this RFC's BC is nothing compare to this. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net