Coverage report: /home/ellis/comp/core/lib/cry/password.lisp
Kind | Covered | All | % |
expression | 28 | 30 | 93.3 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; password.lisp --- Reasonably Safe User Passwords
6
(in-package :cry/password)
10
:reader password-hash)
13
;; Use /dev/urandom seed for portability.
14
(let ((ironclad:*prng* (ironclad:make-prng :fortuna :seed :urandom)))
15
(ironclad:make-random-salt 20))
16
:reader password-salt)))
18
(defun make-password-hash (password salt)
19
(ironclad:byte-array-to-hex-string
20
(ironclad:digest-sequence
22
(concatenate '(vector (unsigned-byte 8))
23
(sb-ext:string-to-octets password)
26
(defgeneric (setf password) (password auth)
27
(:method (password (object password))
28
(let ((hash (make-password-hash
30
(slot-value object 'salt))))
31
(setf (slot-value object 'hash) hash))))
33
(defmethod initialize-instance :after ((object password) &rest initargs
34
&key password &allow-other-keys)
35
(declare (ignore initargs))
37
(setf (password object) password)))
39
(defmethod auth (object password)
40
(string= (password-hash object)
41
(make-password-hash password
42
(password-salt object))))