diff options
| author | Reiner Steib | 2006-03-21 21:24:27 +0000 |
|---|---|---|
| committer | Reiner Steib | 2006-03-21 21:24:27 +0000 |
| commit | 7b97a7a56cafd4d955039c38e5cdfc3868488356 (patch) | |
| tree | 9f22ff1ec2a5a432815e16d8f2bf9bf4727e70c5 | |
| parent | 6c3ba92180c2195d109f52f3c9654c749f3cd645 (diff) | |
| download | emacs-7b97a7a56cafd4d955039c38e5cdfc3868488356.tar.gz emacs-7b97a7a56cafd4d955039c38e5cdfc3868488356.zip | |
Sync with version from Gnus (only whitespace changes).
| -rw-r--r-- | lisp/pgg-gpg.el | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lisp/pgg-gpg.el b/lisp/pgg-gpg.el index 28512dce8fc..a9608b7f4f2 100644 --- a/lisp/pgg-gpg.el +++ b/lisp/pgg-gpg.el | |||
| @@ -163,24 +163,22 @@ Optional ALL non-nil means search all keys, including secret keys." | |||
| 163 | (let ((args (list "--with-colons" "--no-greeting" "--batch" | 163 | (let ((args (list "--with-colons" "--no-greeting" "--batch" |
| 164 | (if all "--list-secret-keys" "--list-keys") | 164 | (if all "--list-secret-keys" "--list-keys") |
| 165 | string)) | 165 | string)) |
| 166 | (key-regexp (concat "^\\(sec\\|pub\\)" | 166 | (key-regexp (concat "^\\(sec\\|pub\\)" |
| 167 | ":[^:]*:[^:]*:[^:]*:\\([^:]*\\):[^:]*" | 167 | ":[^:]*:[^:]*:[^:]*:\\([^:]*\\):[^:]*" |
| 168 | ":[^:]*:[^:]*:[^:]*:\\([^:]*\\):")) | 168 | ":[^:]*:[^:]*:[^:]*:\\([^:]*\\):"))) |
| 169 | ) | ||
| 170 | (with-temp-buffer | 169 | (with-temp-buffer |
| 171 | (apply #'call-process pgg-gpg-program nil t nil args) | 170 | (apply #'call-process pgg-gpg-program nil t nil args) |
| 172 | (goto-char (point-min)) | 171 | (goto-char (point-min)) |
| 173 | (if (re-search-forward key-regexp | 172 | (if (re-search-forward key-regexp |
| 174 | nil t) | 173 | nil t) |
| 175 | (match-string 3))))) | 174 | (match-string 3))))) |
| 176 | 175 | ||
| 177 | (defun pgg-gpg-key-id-from-key-owner (key-owner) | 176 | (defun pgg-gpg-key-id-from-key-owner (key-owner) |
| 178 | (cond ((not key-owner) nil) | 177 | (cond ((not key-owner) nil) |
| 179 | ;; Extract bare key id from outermost paired angle brackets, if any: | 178 | ;; Extract bare key id from outermost paired angle brackets, if any: |
| 180 | ((string-match "[^<]*<\\(.+\\)>[^>]*" key-owner) | 179 | ((string-match "[^<]*<\\(.+\\)>[^>]*" key-owner) |
| 181 | (substring key-owner (match-beginning 1)(match-end 1))) | 180 | (substring key-owner (match-beginning 1)(match-end 1))) |
| 182 | (key-owner)) | 181 | (key-owner))) |
| 183 | ) | ||
| 184 | 182 | ||
| 185 | (defun pgg-gpg-encrypt-region (start end recipients &optional sign passphrase) | 183 | (defun pgg-gpg-encrypt-region (start end recipients &optional sign passphrase) |
| 186 | "Encrypt the current region between START and END. | 184 | "Encrypt the current region between START and END. |
| @@ -242,15 +240,15 @@ passphrase cache or user." | |||
| 242 | (insert-buffer-substring current-buffer) | 240 | (insert-buffer-substring current-buffer) |
| 243 | (pgg-decode-armor-region (point-min) (point-max)))) | 241 | (pgg-decode-armor-region (point-min) (point-max)))) |
| 244 | (secret-keys (pgg-gpg-lookup-all-secret-keys)) | 242 | (secret-keys (pgg-gpg-lookup-all-secret-keys)) |
| 245 | ;; XXX the user is stuck if they need to use the passphrase for | 243 | ;; XXX the user is stuck if they need to use the passphrase for |
| 246 | ;; any but the first secret key for which the message is | 244 | ;; any but the first secret key for which the message is |
| 247 | ;; encrypted. ideally, we would incrementally give them a | 245 | ;; encrypted. ideally, we would incrementally give them a |
| 248 | ;; chance with subsequent keys each time they fail with one. | 246 | ;; chance with subsequent keys each time they fail with one. |
| 249 | (key (pgg-gpg-select-matching-key message-keys secret-keys)) | 247 | (key (pgg-gpg-select-matching-key message-keys secret-keys)) |
| 250 | (key-owner (and key (pgg-gpg-lookup-key-owner key t))) | 248 | (key-owner (and key (pgg-gpg-lookup-key-owner key t))) |
| 251 | (key-id (pgg-gpg-key-id-from-key-owner key-owner)) | 249 | (key-id (pgg-gpg-key-id-from-key-owner key-owner)) |
| 252 | (pgg-gpg-user-id (or key-id key | 250 | (pgg-gpg-user-id (or key-id key |
| 253 | pgg-gpg-user-id pgg-default-user-id)) | 251 | pgg-gpg-user-id pgg-default-user-id)) |
| 254 | (passphrase (or passphrase | 252 | (passphrase (or passphrase |
| 255 | (when (not pgg-gpg-use-agent) | 253 | (when (not pgg-gpg-use-agent) |
| 256 | (pgg-read-passphrase | 254 | (pgg-read-passphrase |
| @@ -280,7 +278,7 @@ passphrase cache or user." | |||
| 280 | (loop for message-key in message-keys | 278 | (loop for message-key in message-keys |
| 281 | for message-key-id = (and (equal (car message-key) 1) | 279 | for message-key-id = (and (equal (car message-key) 1) |
| 282 | (cdr (assq 'key-identifier | 280 | (cdr (assq 'key-identifier |
| 283 | (cdr message-key)))) | 281 | (cdr message-key)))) |
| 284 | for key = (and message-key-id (pgg-lookup-key message-key-id 'encrypt)) | 282 | for key = (and message-key-id (pgg-lookup-key message-key-id 'encrypt)) |
| 285 | when (and key (member key secret-keys)) return key)) | 283 | when (and key (member key secret-keys)) return key)) |
| 286 | 284 | ||