Coverage report: /home/ellis/comp/ext/ironclad/src/aead/aead.lisp

KindCoveredAll%
expression053 0.0
branch06 0.0
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;;; aead.lisp -- authenticated encryption with associated data
2
 (in-package :crypto)
3
 
4
 (defclass aead-mode ()
5
   ((encryption-started :accessor encryption-started-p
6
                        :initform nil
7
                        :type boolean)
8
    (tag :accessor tag)))
9
 
10
 (defmethod shared-initialize :after ((mode aead-mode) slot-names &rest initargs &key tag &allow-other-keys)
11
   (declare (ignore slot-names initargs))
12
   (setf (encryption-started-p mode) nil
13
         (tag mode) (copy-seq tag))
14
   mode)
15
 
16
 (defun aeadp (name)
17
   (get name 'aead))
18
 
19
 (defun list-all-authenticated-encryption-modes ()
20
   "Returns a list whose elements may be validly passed to
21
 make-authenticated-encryption-mode."
22
   (loop for symbol being each external-symbol of (find-package :ironclad)
23
         if (aeadp symbol)
24
           collect (intern (symbol-name symbol) :keyword) into ciphers
25
         finally (return (sort ciphers #'string<))))
26
 
27
 (defun authenticated-encryption-mode-supported-p (name)
28
   "Returns T if NAME would be in the list returned by
29
 list-all-authenticated-encryption-modes NIL otherwise."
30
   (and (symbolp name) (aeadp (massage-symbol name))))
31
 
32
 (defmacro defaead (name)
33
   `(setf (get ',name 'aead) t))
34
 
35
 (defun make-authenticated-encryption-mode (name &rest args)
36
   "Return an authenticated encryption object suitable for use for both
37
 encryption and decryption."
38
   (typecase name
39
     (symbol
40
      (let ((name (massage-symbol name)))
41
        (if (aeadp name)
42
            (apply #'make-instance name args)
43
            (error 'unsupported-authenticated-encryption-mode :name name))))
44
     (t
45
      (error 'type-error :datum name :expected-type 'symbol))))