Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 268 lines (245 sloc) 13.255 kb
eaf2f0d Initial commit.
Nathan Froyd authored
1 ; -*- mode: lisp -*-
2 (defpackage #:ironclad-system
3 (:use :cl :asdf))
4
5 (in-package #:ironclad-system)
6
7 ;;; easy-to-type readmacro for creating s-boxes and the like
8
9 (defun array-reader (stream subchar arg)
10 (declare (ignore subchar))
11 (let ((array-data (read stream nil stream nil))
12 (array-element-type `(unsigned-byte ,arg)))
13 ;; FIXME: need to make this work for multi-dimensional arrays
14 `(make-array ,(length array-data) :element-type ',array-element-type
15 :initial-contents ',array-data)))
16
17 (defparameter *ironclad-readtable*
18 (let ((readtable (copy-readtable nil)))
19 (set-dispatch-macro-character #\# #\@ #'array-reader readtable)
20 readtable))
21
22 (defclass ironclad-source-file (cl-source-file) ())
23 (defclass txt-file (doc-file) ())
24 (defclass css-file (doc-file) ())
25
26 (defmethod source-file-type ((c txt-file) (s module)) "txt")
27 (defmethod source-file-type ((c css-file) (s module)) "css")
28
29 (asdf:defsystem :ironclad
7a248e8 @froydnj release 0.30
authored
30 :version "0.30"
eaf2f0d Initial commit.
Nathan Froyd authored
31 :author "Nathan Froyd <froydnj@gmail.com>"
32 :maintainer "Nathan Froyd <froydnj@gmail.com>"
33 :description "A cryptographic toolkit written in pure Common Lisp"
34 :default-component-class ironclad-source-file
b6461b4 @froydnj add dependency on nibbles for faster N-bit accesses
authored
35 :depends-on (#+sbcl sb-rotate-byte nibbles)
eaf2f0d Initial commit.
Nathan Froyd authored
36 :components ((:static-file "README")
37 (:static-file "LICENSE")
38 (:static-file "TODO")
39 (:static-file "NEWS")
40 (:module "src"
41 :components
42 ((:file "package")
43 (:file "conditions" :depends-on ("package"))
44 (:file "util" :depends-on ("package"))
45 (:file "macro-utils" :depends-on ("package"))
46 (:file "common" :depends-on ("package"))
47 ;; FIXME: make this depend on :FEATURE :IRONCLAD-GRAY-STREAMS
48 #+(or lispworks sbcl openmcl cmu allegro)
49 (:file "octet-stream" :depends-on ("common"))
50 (:file "padding" :depends-on ("common"))
51 (:file "pkcs5" :depends-on ("common"))
3372482 @vsedach Added pbkdf password hash convenience functions, documentation, re-en…
vsedach authored
52 (:file "password-hash" :depends-on ("pkcs5"))
6cb47cd @froydnj add SBCL-OPT module
authored
53 (:module "sbcl-opt"
54 :depends-on ("package" "common")
55 :components
56 ;; ASDF doesn't DTRT, so we can't make
57 ;; the whole module :IN-ORDER-TO.
58 ;; We'll settle for this one file and
59 ;; key off of that.
60 ((:file "fndb"
61 :in-order-to ((compile-op
62 (feature :sbcl))))
3b965f3 @froydnj add x86oid optimizations for FILL-BLOCK-* functions
authored
63 ;; It would be nice if we could say
64 ;; (OR (FEATURE :X86) (FEATURE :X86-64))
65 ;; but ASDF is not that flexible.
66 (:file "x86oid-vm" :depends-on ("fndb")))
6cb47cd @froydnj add SBCL-OPT module
authored
67 :if-component-dep-fails :ignore)
eaf2f0d Initial commit.
Nathan Froyd authored
68 (:module "ciphers"
d57e9fe @froydnj move MASSAGE-SYMBOL to a common place
authored
69 :depends-on ("common" "macro-utils")
eaf2f0d Initial commit.
Nathan Froyd authored
70 :components
71 (
72 ;; block ciphers of various kinds
73 (:file "cipher")
74 (:file "modes" :depends-on ("cipher"))
75 (:file "make-cipher" :depends-on ("cipher"))
76 (:file "null-cipher" :depends-on ("cipher"))
77 (:file "aes" :depends-on ("cipher"))
78 (:file "des" :depends-on ("cipher"))
79 (:file "blowfish" :depends-on ("cipher"))
80 (:file "twofish" :depends-on ("cipher"))
81 (:file "idea" :depends-on ("cipher"))
82 (:file "misty1" :depends-on ("cipher"))
83 (:file "square" :depends-on ("cipher"))
84 (:file "rc2" :depends-on ("cipher"))
85 (:file "rc5" :depends-on ("cipher"))
86 (:file "rc6" :depends-on ("cipher"))
87 (:file "tea" :depends-on ("cipher"))
88 (:file "xtea" :depends-on ("cipher"))
89 (:file "cast5" :depends-on ("cipher"))
90 ;; stream ciphers
91 (:file "arcfour" :depends-on ("cipher"))))
92 (:module "digests"
6cb47cd @froydnj add SBCL-OPT module
authored
93 :depends-on ("common" "macro-utils" "sbcl-opt")
eaf2f0d Initial commit.
Nathan Froyd authored
94 :components
95 ((:file "digest")
96 (:file "crc24" :depends-on ("digest"))
97 (:file "crc32" :depends-on ("digest"))
98 (:file "adler32" :depends-on ("digest"))
99 (:file "md2" :depends-on ("digest"))
100 (:file "md4" :depends-on ("digest"))
101 (:file "md5" :depends-on ("digest"))
0a75651 - Lispworks-specific implementation of MD5, based on SYS:INT32.
Klaus Harbo authored
102 (:file "md5-lispworks-int32" :depends-on ("digest"))
eaf2f0d Initial commit.
Nathan Froyd authored
103 (:file "sha1" :depends-on ("digest"))
104 (:file "sha256" :depends-on ("digest"))
105 (:file "sha512" :depends-on ("digest"))
106 (:file "ripemd-128" :depends-on ("digest"))
107 (:file "ripemd-160" :depends-on ("digest"))
108 (:file "tiger" :depends-on ("digest"))
64597e1 @fare Add support for (tiger-)tree-hash digests.
fare authored
109 (:file "whirlpool" :depends-on ("digest"))
110 (:file "tree-hash" :depends-on ("digest"))))
eaf2f0d Initial commit.
Nathan Froyd authored
111 (:module "macs"
d57e9fe @froydnj move MASSAGE-SYMBOL to a common place
authored
112 :depends-on ("common" "digests")
eaf2f0d Initial commit.
Nathan Froyd authored
113 :components
114 ((:file "hmac")
115 (:file "cmac")))
116 (:module "public-key"
117 :depends-on ("package")
118 :components
119 ((:file "public-key")
120 (:file "dsa" :depends-on ("public-key"))
121 (:file "rsa" :depends-on ("public-key"))))))
122 (:module "doc"
123 :components
124 ((:html-file "ironclad")
125 ;; XXX ASDF bogosity
126 (:txt-file "ironclad-doc")
127 (:css-file "style")))))
128
129 (defun ironclad-implementation-features ()
130 #+sbcl
d34b2b8 @froydnj dial back the inlining for non-mod-wordsize implementations
authored
131 (list* sb-c:*backend-byte-order*
132 (if (= sb-vm:n-word-bits 32)
133 :32-bit
134 :64-bit)
135 :ironclad-fast-mod32-arithmetic
136 :ironclad-gray-streams
137 (when (member :x86-64 *features*)
138 '(:ironclad-fast-mod64-arithmetic)))
eaf2f0d Initial commit.
Nathan Froyd authored
139 #+cmu
140 (list (c:backend-byte-order c:*target-backend*)
141 (if (= vm:word-bits 32)
142 :32-bit
143 :64-bit)
d34b2b8 @froydnj dial back the inlining for non-mod-wordsize implementations
authored
144 :ironclad-fast-mod32-arithmetic
eaf2f0d Initial commit.
Nathan Froyd authored
145 :ironclad-gray-streams)
146 #+allegro
147 (list :ironclad-gray-streams)
148 #+lispworks
149 (list :ironclad-gray-streams)
150 #+openmcl
151 (list :ironclad-gray-streams)
152 #-(or sbcl cmu allegro lispworks openmcl)
153 nil)
154
155
156 (macrolet ((do-silently (&body body)
157 `(handler-bind ((style-warning #'muffle-warning)
158 ;; It's about as fast as we can make it,
159 ;; and a number of the notes relate to code
160 ;; that we're running at compile time,
161 ;; which we don't care about the speed of
162 ;; anyway...
163 #+sbcl (sb-ext:compiler-note #'muffle-warning))
164 ,@body)))
165 (defmethod perform :around ((op compile-op) (c ironclad-source-file))
166 (let ((*readtable* *ironclad-readtable*)
167 (*print-base* 10) ; INTERN'ing FORMAT'd symbols
168 (*print-case* :upcase)
169 #+sbcl (sb-ext:*inline-expansion-limit* (max sb-ext:*inline-expansion-limit* 1000))
170 #+cmu (ext:*inline-expansion-limit* (max ext:*inline-expansion-limit* 1000))
171 (*features* (append (ironclad-implementation-features) *features*)))
172 (do-silently (call-next-method))))
173
174 (defmethod perform :around ((op load-op) (c ironclad-source-file))
175 (do-silently (call-next-method))))
176
177 (defmethod perform :after ((op load-op) (c (eql (find-system :ironclad))))
178 (provide :ironclad))
b8db877 @froydnj put ironclad-tests system back in ironclad.asd
authored
179
180
181 ;;; testing
182
183 (defclass test-vector-file (static-file)
184 ())
185
186 (defmethod source-file-type ((c test-vector-file) (s module)) "testvec")
187
188 (defpackage :ironclad-tests
189 (:nicknames :crypto-tests)
190 (:use :cl))
191
192 (defmethod perform ((op test-op) (c (eql (find-system :ironclad))))
193 (oos 'test-op 'ironclad-tests))
194
195 ;;; A tester's job is never done!
196 (defmethod operation-done-p ((op test-op) (c (eql (find-system :ironclad))))
197 nil)
198
199 (asdf:defsystem ironclad-tests
200 :depends-on (ironclad)
201 :version "0.5"
202 :in-order-to ((test-op (load-op :ironclad-tests)))
203 :components ((:module "testing"
204 :components
205 ((:file "rt")
206 (:file "testfuns" :depends-on ("rt"))
207 (:module "test-vectors"
208 :depends-on ("testfuns")
209 :components
210 ((:file "macs")
211 (:file "modes")
212 (:file "ciphers")
213 (:file "digests")
214 (:file "padding")
3372482 @vsedach Added pbkdf password hash convenience functions, documentation, re-en…
vsedach authored
215 (:file "pkcs5")
b8db877 @froydnj put ironclad-tests system back in ironclad.asd
authored
216 (:file "ironclad")
217 ;; test vectors
218 (:test-vector-file "crc24")
219 (:test-vector-file "crc32")
220 (:test-vector-file "adler32")
221 (:test-vector-file "md2")
222 (:test-vector-file "md4")
223 (:test-vector-file "md5")
224 (:test-vector-file "sha1")
225 (:test-vector-file "sha224")
226 (:test-vector-file "sha256")
227 (:test-vector-file "sha384")
228 (:test-vector-file "sha512")
229 (:test-vector-file "ripemd-128")
230 (:test-vector-file "ripemd-160")
231 (:test-vector-file "tiger")
232 (:test-vector-file "whirlpool")
233 (:test-vector-file "hmac")
234 (:test-vector-file "cmac")
de5547e @froydnj add tree-hash test vector file to the test system
authored
235 (:test-vector-file "tree-hash")
b8db877 @froydnj put ironclad-tests system back in ironclad.asd
authored
236 ;; block ciphers of various kinds
237 (:test-vector-file "null")
238 (:test-vector-file "aes")
239 (:test-vector-file "des")
240 (:test-vector-file "3des")
241 (:test-vector-file "blowfish")
242 (:test-vector-file "twofish")
243 (:test-vector-file "idea")
244 (:test-vector-file "misty1")
245 (:test-vector-file "square")
246 (:test-vector-file "rc2")
247 (:test-vector-file "rc5")
248 (:test-vector-file "rc6")
249 (:test-vector-file "tea")
250 (:test-vector-file "xtea")
251 (:test-vector-file "cast5")
252 ;; modes
253 (:test-vector-file "cbc")
254 (:test-vector-file "ctr")
255 (:test-vector-file "ofb")
256 (:test-vector-file "cfb")
257 (:test-vector-file "cfb8")
258 ;; stream ciphers
259 (:test-vector-file "arcfour")))))))
260
261 (defmethod operation-done-p ((op test-op)
262 (c (eql (find-system :ironclad-tests))))
263 nil)
264
265 (defmethod perform ((op test-op) (c (eql (find-system :ironclad-tests))))
266 (or (funcall (intern "DO-TESTS" (find-package "RTEST")))
267 (error "TEST-OP failed for IRONCLAD-TESTS")))
Something went wrong with that request. Please try again.