(2 . "ZLIB")
(3 . "BZIP2")))
-(defconst epg-invalid-recipients-alist
+(defconst epg-invalid-recipients-reason-alist
'((0 . "No specific reason given")
(1 . "Not Found")
(2 . "Ambigious specification")
(9 . "Not a secret key")
(10 . "Key not trusted")))
-(defconst epg-delete-problem-alist
+(defconst epg-delete-problem-reason-alist
'((1 . "No such key")
(2 . "Must delete secret key first")
(3 . "Ambigious specification")))
+(defconst epg-import-ok-reason-alist
+ '((0 . "Not actually changed")
+ (1 . "Entirely new key")
+ (2 . "New user IDs")
+ (4 . "New signatures")
+ (8 . "New subkeys")
+ (16 . "Contains private key")))
+
+(defconst epg-import-problem-reason-alist
+ '((0 . "No specific reason given")
+ (1 . "Invalid Certificate")
+ (2 . "Issuer Certificate missing")
+ (3 . "Certificate Chain too long")
+ (4 . "Error storing certificate")))
+
(defvar epg-key-validity-alist
'((?o . unknown)
(?i . invalid)
(defun epg-status-NODATA (process string)
(epg-context-set-result-for
epg-context 'error
- (cons (cons 'no-data (string-to-number string))
+ (cons (list 'no-data (cons 'reason (string-to-number string)))
(epg-context-result-for epg-context 'error))))
(defun epg-status-UNEXPECTED (process string)
(epg-context-set-result-for
epg-context 'error
- (cons (cons 'unexpected (string-to-number string))
+ (cons (list 'unexpected (cons 'reason (string-to-number string)))
(epg-context-result-for epg-context 'error))))
(defun epg-status-KEYEXPIRED (process string)
(epg-context-set-result-for
epg-context 'error
- (cons (cons 'key-expired string)
+ (cons (list 'key-expired (cons 'expiration-time string))
(epg-context-result-for epg-context 'error))))
(defun epg-status-KEYREVOKED (process string)
(epg-context-set-result-for
epg-context 'error
(cons (list 'invalid-recipient
- (string-to-number (match-string 1 string))
- (match-string 2 string))
+ (cons 'reason
+ (string-to-number (match-string 1 string)))
+ (cons 'requested-recipient
+ (match-string 2 string)))
(epg-context-result-for epg-context 'error)))))
(defun epg-status-NO_RECP (process string)
(if (string-match "\\`\\([0-9]+\\)" string)
(epg-context-set-result-for
epg-context 'error
- (cons (cons 'delete-problem (string-to-number (match-string 1 string)))
+ (cons (list 'delete-problem
+ (cons 'reason (string-to-number (match-string 1 string))))
(epg-context-result-for epg-context 'error)))))
(defun epg-status-SIG_CREATED (process string)
(cons '(key-not-created)
(epg-context-result-for epg-context 'error))))
+(defun epg-status-IMPORTED (process string)
+ (if (string-match "\\`\\([^ ]+\\) \\(.*\\)" string)
+ (let* ((key-id (match-string 1 string))
+ (user-id (match-string 2 string))
+ (entry (assoc key-id epg-user-id-alist)))
+ (if entry
+ (setcdr entry user-id)
+ (setq epg-user-id-alist (cons (cons key-id user-id)
+ epg-user-id-alist)))
+ (epg-context-set-result-for
+ epg-context 'import
+ (cons (list (cons 'key-id key-id)
+ (cons 'user-id user-id))
+ (epg-context-result-for epg-context 'import))))))
+
+(defun epg-status-IMPORT_OK (process string)
+ (let ((result (epg-context-result-for epg-context 'import)))
+ (if (and result
+ (string-match "\\`\\([0-9]+\\)\\( \\(.+\\)\\)?" string))
+ (setcar result
+ (append (list (cons 'reason
+ (string-to-number
+ (match-string 1 string))))
+ (if (match-beginning 2)
+ (list (cons 'fingerprint
+ (match-string 3 string))))
+ (car result))))))
+
+(defun epg-status-IMPORT_PROBLEM (process string)
+ (if (string-match "\\`\\([0-9]+\\)\\( \\(.+\\)\\)?" string)
+ (epg-context-set-result-for
+ epg-context 'error
+ (cons (cons 'import-problem
+ (append (list (cons 'reason
+ (string-to-number
+ (match-string 1 string))))
+ (if (match-beginning 2)
+ (list (cons 'fingerprint
+ (match-string 3 string)))))
+ (epg-context-result-for epg-context 'error))))))
+
(defun epg-passphrase-callback-function (context key-id handback)
(read-passwd
(if (eq key-id 'SYM)
If you are unsure, use synchronous version of this function
`epg-import-keys-from-file' or `epg-import-keys-from-string' instead."
(epg-context-set-result context nil)
- (epg-context-set-output-file context (epg-make-temp-file "epg-output"))
(epg-start context (list "--import" (epg-data-file keys)))
(when (epg-data-string keys)
(if (eq (process-status (epg-context-process context)) 'run)
(epg-wait-for-completion context)
(if (epg-context-result-for context 'error)
(error "Import keys failed: %S"
- (epg-context-result-for context 'error)))
- (epg-read-output context))
+ (epg-context-result-for context 'error))))
(epg-reset context)))
;;;###autoload
(epg-import-keys-1 context (epg-make-data-from-string keys)))
;;;###autoload
+(defun epg-start-receive-keys (context key-id-list)
+ "Initiate a receive key operation.
+KEY-ID-LIST is a list of key IDs.
+
+If you use this function, you will need to wait for the completion of
+`epg-gpg-program' by using `epg-wait-for-completion' and call
+`epg-reset' to clear a temporaly output file.
+If you are unsure, use synchronous version of this function
+`epg-generate-key-from-file' or `epg-generate-key-from-string' instead."
+ (epg-context-set-result context nil)
+ (epg-start context (cons "--recv-keys" key-id-list)))
+
+;;;###autoload
+(defun epg-import-keys-from-server (context keys)
+ "Add keys from server.
+KEYS is a list of key IDs"
+ (unwind-protect
+ (progn
+ (epg-start-receive-keys context (epg-make-data-from-file parameters))
+ (epg-wait-for-completion context)
+ (if (epg-context-result-for context 'error)
+ (error "Import keys failed: %S"
+ (epg-context-result-for context 'error))))
+ (epg-reset context)))
+
+;;;###autoload
+(defalias 'epg-receive-keys 'epg-import-keys-from-server)
+
+;;;###autoload
(defun epg-start-delete-keys (context keys &optional allow-secret)
"Initiate an delete keys operation.