Coverage report: /home/ellis/comp/ext/ironclad/src/ciphers/xchacha.lisp
Kind | Covered | All | % |
expression | 0 | 116 | 0.0 |
branch | 0 | 2 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;;; xchacha.lisp -- implementation of the XChacha stream cipher
4
(defclass xchacha (chacha)
7
(defclass xchacha/12 (xchacha)
9
(:default-initargs :core-function #'chacha/12-core))
11
(defclass xchacha/8 (xchacha)
13
(:default-initargs :core-function #'chacha/8-core))
15
(defmethod shared-initialize :after ((cipher xchacha) slot-names
18
(initialization-vector nil iv-p)
20
(declare (ignore initargs key key-p iv-p))
21
(let ((state (chacha-state cipher))
22
(buffer (make-array 64 :element-type '(unsigned-byte 8))))
23
(declare (type chacha-state state)
24
(type chacha-keystream-buffer buffer))
25
(when initialization-vector
26
(when (< (length initialization-vector) 24)
27
(error 'invalid-initialization-vector
28
:cipher (class-name (class-of cipher))
30
(setf (aref state 12) (ub32ref/le initialization-vector 0)
31
(aref state 13) (ub32ref/le initialization-vector 4)
32
(aref state 14) (ub32ref/le initialization-vector 8)
33
(aref state 15) (ub32ref/le initialization-vector 12)))
34
(funcall (chacha-core-function cipher) buffer state)
35
(setf (aref state 4) (mod32- (ub32ref/le buffer 0) (aref state 0))
36
(aref state 5) (mod32- (ub32ref/le buffer 4) (aref state 1))
37
(aref state 6) (mod32- (ub32ref/le buffer 8) (aref state 2))
38
(aref state 7) (mod32- (ub32ref/le buffer 12) (aref state 3))
39
(aref state 8) (mod32- (ub32ref/le buffer 48) (aref state 12))
40
(aref state 9) (mod32- (ub32ref/le buffer 52) (aref state 13))
41
(aref state 10) (mod32- (ub32ref/le buffer 56) (aref state 14))
42
(aref state 11) (mod32- (ub32ref/le buffer 60) (aref state 15))
45
(if initialization-vector
46
(setf (aref state 14) (ub32ref/le initialization-vector 16)
47
(aref state 15) (ub32ref/le initialization-vector 20))
48
(setf (aref state 14) 0
54
(:crypt-function chacha-crypt)
55
(:key-length (:fixed 16 32)))
59
(:crypt-function chacha-crypt)
60
(:key-length (:fixed 16 32)))
64
(:crypt-function chacha-crypt)
65
(:key-length (:fixed 16 32)))