(defun epg-progress-callback-function (context what char current total
                                               handback)
-  (message "%s: %d%% (%d/%d)" what (/ current 1.0 total) current total))
+  (message "%s: %d%% (%d/%d)" what (if (> total 0) (/ current 1.0 total) 0)
+          current total))
 
 (defun epg--list-keys-1 (context name mode)
   (let ((args (append (if epg-gpg-home-directory