blowfish encryption - set-key - 1
This commit is contained in:
parent
34b9159fa9
commit
8a5d8fb45d
|
@ -1212,7 +1212,8 @@
|
|||
(set! ret_xr xl)
|
||||
)))
|
||||
|
||||
(define (blowfish-set-key bc key keylen)
|
||||
(define (blowfish-set-key bc key keylen) ;; NOTE key is a table
|
||||
(let ((data (make-table)))
|
||||
|
||||
(do ((i 0 (+ i 1)))
|
||||
((=> i (+ blowfish-rounds 2))0)
|
||||
|
@ -1229,5 +1230,26 @@
|
|||
(do ((i 0 (+ i 1))
|
||||
(j 0 (+ j 1)))
|
||||
((>= i (+ blowfish-rounds 2))0)
|
||||
(if BIG-ENDIAN-HOST
|
||||
(begin
|
||||
(table-set! data 0 (table-ref key j))
|
||||
(table-set! data 1 (table-ref key (remainder (+ j 1) keylen)))
|
||||
(table-set! data 2 (table-ref key (remainder (+ j 2) keylen)))
|
||||
(table-set! data 3 (table-ref key (remainder (+ j 3) keylen)))
|
||||
)
|
||||
(begin
|
||||
(table-set! data 3 (table-ref key j))
|
||||
(table-set! data 2 (table-ref key (remainder (+ j 1) keylen)))
|
||||
(table-set! data 1 (table-ref key (remainder (+ j 2) keylen)))
|
||||
(table-set! data 0 (table-ref key (remainder (+ j 3) keylen)))
|
||||
))
|
||||
(vector-set! (blowfish-p bc) i (bitwise-xor
|
||||
(vector-ref (blowfish-p bc) i)
|
||||
(+ (table-ref data 0)
|
||||
(table-ref data 1)
|
||||
(table-ref data 2)
|
||||
(table-ref data 3))))
|
||||
|
||||
))
|
||||
|
||||
)
|
Loading…
Reference in New Issue