From 8e1b4e53da728a59be2dc56f9ee349c5b93d6121 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 1 Sep 2012 04:11:04 +0000 Subject: [PATCH] Better seed support for (random) --- lisp/ChangeLog | 7 +++++++ lisp/gnus-sync.el | 2 +- lisp/message.el | 5 +---- lisp/sasl.el | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 44adea5cf..77baac15b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2012-09-01 Paul Eggert + + Better seeds for (random). + * gnus-sync.el (gnus-sync-lesync-setup): + * message.el (message-canlock-generate, message-unique-id): + Change (random t) to (random), now that the latter is more random. + 2012-08-31 Dave Abrahams * auth-source.el (auth-sources): Fix macos keychain access. diff --git a/lisp/gnus-sync.el b/lisp/gnus-sync.el index 7e13b885e..510e85892 100644 --- a/lisp/gnus-sync.el +++ b/lisp/gnus-sync.el @@ -236,7 +236,7 @@ When SALT is nil, a random one will be generated using `random'." (security-object (concat url "/_security")) (user-record `((names . [,user]) (roles . []))) (couch-user-name (format "org.couchdb.user:%s" user)) - (salt (or salt (sha1 (format "%s" (random t))))) + (salt (or salt (sha1 (format "%s" (random))))) (couch-user-record `((_id . ,couch-user-name) (type . user) diff --git a/lisp/message.el b/lisp/message.el index 1e4436ac8..1fea5f912 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -4864,9 +4864,7 @@ Do not use this for anything important, it is cryptographically weak." (require 'sha1) (let (sha1-maximum-internal-length) (sha1 (concat (message-unique-id) - (format "%x%x%x" (random) - (progn (random t) (random)) - (random)) + (format "%x%x%x" (random) (random) (random)) (prin1-to-string (recent-keys)) (prin1-to-string (garbage-collect)))))) @@ -5569,7 +5567,6 @@ In posting styles use `(\"Expires\" (make-expires-date 30))'." ;; You might for example insert a "." somewhere (not next to another dot ;; or string boundary), or modify the "fsf" string. (defun message-unique-id () - (random t) ;; Don't use microseconds from (current-time), they may be unsupported. ;; Instead we use this randomly inited counter. (setq message-unique-id-char diff --git a/lisp/sasl.el b/lisp/sasl.el index c6e95970f..4e759a4e6 100644 --- a/lisp/sasl.el +++ b/lisp/sasl.el @@ -183,7 +183,7 @@ It contain at least 64 bits of entropy." ;; Don't use microseconds from (current-time), they may be unsupported. ;; Instead we use this randomly inited counter. (setq sasl-unique-id-char - (% (1+ (or sasl-unique-id-char (logand (random t) (1- (lsh 1 20))))) + (% (1+ (or sasl-unique-id-char (logand (random) (1- (lsh 1 20))))) ;; (current-time) returns 16-bit ints, ;; and 2^16*25 just fits into 4 digits i base 36. (* 25 25))) -- 2.11.4.GIT