blowfish fixes - 19

This commit is contained in:
erana 2012-01-20 20:40:44 +09:00
parent 37665577ab
commit 08aad3273f
1 changed files with 36 additions and 36 deletions

View File

@ -1158,9 +1158,9 @@
(vector-ref (blowfish-s3 blowfish-context) 0)))) (vector-ref (blowfish-s3 blowfish-context) 0))))
(define blowfish-F (if BIG-ENDIAN-HOST blowfish-F-be blowfish-F-le)) ;; FIXME default is big endian (define blowfish-F (if BIG-ENDIAN-HOST blowfish-F-be blowfish-F-le)) ;; FIXME default is big endian
(define (blowfish-R l r i) (define (blowfish-R bc l r i)
(set! l (bitwise-xor l (dictionary-ref (blowfish-p blowfish-context) i))) (set! l (bitwise-xor l (dictionary-ref (blowfish-p bc) i)))
(set! r (bitwise-xor r ((dictionary-ref (blowfish-p blowfish-context) blowfish-F l))))) (set! r (bitwise-xor r ((dictionary-ref (blowfish-p bc) blowfish-F l)))))
;; blowfish-rounds == 16 -> ;; blowfish-rounds == 16 ->
(define (blowfish-encrypt bc ret_xl ret_xr) ;; NOTE bc = blowfish-context (define (blowfish-encrypt bc ret_xl ret_xr) ;; NOTE bc = blowfish-context
@ -1173,22 +1173,22 @@
;;(s3 (blowfish-s3 bc)) ;;(s3 (blowfish-s3 bc))
) )
(blowfish-R xl xr 0) (blowfish-R bc xl xr 0)
(blowfish-R xr xl 1) (blowfish-R bc xr xl 1)
(blowfish-R xl xr 2) (blowfish-R bc xl xr 2)
(blowfish-R xr xl 3) (blowfish-R bc xr xl 3)
(blowfish-R xl xr 4) (blowfish-R bc xl xr 4)
(blowfish-R xr xl 5) (blowfish-R bc xr xl 5)
(blowfish-R xl xr 6) (blowfish-R bc xl xr 6)
(blowfish-R xr xl 7) (blowfish-R bc xr xl 7)
(blowfish-R xl xr 8) (blowfish-R bc xl xr 8)
(blowfish-R xr xl 9) (blowfish-R bc xr xl 9)
(blowfish-R xl xr 10) (blowfish-R bc xl xr 10)
(blowfish-R xr xl 11) (blowfish-R bc xr xl 11)
(blowfish-R xl xr 12) (blowfish-R bc xl xr 12)
(blowfish-R xr xl 13) (blowfish-R bc xr xl 13)
(blowfish-R xl xr 14) (blowfish-R bc xl xr 14)
(blowfish-R xr xl 15) (blowfish-R bc xr xl 15)
(let ((xl (bitwise-xor xl (dictionary-ref-with-index (blowfish-p bc) blowfish-rounds))) (let ((xl (bitwise-xor xl (dictionary-ref-with-index (blowfish-p bc) blowfish-rounds)))
(xr (bitwise-xor xr (dictionary-ref-with-index (blowfish-p bc) (+ blowfish-rounds 1))))) (xr (bitwise-xor xr (dictionary-ref-with-index (blowfish-p bc) (+ blowfish-rounds 1)))))
@ -1209,22 +1209,22 @@
;; (s3 (blowfish-s3 bc)) ;; (s3 (blowfish-s3 bc))
) )
(blowfish-R xl xr 17) (blowfish-R bc xl xr 17)
(blowfish-R xr xl 16) (blowfish-R bc xr xl 16)
(blowfish-R xl xr 15) (blowfish-R bc xl xr 15)
(blowfish-R xr xl 14) (blowfish-R bc xr xl 14)
(blowfish-R xl xr 13) (blowfish-R bc xl xr 13)
(blowfish-R xr xl 12) (blowfish-R bc xr xl 12)
(blowfish-R xl xr 11) (blowfish-R bc xl xr 11)
(blowfish-R xr xl 10) (blowfish-R bc xr xl 10)
(blowfish-R xl xr 9) (blowfish-R bc xl xr 9)
(blowfish-R xr xl 8) (blowfish-R bc xr xl 8)
(blowfish-R xl xr 7) (blowfish-R bc xl xr 7)
(blowfish-R xr xl 6) (blowfish-R bc xr xl 6)
(blowfish-R xl xr 5) (blowfish-R bc xl xr 5)
(blowfish-R xr xl 4) (blowfish-R bc xr xl 4)
(blowfish-R xl xr 3) (blowfish-R bc xl xr 3)
(blowfish-R xr xl 2) (blowfish-R bc xr xl 2)
(let ((xl (bitwise-xor xl (vector-ref (blowfish-p bc) 1))) (let ((xl (bitwise-xor xl (vector-ref (blowfish-p bc) 1)))
(xr (bitwise-xor xr (vector-ref (blowfish-p bc) 0)))) (xr (bitwise-xor xr (vector-ref (blowfish-p bc) 0))))
@ -1260,7 +1260,7 @@
(dictionary-set-with-index! data 1 (vector-ref keyvec (remainder (+ j 2) keylen))) (dictionary-set-with-index! data 1 (vector-ref keyvec (remainder (+ j 2) keylen)))
(dictionary-set-with-index! data 0 (vector-ref keyvec (remainder (+ j 3) keylen))) (dictionary-set-with-index! data 0 (vector-ref keyvec (remainder (+ j 3) keylen)))
)) ))
(display "FOO!") ;;(display "FOO")
(dictionary-set-with-index! (blowfish-p bc) i (dictionary-set-with-index! (blowfish-p bc) i
(bitwise-xor (bitwise-xor
(dictionary-ref-with-index (blowfish-p bc) i) (dictionary-ref-with-index (blowfish-p bc) i)