summaryrefslogtreecommitdiff
path: root/benchmark
diff options
context:
space:
mode:
authorGuillaume LE VAILLANT <glv@posteo.net>2018-08-24 11:55:12 +0200
committerGuillaume LE VAILLANT <glv@posteo.net>2018-08-24 12:53:39 +0200
commit1d6005405cf6922ee172e408ebcc66d35aaca29d (patch)
treefcf12dba98e30be4545c0dac5da2b7e2f59964a5 /benchmark
parent4815ca2b88796fb601d854bb1b25254b5d8831ba (diff)
Add benchmark for block cipher modes
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/benchmark-implementation.lisp17
-rw-r--r--benchmark/benchmark.lisp25
2 files changed, 42 insertions, 0 deletions
diff --git a/benchmark/benchmark-implementation.lisp b/benchmark/benchmark-implementation.lisp
index 536b836..7447085 100644
--- a/benchmark/benchmark-implementation.lisp
+++ b/benchmark/benchmark-implementation.lisp
@@ -93,6 +93,22 @@
(setf speeds (acons mac-name speed speeds))))
(setf *result* (acons "macs" speeds *result*))))
+(defun benchmark-modes ()
+ (let ((speeds '()))
+ (dolist (mode-name (ironclad:list-all-modes))
+ (let* ((cipher-name :aes)
+ (key (ironclad:random-data (car (last (ironclad:key-lengths cipher-name)))))
+ (iv (ironclad:random-data (ironclad:block-length cipher-name)))
+ (cipher (ironclad:make-cipher cipher-name
+ :mode mode-name
+ :key key
+ :initialization-vector iv))
+ (buffer (ironclad:random-data *buffer-size*))
+ (speed (get-speed-data (dotimes (i (ceiling *data-size* *buffer-size*))
+ (ironclad:encrypt-in-place cipher buffer)))))
+ (setf speeds (acons mode-name speed speeds))))
+ (setf *result* (acons "modes" speeds *result*))))
+
(defun benchmark-diffie-hellman ()
(let ((speeds '()))
(dolist (dh-name '(:curve25519 :curve448 :elgamal))
@@ -144,6 +160,7 @@
(benchmark-ciphers)
(benchmark-digests)
(benchmark-macs)
+(benchmark-modes)
(benchmark-diffie-hellman)
(benchmark-message-encryptions)
(benchmark-signatures)
diff --git a/benchmark/benchmark.lisp b/benchmark/benchmark.lisp
index d487754..7ffc8b8 100644
--- a/benchmark/benchmark.lisp
+++ b/benchmark/benchmark.lisp
@@ -23,6 +23,9 @@
;;; ("macs" (("mac1" speed1)
;;; ("mac2" speed2)
;;; (...)))
+;;; ("modes" (("mode1" speed1)
+;;; ("mode2" speed2)
+;;; (...)))
;;; ("diffie-hellman" (("diffie-hellman1" speed1)
;;; ("diffie-hellman2" speed2)
;;; (...)))
@@ -123,6 +126,28 @@
(terpri file))
(format file "~a~%~%" line)
+ (format file "* Block cipher modes~%~%")
+ (format file "Cipher: AES~%~%")
+ (format file "Encryption speed in bytes per second~%~%")
+ (format file "~a~%" line)
+ (format file "| |")
+ (dolist (implementation *lisp-implementations*)
+ (let ((lisp (car implementation)))
+ (format file " ~10a |" lisp)))
+ (terpri file)
+ (format file "~a~%" line)
+ (dolist (mode-name (ironclad:list-all-modes))
+ (format file "| ~14a |" mode-name)
+ (dolist (implementation *lisp-implementations*)
+ (let* ((lisp (car implementation))
+ (result (cdr (assoc "modes"
+ (cdr (assoc lisp results :test #'string=))
+ :test #'string=)))
+ (speed (cdr (assoc mode-name result :test #'string=))))
+ (format file " ~10@a |" speed)))
+ (terpri file))
+ (format file "~a~%~%" line)
+
(format file "* Diffie-Hellman key exchanges~%~%")
(format file "ELGAMAL: 2048 bits~%~%")
(format file "Diffie-Hellman speed in exchanges per second~%~%")