Coverage report: /home/ellis/comp/core/lib/cry/pkg.lisp
Kind | Covered | All | % |
expression | 0 | 51 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; pkg.lisp --- Crypto Packages
8
(ironclad:digest-file :sha1 "/tmp/picard01t0fjkc.jpg")
11
(cry/b3:b3sum "/tmp/picard01t0fjkc.jpg" :hex nil)
15
(:nicknames :cryptography)
16
(:shadowing-import-from :ironclad :integer-to-octets :octets-to-integer :xor)
17
(:use :cl :std :sb-thread :ironclad :obj/db :obj/id)
18
(:export :crypto-error :crypto-token-expired :crypto-token-invalid
19
:crypto-key :token :crypto-token
20
:*default-password-db* :*default-password-hasher* :*default-password-store* :*default-password-pepper*
33
(:use :cl :std :cry/hotp)
35
*time-step-in-seconds*
38
(defpackage :cry/crc64
40
(:export :+polynomial+ :+improved-polynomial+
41
:init-crc64 :crc64-stream
42
:crc64-file :crc64-sequence))
46
(:use :cl :std :blake3 :sb-alien)
47
(:export :b3hash :b3sum
51
(:use :cl :std :dat/json :dat/base64 :cry)
54
#:compare-hs256-digest
57
(defpackage :cry/authinfo
62
(defpackage :cry/keyring
63
(:use :cl :std :cry :keyutils :id :db :sb-alien)
70
(defpackage :cry/password
71
(:use :cl :std :obj/secret)
72
(:export :password :password-hash :password-salt :make-password-hash :auth))
79
(defvar *password-db* nil
80
"The default password database.")
81
(defvar *password-hasher* nil
82
"The default password hasher.")
83
(defvar *password-store* nil
84
"The default password store.")
85
(defvar *password-pepper* nil
86
"The default pepper value for password hashing. Make sure you change this.")
88
(defclass token (id) ())
90
(defun random-token ()
91
(let ((id (make-array 64 :element-type '(unsigned-byte 8) :fill-pointer 0)))
93
(vector-push (random 128) id))
94
(make-instance 'token :id id)))
96
(defgeneric token-bytes (self)
97
(:method ((self token))
100
(defgeneric token-string (self)
101
(:method ((self token))
102
(sb-ext:octets-to-string (obj/id:id self))))
104
(defclass crypto-token (token) ())
105
(defclass crypto-key (id) ())
106
(defclass password-db (database) ())
107
(defclass password-store (store) ())
110
(defgeneric register-user (user &key store password deadline)
111
(:documentation "Register user identified by TOKEN in store specified by STORE. Returns
112
the user object and an optionally a confirmation token."))
113
(defgeneric get-confirmation-token (user &key store duration)
114
(:documentation "Create a new user confirmation token which must be
115
validated within DURATION if non-nil. Register it for USER in STORE."))
116
(defgeneric confirm-registration (user confirmation &key store)
117
(:documentation "Confirm USER using CONFIRMATION in STORE."))
118
(defgeneric user-pending-p (user &key store)
119
(:documentation "Return non-nil if USER isn't pending confirmation, else nil."))
120
(defgeneric user-known-p (user &key store)
121
(:documentation "Return non-nil if USER is known in STORE."))
122
(defgeneric authenticate-user (user password &key store)
123
(:documentation "Check whether USER successfully authenticates with PASSWORD in STORE. If user had a reset-token pending, clear it upon success."))
124
(defgeneric get-reset-token (user &key store duration)
125
(:documentation "Create a new reset token, register it for USER in STORE for DURATION."))
126
(defgeneric clear-reset-token (user &key store)
127
(:documentation "Clear reset token of USER."))
128
(defgeneric reset-password (user reset new &key store)
129
(:documentation "Reset password of USER in STORE to NEW, authenticating with RESET."))
130
(defgeneric delete-user (user &key store error-p)
131
(:documentation "Delete user identified by USER in STORE. Signal an error if user can't be found and ERROR-P is non-nil."))