Skip to content
Browse files

delete unused S-BOXES variable in CAST5 implementation

This variable apparently caused problems for some Lispworks users.
  • Loading branch information...
1 parent bc37440 commit 436e53b1aafd1b4a719881be480153494d1bb810 @froydnj committed Jun 16, 2012
Showing with 13 additions and 14 deletions.
  1. +13 −14 src/ciphers/cast5.lisp
View
27 src/ciphers/cast5.lisp
@@ -295,8 +295,7 @@
(declaim (inline cast5-f1 cast5-f2 cast5-f3))
-(macrolet ((cast5-s-box (s-boxes s-box-index index)
- (declare (ignore s-boxes))
+(macrolet ((cast5-s-box (s-box-index index)
`(aref ,(intern (format nil "+~A~A+" '#:cast5-sbox s-box-index))
,index)))
@@ -305,30 +304,30 @@
(declare (type (unsigned-byte 5) rotate))
(let ((value (rol32 (mod32+ input mask) rotate)))
(declare (type (unsigned-byte 32) value))
- (mod32+ (cast5-s-box s-boxes 3 (first-byte value))
- (mod32- (logxor (cast5-s-box s-boxes 1 (third-byte value))
- (cast5-s-box s-boxes 0 (fourth-byte value)))
- (cast5-s-box s-boxes 2 (second-byte value))))))
+ (mod32+ (cast5-s-box 3 (first-byte value))
+ (mod32- (logxor (cast5-s-box 1 (third-byte value))
+ (cast5-s-box 0 (fourth-byte value)))
+ (cast5-s-box 2 (second-byte value))))))
(defun cast5-f2 (input mask rotate)
(declare (type (unsigned-byte 32) input mask))
(declare (type (unsigned-byte 5) rotate))
(let ((value (rol32 (logxor input mask) rotate)))
(declare (type (unsigned-byte 32) value))
- (logxor (cast5-s-box s-boxes 3 (first-byte value))
- (mod32+ (cast5-s-box s-boxes 2 (second-byte value))
- (mod32- (cast5-s-box s-boxes 0 (fourth-byte value))
- (cast5-s-box s-boxes 1 (third-byte value)))))))
+ (logxor (cast5-s-box 3 (first-byte value))
+ (mod32+ (cast5-s-box 2 (second-byte value))
+ (mod32- (cast5-s-box 0 (fourth-byte value))
+ (cast5-s-box 1 (third-byte value)))))))
(defun cast5-f3 (input mask rotate)
(declare (type (unsigned-byte 32) input mask))
(declare (type (unsigned-byte 5) rotate))
(let ((value (rol32 (mod32- mask input) rotate)))
(declare (type (unsigned-byte 32) value))
- (mod32- (logxor (cast5-s-box s-boxes 2 (second-byte value))
- (mod32+ (cast5-s-box s-boxes 1 (third-byte value))
- (cast5-s-box s-boxes 0 (fourth-byte value))))
- (cast5-s-box s-boxes 3 (first-byte value)))))
+ (mod32- (logxor (cast5-s-box 2 (second-byte value))
+ (mod32+ (cast5-s-box 1 (third-byte value))
+ (cast5-s-box 0 (fourth-byte value))))
+ (cast5-s-box 3 (first-byte value)))))
(define-block-encryptor cast5 8
(let ((mask-vector (mask-vector context))

0 comments on commit 436e53b

Please sign in to comment.
Something went wrong with that request. Please try again.