("Pass phrase is good." .
"GOOD_PASSPHRASE")
("Cannot decrypt message. It can only be decrypted by:" .
- "CANNOT_DECRYPT")))
+ "CANNOT_DECRYPT")
+ ("Good signature made .* by key:" .
+ "GOOD_SIGNATURE")
+ ("BAD signature made .* by key:" .
+ "BAD_SIGNATURE")
+ ("Error .* checking signature: " .
+ "ERROR_SIGNATURE")
+ ("Signature by unknown keyid: " .
+ "UNKNOWN_SIGNATURE")))
(defvar epg-pgp50i-status nil)
(defun epg-pgp50i--start (context program args)
- (let ((args (append '("--headers" "--language=us" "--batchmode=0" "--force")
+ (let ((args (append '("--headers" "--language=us")
(if (epg-context-armor context) '("--armor"))
(if (epg-context-textmode context) '("--textmode"))
(if (epg-context-output-file context)
(accept-process-output (epg-context-process context) 1))
(buffer-substring (point) (progn (end-of-line) (point))))))
-(defun epg-pgp50i--status-ENTER_PASSPHRASE (context status)
+(defun epg-pgp50i--status-ENTER_PASSPHRASE (context message)
(epg--status-GET_HIDDEN context "passphrase."))
-(defun epg-pgp50i--status-NEED_PASSPHRASE_TO_DECRYPT_KEY (context status)
+(defun epg-pgp50i--read-key (context)
(let ((line (epg-pgp50i--wait-for-line context))
- user-id entry)
+ key-id user-id-list)
(when (and line
(string-match "[ 0-9]+ bits, Key ID \\([0-9A-F]+\\)" line))
- (setq epg-key-id (match-string 1 line)
- line (epg-pgp50i--wait-for-line context))
- (when (and line
+ (setq key-id (match-string 1 line))
+ (when (and (setq line (epg-pgp50i--wait-for-line context))
(string-match "\"\\([^\"]+\\)\"" line))
- (setq user-id (match-string 1 line)
- entry (assoc epg-key-id epg-user-id-alist))
- (if entry
- (setcdr entry user-id)
- (setq epg-user-id-alist (cons (cons epg-key-id user-id)
- epg-user-id-alist)))))))
+ (setq user-id-list (cons (match-string 1 line) user-id-list)))
+ (cons key-id user-id-list))))
+
+(defun epg-pgp50i--status-NEED_PASSPHRASE_TO_DECRYPT_KEY (context message)
+ (let* ((key (epg-pgp50i--read-key context))
+ (entry (assoc (car key) epg-user-id-alist)))
+ (if entry
+ (setcdr entry (car (cdr key)))
+ (setq epg-user-id-alist (cons (cons (car key) (car (cdr key)))
+ epg-user-id-alist)))
+ (setq epg-key-id (car key))))
+
+(defun epg-pgp50i--status-GOOD_SIGNATURE (context message)
+ (let ((key (epg-pgp50i--read-key context)))
+ (epg--status-*SIG context 'good (concat (car key) " " (car (cdr key))))))
(defadvice epg-start-decrypt
(around epg-pgp50i activate)
(if (eq (epg-context-protocol (ad-get-arg 0)) 'CMS)
ad-do-it
- (unless (epg-data-file (ad-get-arg 1))
- (error "Not a file"))
- (epg-context-set-operation context 'decrypt)
- (epg-context-set-result (ad-get-arg 0) nil)
- (epg-pgp50i--start context epg-pgp50i-pgpv-program
- (list (epg-data-file (ad-get-arg 1))))))
+ (let ((context (ad-get-arg 0))
+ (cipher (ad-get-arg 1)))
+ (unless (epg-data-file cipher)
+ (error "Not a file"))
+ (epg-context-set-operation context 'decrypt)
+ (epg-context-set-result context nil)
+ (epg-pgp50i--start context epg-pgp50i-pgpv-program
+ (list "--batchmode=0" "--force"
+ (epg-data-file cipher))))))
(defadvice epg-start-verify
(around epg-pgp50i activate)
(if (eq (epg-context-protocol (ad-get-arg 0)) 'CMS)
ad-do-it
- (error "Not implemented yet")))
+ (let ((context (ad-get-arg 0))
+ (signature (ad-get-arg 1))
+ (signed-text (ad-get-arg 2)))
+ (epg-context-set-operation context 'verify)
+ (epg-context-set-result context nil)
+ (if signed-text
+ ;; Detached signature.
+ (if (epg-data-file signed-text)
+ (epg-pgp50i--start context
+ epg-pgp50i-pgpv-program
+ (list "--batchmode=1" "--force"
+ (epg-data-file signature)
+ (epg-data-file signed-text)))
+ (epg-pgp50i--start context
+ epg-pgp50i-pgpv-program
+ (list "--batchmode=1" "--force"
+ (epg-data-file signature)))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-string (epg-context-process context)
+ (epg-data-string signed-text)))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-eof (epg-context-process context))))
+ ;; Normal (or cleartext) signature.
+ (if (epg-data-file signature)
+ (epg-pgp50i--start context
+ epg-pgp50i-pgpv-program
+ (list "--batchmode=1" "--force"
+ (epg-data-file signature)))
+ (epg-pgp50i--start context
+ epg-pgp50i-pgpv-program
+ (list "--batchmode=1" "--force"))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-string (epg-context-process context)
+ (epg-data-string signature)))
+ (if (eq (process-status (epg-context-process context)) 'run)
+ (process-send-eof (epg-context-process context))))))))
(defadvice epg-start-sign
(around epg-pgp50i activate)