From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#58472: [PATCH] Make `message-unique-id' less prone to collisions Date: Thu, 13 Oct 2022 09:21:05 -0700 Organization: UCLA Computer Science Department Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="457"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Cc: 58472@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 13 18:25:39 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oj11e-000AQf-8O for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 18:25:38 +0200 Original-Received: from localhost ([::1]:50004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oj11c-0006iN-ID for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Oct 2022 12:25:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oj0yB-0003Ms-54 for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 12:22:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oj0yA-000454-TO for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 12:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oj0yA-0006Lx-OS for bug-gnu-emacs@gnu.org; Thu, 13 Oct 2022 12:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Oct 2022 16:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58472 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58472-submit@debbugs.gnu.org id=B58472.166567807624354 (code B ref 58472); Thu, 13 Oct 2022 16:22:02 +0000 Original-Received: (at 58472) by debbugs.gnu.org; 13 Oct 2022 16:21:16 +0000 Original-Received: from localhost ([127.0.0.1]:34716 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj0xP-0006Ki-Mb for submit@debbugs.gnu.org; Thu, 13 Oct 2022 12:21:16 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oj0xN-0006KM-AJ for 58472@debbugs.gnu.org; Thu, 13 Oct 2022 12:21:14 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0E33A160056; Thu, 13 Oct 2022 09:21:07 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1Oh-2IutnDAm; Thu, 13 Oct 2022 09:21:06 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 425BF160075; Thu, 13 Oct 2022 09:21:06 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.9.2 zimbra.cs.ucla.edu 425BF160075 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=78364E5A-2AF3-11ED-87FA-8298ECA2D365; t=1665678066; bh=cT4fm3dr5ribF8ePr2y7uwV22vcQX5Sje0uiD9KR6js=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type: Content-Transfer-Encoding; b=axqwWqvoI65t0G6qbgH2Iv2kVrlCWJAglc3YanF/MCyD6eKX/jff6Dpx5zOxhaf5o NyM/m9omLLVFOoi9CP0X8CmFMYbN89ZaT5EbfCYtqSfYb9s63La4nIPQJqEfPZnlnL n4CoSc/86y1ShdaJdz07WyJQAd/Qp/ARal9d6/rI= X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Zoljz0NW_-BV; Thu, 13 Oct 2022 09:21:06 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1AD13160056; Thu, 13 Oct 2022 09:21:06 -0700 (PDT) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:245326 Archived-At: On 2022-10-12 19:46, Stefan Kangas wrote: > The main goal is to avoid collisions, but using the time also gives an > idea of when the message was sent, which is kind of nice. That info is in the Date: line, along with zillions of other Received: lines. There should be no need to repeat it in the Message-ID line. > Time also > guarantees a somewhat unique value even if the user has happened to set > the random seed. If that's a concern, we should be using more-random data, e.g., with (base64-encode-string (secure-hash 'md5 'iv-auto 128 nil t)) if we want 128 bits of randomness (this yields a string like "B8a3usyu5QSE/rTLu0nIHg=="). As an aside, it's weird that there's no easy way to ask Emacs for an N-bit random integer, where the randomness is taken from system entropy. Shouldn't we extend Emacs to support that? E.g., (make-string 128 'iv-auto) could give you an N-byte entropy-derived random string, or (random -N) could give you an N-bit entropy-derived random nonnegative integer, or something like that. Then we could write something like this: (base64-encode-string (make-string 16 'iv-auto)) to get a Message-ID component with 16 bytes (128 bits) of entropy.