Coverage report: /home/ellis/comp/ext/ironclad/src/ciphers/tea.lisp
Kind | Covered | All | % |
expression | 0 | 91 | 0.0 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
4
(defconstant +tea-n-rounds+ 32)
5
(defconstant +tea-delta+ #x9e3779b9)
7
(defclass tea (cipher 8-byte-block-mixin)
10
(define-block-encryptor tea 8
11
(with-words ((y z) plaintext plaintext-start)
12
(let ((key (key context))
14
(declare (type (simple-array (unsigned-byte 32) (4)) key))
15
(declare (type (unsigned-byte 32) sum))
16
;; could probably unroll this loop for reasonable performance gain
17
(dotimes (i +tea-n-rounds+)
18
(setf sum (mod32+ sum +tea-delta+))
19
(setf y (mod32+ y (logxor (mod32+ (mod32ash z 4) (aref key 0))
21
(mod32+ (mod32ash z -5) (aref key 1)))))
22
(setf z (mod32+ z (logxor (mod32+ (mod32ash y 4) (aref key 2))
24
(mod32+ (mod32ash y -5) (aref key 3))))))
25
(store-words ciphertext ciphertext-start y z))))
27
(define-block-decryptor tea 8
28
(with-words ((y z) ciphertext ciphertext-start)
29
(let ((key (key context))
30
(sum (mod32ash +tea-delta+ 5)))
31
(declare (type (simple-array (unsigned-byte 32) (4)) key))
32
(declare (type (unsigned-byte 32) sum))
33
(dotimes (i +tea-n-rounds+)
34
(setf z (mod32- z (logxor (mod32+ (mod32ash y 4) (aref key 2))
36
(mod32+ (mod32ash y -5) (aref key 3)))))
37
(setf y (mod32- y (logxor (mod32+ (mod32ash z 4) (aref key 0))
39
(mod32+ (mod32ash z -5) (aref key 1)))))
40
(setf sum (mod32- sum +tea-delta+)))
41
(store-words plaintext plaintext-start y z))))
43
(defmethod schedule-key ((cipher tea) key)
44
(let ((ub32key (make-array 4 :element-type '(unsigned-byte 32))))
45
(with-words ((a b c d) key 0)
46
(setf (aref ub32key 0) a
50
(setf (key cipher) ub32key)
54
(:encrypt-function tea-encrypt-block)
55
(:decrypt-function tea-decrypt-block)
57
(:key-length (:fixed 16)))