Skip to content

Commit c7c67c9

Browse files
committed
Uses crypto-random-bytes for make-secret-salt/file
in web-server/http/id-cookie Also updates broken link to MIT Cookie Eaters
1 parent 3d6e543 commit c7c67c9

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

web-server-doc/web-server/scribblings/http.scrbl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#lang scribble/doc
2-
@(require "web-server.rkt")
2+
@(require "web-server.rkt"
3+
(for-label racket/random
4+
))
35

46
@title[#:tag "http"]{HTTP: Hypertext Transfer Protocol}
57

@@ -321,7 +323,7 @@ is fully controlled by the user, and thus cannot be trusted.
321323
This module provides functions for creating and verifying
322324
authenticated cookies that are intrinsically timestamped. It is based
323325
on the algorithm proposed by the
324-
@link["http://cookies.lcs.mit.edu/"]{MIT Cookie Eaters}: if you store
326+
@link["https://pdos.csail.mit.edu/archive/cookies/"]{MIT Cookie Eaters}: if you store
325327
the data @racket[_data] at thime @racket[_authored-seconds], then the
326328
user will receive @litchar{digest&authored-seconds&data}, where
327329
@racket[_digest] is an HMAC-SHA1 digest of @racket[_authored-seconds]
@@ -335,8 +337,8 @@ to generate this is by using random bytes from something like OpenSSL
335337
or
336338
@tt{/dev/random}. @link["http://www.madboa.com/geek/openssl/#random-generate"]{This
337339
FAQ} lists a few options. A convenient purely Racket-based option is
338-
available (@racket[make-secret-salt/file]), but it will not have as
339-
good entropy, if you care about that sort of thing.
340+
available (@racket[make-secret-salt/file]),
341+
which is implemented using @racket[crypto-random-bytes].
340342

341343
@defproc[(make-id-cookie
342344
[name cookie-name?]

web-server-lib/web-server/http/id-cookie.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
net/cookie
44
racket/match
55
racket/file
6+
racket/random
67
racket/contract
78
web-server/http
89
web-server/stuffers/hmac-sha1
@@ -21,8 +22,7 @@
2122
(unless (file-exists? secret-salt-path)
2223
(with-output-to-file secret-salt-path
2324
(λ ()
24-
(for ([i (in-range 128)])
25-
(write-byte (random 256))))))
25+
(write-bytes (crypto-random-bytes 128)))))
2626
(file->bytes secret-salt-path))
2727

2828
(define (id-cookie? name c)

0 commit comments

Comments
 (0)