Commits

Anonymous committed a3473f1

added optional blob size argument for encryptor/decryptor

  • Participants
  • Parent commits 3979666

Comments (0)

Files changed (2)

File blowfish.scm

 
 (define (make-blowfish-encrypt-decrypt key func)
   (let ((ctx (blowfish-init key (blob-size key))))
-                (lambda (input)
+                (lambda (input #!optional (size (blob-size input)))
                   (let loop ((i 0)
-                             (e (blob-size input))
-                             (result (make-blob (blob-size input))))
+                             (e size)
+                             (result (make-blob size)))
                     (when (< i e)
                       (or
                         (<= 8 (- e i))
-                        (error "blowfish invalid encryptor/decryptor block size" (blob-size input)))
+                        (error "blowfish invalid encryptor/decryptor block size" size))
                       (func ctx input result i)
                       (loop (+ i 8) e result))
                     result))))

File tests/run.scm

 (test '#${d23f33dfb41ba730} (enc '#${0100000002000000}))
 (test '#${0100000002000000} (dec (enc '#${0100000002000000})))
 
+(test '#${d23f33dfb41ba730} (enc '#${0100000002000000 0100000002000000} 8))
+
+(test-error (enc '#${0100000002000000} 9))
 (test-error (enc '#${01 02 03}))
 (test-error (dec '#${01 02 03 04 05 06 07}))