anchor.diff:                  (declare (type simple-octet-vector plaintext ciphertext))
                   (declare (type index ciphertext-start ciphertext-end plaintext-start))
                   (declare (ignorable handle-final-block))
  -                (let ,block-length-binding
  -                  (loop with offset of-type index = ciphertext-start
  -                     with decrypt-function of-type function = (decrypt-function cipher)
  -                     while (<= offset (- ciphertext-end ,block-length-expr))
  -                     do (funcall decrypt-function cipher ciphertext offset
  -                                 plaintext plaintext-start)
  -                     (incf offset ,block-length-expr)
  -                     (incf plaintext-start ,block-length-expr)
  -                     finally (return-from decrypt-with-mode
  -                               (let ((n-bytes-decrypted (- offset ciphertext-start)))
  -                                 (values n-bytes-decrypted n-bytes-decrypted)))))))
  -           (message-length (cipher-specializer block-length-binding
  -                                                block-length-expr)
  +                (loop with offset of-type index = ciphertext-start
  +                      with decrypt-function of-type function = (decrypt-function cipher)
  +                      while (<= offset (- ciphertext-end ,block-length-expr))
  +                      do (funcall decrypt-function cipher ciphertext offset
  +                                  plaintext plaintext-start)
  +                         (incf offset ,block-length-expr)
  +                         (incf plaintext-start ,block-length-expr)
  +                      finally (return-from decrypt-with-mode
  +                                (let ((n-bytes-decrypted (- offset ciphertext-start)))
  +                                  (values n-bytes-decrypted n-bytes-decrypted))))))
  +           (message-length (cipher-specializer block-length-expr)
                `(defmethod encrypted-message-length ((cipher ,cipher-specializer)
                                                      (mode ecb-mode) length
                                                      &optional handle-final-block)
                   (declare (ignore handle-final-block))
  -                (let ,block-length-binding
  -                  ;; Just count the number of full blocks.
  -                  (* (truncate length ,block-length-expr) ,block-length-expr)))))
  +                (* (truncate length ,block-length-expr) ,block-length-expr))))
     (define-mode-function encrypt decrypt message-length))
   
    
   ;;; CBC mode
   
  -(macrolet ((encrypt (cipher-specializer block-length-binding
  -                                                block-length-expr)
  +(macrolet ((encrypt (cipher-specializer block-length-expr)
                `(defmethod encrypt-with-mode ((cipher ,cipher-specializer)
                                               (mode cbc-mode) plaintext ciphertext
                                               plaintext-start plaintext-end
  
positive.code:               (declare (type simple-octet-vector plaintext ciphertext))
                (declare (type index plaintext-start plaintext-end ciphertext-start))
                (declare (ignorable handle-final-block))
                (let ,block-length-binding
                  (loop with iv of-type (simple-octet-vector ,(if (constantp `,block-length-expr)
                                                                  `,block-length-expr
                                                                  '*)) = (iv mode)
                     with iv-position of-type (integer 0 ,(if (constantp `,block-length-expr)
                                                              `(,block-length-expr)
                                                              '*)) = (iv-position mode)
                     with encrypt-function of-type function = (encrypt-function cipher)
                     for i of-type index from plaintext-start below plaintext-end
                     for j of-type index from ciphertext-start
                     do (when (zerop iv-position)
                          (funcall encrypt-function cipher iv 0 iv 0))
                     (let ((b (logxor (aref plaintext i) (aref iv iv-position))))
                       (setf (aref ciphertext j) b)
                       (setf (aref iv iv-position) b)
                       (setf iv-position (mod (1+ iv-position) ,block-length-expr)))
                     finally (return-from encrypt-with-mode
                               (let ((n-bytes-encrypted (- plaintext-end plaintext-start)))
                                 (setf (iv-position mode) iv-position)
                                 (values n-bytes-encrypted n-bytes-encrypted)))))))
             (decrypt (cipher-specializer block-length-binding
                                                  block-length-expr)
               `(defmethod decrypt-with-mode ((cipher ,cipher-specializer)
                                              (mode cfb-mode) ciphertext plaintext
                                              ciphertext-start ciphertext-end
  
negative.code:                 (declare (type simple-octet-vector plaintext ciphertext))
                  (declare (type index plaintext-start plaintext-end ciphertext-start))
                  (declare (ignorable handle-final-block))
                  (loop with iv of-type (simple-octet-vector ,(if (constantp `,block-length-expr)
                                                                  `,block-length-expr
                                                                  '*)) = (iv mode)
                        with offset of-type index = plaintext-start
                        with encrypt-function of-type function = (encrypt-function cipher)
                        while (<= offset (- plaintext-end ,block-length-expr))
                        do (xor-block ,block-length-expr iv plaintext offset
                               ciphertext ciphertext-start)
                           (funcall encrypt-function cipher ciphertext ciphertext-start
                                    ciphertext ciphertext-start)
                           (replace iv ciphertext :start1 0 :end1 ,block-length-expr
                                    :start2 ciphertext-start)
                           (incf offset ,block-length-expr)
                           (incf ciphertext-start ,block-length-expr)
                        finally (return-from encrypt-with-mode
                                  (let ((n-bytes-encrypted (- offset plaintext-start)))
                                    (values n-bytes-encrypted n-bytes-encrypted))))))
             (decrypt (cipher-specializer block-length-expr)
               `(defmethod decrypt-with-mode ((cipher ,cipher-specializer)
                                              (mode cbc-mode) ciphertext plaintext
                                              ciphertext-start ciphertext-end
  