blowfish fixes - 4

This commit is contained in:
erana 2012-01-20 18:01:36 +09:00
parent f7ee4a9341
commit f62e4958a6
1 changed files with 23 additions and 18 deletions

View File

@ -1242,12 +1242,13 @@
(dictionary-set! data 1 (vector-ref keyvec (remainder (+ j 2) keylen))) (dictionary-set! data 1 (vector-ref keyvec (remainder (+ j 2) keylen)))
(dictionary-set! data 0 (vector-ref keyvec (remainder (+ j 3) keylen))) (dictionary-set! data 0 (vector-ref keyvec (remainder (+ j 3) keylen)))
)) ))
(dictionary-set! (blowfish-p bc) i (bitwise-xor (dictionary-set-with-index! (blowfish-p bc) i
(dictionary-ref-with-index (blowfish-p bc) i) (bitwise-xor
(+ (dictionary-ref-with-index data 0) (dictionary-ref-with-index (blowfish-p bc) i)
(dictionary-ref-with-index data 1) (+ (dictionary-ref-with-index data 0)
(dictionary-ref-with-index data 2) (dictionary-ref-with-index data 1)
(dictionary-ref-with-index data 3)))) (dictionary-ref-with-index data 2)
(dictionary-ref-with-index data 3))))
) )
(let ((datal 0) (let ((datal 0)
@ -1256,31 +1257,35 @@
(do ((i 0 (+ 2))) (do ((i 0 (+ 2)))
((>= i (+ blowfish-rounds 2))0) ((>= i (+ blowfish-rounds 2))0)
(blowfish-encrypt bc datal datar) (blowfish-encrypt bc datal datar)
(vector-set! (blowfish-p bc) i datal) (dictionary-set-with-index! (blowfish-p bc) i datal)
(vector-set! (blowfish-p bc) (+ i 1) datar) (dictionary-set-with-index! (blowfish-p bc) (+ i 1) datar)
) )
(do ((i 0 (+ 2))) (do ((i 0 (+ 2)))
((>= i 256)0) ((>= i 256)0)
(vector-set! (blowfish-s0 bc) i datal) (blowfish-encrypt bc datal datar)
(vector-set! (blowfish-s0 bc) (+ i 1) datar)) (dictionary-set-with-index! (blowfish-s0 bc) i datal)
(dictionary-set-with-index! (blowfish-s0 bc) (+ i 1) datar))
(do ((i 0 (+ 2))) (do ((i 0 (+ 2)))
((>= i 256)0) ((>= i 256)0)
(vector-set! (blowfish-s1 bc) i datal) (blowfish-encrypt bc datal datar)
(vector-set! (blowfish-s1 bc) (+ i 1) datar)) (dictionary-set-with-index! (blowfish-s1 bc) i datal)
(dictionary-set-with-index! (blowfish-s1 bc) (+ i 1) datar))
(do ((i 0 (+ 2))) (do ((i 0 (+ 2)))
((>= i 256)0) ((>= i 256)0)
(vector-set! (blowfish-s2 bc) i datal) (blowfish-encrypt bc datal datar)
(vector-set! (blowfish-s2 bc) (+ i 1) datar)) (dictionary-set-with-index! (blowfish-s2 bc) i datal)
(dictionary-set-with-index! (blowfish-s2 bc) (+ i 1) datar))
(do ((i 0 (+ 2))) (do ((i 0 (+ 2)))
((>= i 256)0) ((>= i 256)0)
(vector-set! (blowfish-s3 bc) i datal) (blowfish-encrypt bc datal datar)
(vector-set! (blowfish-s3 bc) (+ i 1) datar)) (dictionary-set-with-index! (blowfish-s3 bc) i datal)
(dictionary-set-with-index! (blowfish-s3 bc) (+ i 1) datar))
(do ((i 0 (+ i 1))) (do ((i 0 (+ i 1)))
((>= i 255)0);; ((>= i 255)0);;
(do ((j (+ i 1) (+ j 1))) (do ((j (+ i 1) (+ j 1)))
(if (or (= (vector-ref (blowfish-s0 bc) i) (if (or (= (dictionary-ref-with-index (blowfish-s0 bc) i)
(vector-ref (blowfish-s0 bc) j)) (dictionary-ref-with-index (blowfish-s0 bc) j))
(= (vector-ref (blowfish-s1 bc) i) (= (vector-ref (blowfish-s1 bc) i)
(vector-ref (blowfish-s1 bc) j)) (vector-ref (blowfish-s1 bc) j))
(= (vector-ref (blowfish-s2 bc) i) (= (vector-ref (blowfish-s2 bc) i)