diff --git a/md5.lisp b/md5.lisp index 6bf04b6..5ac5a16 100644 --- a/md5.lisp +++ b/md5.lisp @@ -404,11 +404,15 @@ bounded by start and end, which must be numeric bounding-indices." (declare (type (integer 0 63) amount)) (copy-to-buffer sequence start amount buffer buffer-index) (setq start (the fixnum (+ start amount))) - (when (>= start end) - (setf (md5-state-buffer-index state) (+ buffer-index amount)) - (return-from update-md5-state state))) - (fill-block-ub8 block buffer 0) - (update-md5-block regs block)) + (let ((new-index (+ buffer-index amount))) + (when (= new-index 64) + (fill-block-ub8 block buffer 0) + (update-md5-block regs block) + (setq new-index 0)) + (when (>= start end) + (setf (md5-state-buffer-index state) new-index) + (incf (md5-state-amount state) length) + (return-from update-md5-state state))))) ;; Handle main-part and new-rest (etypecase sequence ((simple-array (unsigned-byte 8) (*))