- (let* ((marker
- (set-marker (make-marker)
- (and (re-search-forward "^=")
- (match-beginning 0))))
- (checksum (buffer-substring (point) (+ 4 (point)))))
- (delete-region marker (point-max))
- (base64-decode-region (point-min) marker)
- (when (fboundp 'pgg-parse-crc24-string)
- (or pgg-ignore-packet-checksum
- (string-equal
- (base64-encode-string (pgg-parse-crc24-string
- (buffer-string)))
- checksum)
- (error "PGP packet checksum does not match")))))
+ (if (re-search-forward "^=\\([A-Za-z0-9+/]\\{4\\}\\)$" nil t)
+ (let ((p (match-beginning 0))
+ (checksum (match-string 1)))
+ (delete-region p (point-max))
+ (if (ignore-errors (base64-decode-region (point-min) p))
+ (or (not (fboundp 'pgg-parse-crc24-string))
+ pgg-ignore-packet-checksum
+ (string-equal (base64-encode-string (pgg-parse-crc24-string
+ (buffer-string)))
+ checksum)
+ (progn
+ (message "PGP packet checksum does not match")
+ nil))
+ (message "PGP packet contain invalid base64")
+ nil))
+ (message "PGP packet checksum not found")
+ nil))