1 ;;; mml2015.el --- MIME Security with Pretty Good Privacy (PGP)
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
7 ;; Keywords: PGP MIME MML
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published
13 ;; by the Free Software Foundation; either version 3, or (at your
14 ;; option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; RFC 2015 is updated by RFC 3156, this file should be compatible
35 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
37 (eval-when-compile (require 'cl
))
43 (defvar mc-pgp-always-sign
)
45 (declare-function epg-check-configuration
"ext:epg-config"
46 (config &optional minimum-version
))
47 (declare-function epg-configuration
"ext:epg-config" ())
49 (defvar mml2015-use
(or
53 (epg-check-configuration (epg-configuration))
58 ;; Avoid the "Recursive load suspected" error
60 (let ((recursive-load-depth-limit 100))
62 (and (fboundp 'pgg-sign-region
)
67 (and (fboundp 'gpg-sign-detached
)
71 (and (fboundp 'mc-encrypt-generic
)
72 (fboundp 'mc-sign-generic
)
73 (fboundp 'mc-cleanup-recipient-headers
)
75 "The package used for PGP/MIME.
76 Valid packages include `epg', `pgg', `gpg' and `mailcrypt'.")
78 ;; Something is not RFC2015.
79 (defvar mml2015-function-alist
80 '((mailcrypt mml2015-mailcrypt-sign
81 mml2015-mailcrypt-encrypt
82 mml2015-mailcrypt-verify
83 mml2015-mailcrypt-decrypt
84 mml2015-mailcrypt-clear-verify
85 mml2015-mailcrypt-clear-decrypt
)
90 mml2015-gpg-clear-verify
91 mml2015-gpg-clear-decrypt
)
96 mml2015-pgg-clear-verify
97 mml2015-pgg-clear-decrypt
)
102 mml2015-epg-clear-verify
103 mml2015-epg-clear-decrypt
))
104 "Alist of PGP/MIME functions.")
106 (defvar mml2015-result-buffer nil
)
108 (defcustom mml2015-unabbrev-trust-alist
109 '(("TRUST_UNDEFINED" . nil
)
110 ("TRUST_NEVER" . nil
)
111 ("TRUST_MARGINAL" . t
)
113 ("TRUST_ULTIMATE" . t
))
114 "Map GnuPG trust output values to a boolean saying if you trust the key."
116 :group
'mime-security
117 :type
'(repeat (cons (regexp :tag
"GnuPG output regexp")
118 (boolean :tag
"Trust key"))))
120 (defcustom mml2015-verbose mml-secure-verbose
121 "If non-nil, ask the user about the current operation more verbosely."
122 :group
'mime-security
125 (defcustom mml2015-cache-passphrase mml-secure-cache-passphrase
126 "If t, cache passphrase."
127 :group
'mime-security
130 (defcustom mml2015-passphrase-cache-expiry mml-secure-passphrase-cache-expiry
131 "How many seconds the passphrase is cached.
132 Whether the passphrase is cached at all is controlled by
133 `mml2015-cache-passphrase'."
134 :group
'mime-security
137 (defcustom mml2015-signers nil
138 "A list of your own key ID which will be used to sign a message."
139 :group
'mime-security
140 :type
'(repeat (string :tag
"Key ID")))
142 (defcustom mml2015-encrypt-to-self nil
143 "If t, add your own key ID to recipient list when encryption."
144 :group
'mime-security
147 (defcustom mml2015-always-trust t
148 "If t, GnuPG skip key validation on encryption."
149 :group
'mime-security
152 ;; Extract plaintext from cleartext signature. IMO, this kind of task
153 ;; should be done by GnuPG rather than Elisp, but older PGP backends
154 ;; (such as Mailcrypt, PGG, and gpg.el) discard the output from GnuPG.
155 (defun mml2015-extract-cleartext-signature ()
157 ;; <54a15d860801080142l70b95d7dkac4bf51a86196011@mail.gmail.com>: ``I still
158 ;; believe that the right way is to use the plaintext output from GnuPG as
159 ;; it is, and mml2015-extract-cleartext-signature is just a kludge for
160 ;; misdesigned libraries like PGG, which have no ability to do that. So, I
161 ;; think it should not have descriptive documentation.''
163 ;; This function doesn't handle NotDashEscaped correctly. EasyPG handles it
165 ;; http://thread.gmane.org/gmane.emacs.gnus.general/66062/focus=66082
166 ;; http://thread.gmane.org/gmane.emacs.gnus.general/65087/focus=65109
167 (goto-char (point-min))
169 ;; We need to be careful not to strip beyond the armor headers.
170 ;; Previously, an attacker could replace the text inside our
171 ;; markup with trailing garbage by injecting whitespace into the
173 (while (looking-at "Hash:") ; The only header allowed in cleartext
174 (forward-line)) ; signatures according to RFC2440.
175 (when (looking-at "[\t ]*$")
177 (delete-region (point-min) (point))
178 (if (re-search-forward "^-----BEGIN PGP SIGNATURE-----" nil t
)
179 (delete-region (match-beginning 0) (point-max)))
180 (goto-char (point-min))
181 (while (re-search-forward "^- " nil t
)
182 (replace-match "" t t
)
185 ;;; mailcrypt wrapper
188 (autoload 'mailcrypt-decrypt
"mailcrypt")
189 (autoload 'mailcrypt-verify
"mailcrypt")
190 (autoload 'mc-pgp-always-sign
"mailcrypt")
191 (autoload 'mc-encrypt-generic
"mc-toplev")
192 (autoload 'mc-cleanup-recipient-headers
"mc-toplev")
193 (autoload 'mc-sign-generic
"mc-toplev"))
195 (defvar mc-default-scheme
)
198 (defvar mml2015-decrypt-function
'mailcrypt-decrypt
)
199 (defvar mml2015-verify-function
'mailcrypt-verify
)
201 (defun mml2015-format-error (err)
202 (if (stringp (cadr err
))
204 (format "%S" (cdr err
))))
206 (defun mml2015-mailcrypt-decrypt (handle ctl
)
208 (let (child handles result
)
209 (unless (setq child
(mm-find-part-by-type
211 "application/octet-stream" nil t
))
212 (mm-set-handle-multipart-parameter
213 mm-security-handle
'gnus-info
"Corrupted")
214 (throw 'error handle
))
216 (mm-insert-part child
)
219 (funcall mml2015-decrypt-function
)
221 (mm-set-handle-multipart-parameter
222 mm-security-handle
'gnus-details
(mml2015-format-error err
))
225 (mm-set-handle-multipart-parameter
226 mm-security-handle
'gnus-details
"Quit.")
229 (mm-set-handle-multipart-parameter
230 mm-security-handle
'gnus-info
"Failed")
231 (throw 'error handle
))
232 (setq handles
(mm-dissect-buffer t
)))
233 (mm-destroy-parts handle
)
234 (mm-set-handle-multipart-parameter
235 mm-security-handle
'gnus-info
237 (let ((sig (with-current-buffer mml2015-result-buffer
238 (mml2015-gpg-extract-signature-details))))
239 (concat ", Signer: " sig
))))
240 (if (listp (car handles
))
244 (defun mml2015-mailcrypt-clear-decrypt ()
248 (funcall mml2015-decrypt-function
)
250 (mm-set-handle-multipart-parameter
251 mm-security-handle
'gnus-details
(mml2015-format-error err
))
254 (mm-set-handle-multipart-parameter
255 mm-security-handle
'gnus-details
"Quit.")
258 (mm-set-handle-multipart-parameter
259 mm-security-handle
'gnus-info
"OK")
260 (mm-set-handle-multipart-parameter
261 mm-security-handle
'gnus-info
"Failed"))))
263 (defun mml2015-fix-micalg (alg)
265 ;; Mutt/1.2.5i has seen sending micalg=php-sha1
266 (upcase (if (string-match "^p[gh]p-" alg
)
267 (substring alg
(match-end 0))
270 (defun mml2015-mailcrypt-verify (handle ctl
)
273 (unless (setq part
(mm-find-raw-part-by-type
274 ctl
(or (mm-handle-multipart-ctl-parameter
276 "application/pgp-signature")
278 (mm-set-handle-multipart-parameter
279 mm-security-handle
'gnus-info
"Corrupted")
280 (throw 'error handle
))
282 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n")
283 (insert (format "Hash: %s\n\n"
284 (or (mml2015-fix-micalg
285 (mm-handle-multipart-ctl-parameter
289 (narrow-to-region (point) (point))
291 (goto-char (point-min))
293 (if (looking-at "^-")
296 (unless (setq part
(mm-find-part-by-type
297 (cdr handle
) "application/pgp-signature" nil t
))
298 (mm-set-handle-multipart-parameter
299 mm-security-handle
'gnus-info
"Corrupted")
300 (throw 'error handle
))
302 (narrow-to-region (point) (point))
303 (mm-insert-part part
)
304 (goto-char (point-min))
305 (if (re-search-forward "^-----BEGIN PGP [^-]+-----\r?$" nil t
)
306 (replace-match "-----BEGIN PGP SIGNATURE-----" t t
))
307 (if (re-search-forward "^-----END PGP [^-]+-----\r?$" nil t
)
308 (replace-match "-----END PGP SIGNATURE-----" t t
)))
309 (let ((mc-gpg-debug-buffer (get-buffer-create " *gnus gpg debug*")))
310 (unless (condition-case err
312 (funcall mml2015-verify-function
)
313 (if (get-buffer " *mailcrypt stderr temp")
314 (mm-set-handle-multipart-parameter
315 mm-security-handle
'gnus-details
316 (with-current-buffer " *mailcrypt stderr temp"
318 (if (get-buffer " *mailcrypt stdout temp")
319 (kill-buffer " *mailcrypt stdout temp"))
320 (if (get-buffer " *mailcrypt stderr temp")
321 (kill-buffer " *mailcrypt stderr temp"))
322 (if (get-buffer " *mailcrypt status temp")
323 (kill-buffer " *mailcrypt status temp"))
324 (if (get-buffer mc-gpg-debug-buffer
)
325 (kill-buffer mc-gpg-debug-buffer
)))
327 (mm-set-handle-multipart-parameter
328 mm-security-handle
'gnus-details
(mml2015-format-error err
))
331 (mm-set-handle-multipart-parameter
332 mm-security-handle
'gnus-details
"Quit.")
334 (mm-set-handle-multipart-parameter
335 mm-security-handle
'gnus-info
"Failed")
336 (throw 'error handle
))))
337 (mm-set-handle-multipart-parameter
338 mm-security-handle
'gnus-info
"OK")
341 (defun mml2015-mailcrypt-clear-verify ()
342 (let ((mc-gpg-debug-buffer (get-buffer-create " *gnus gpg debug*")))
343 (if (condition-case err
345 (funcall mml2015-verify-function
)
346 (if (get-buffer " *mailcrypt stderr temp")
347 (mm-set-handle-multipart-parameter
348 mm-security-handle
'gnus-details
349 (with-current-buffer " *mailcrypt stderr temp"
351 (if (get-buffer " *mailcrypt stdout temp")
352 (kill-buffer " *mailcrypt stdout temp"))
353 (if (get-buffer " *mailcrypt stderr temp")
354 (kill-buffer " *mailcrypt stderr temp"))
355 (if (get-buffer " *mailcrypt status temp")
356 (kill-buffer " *mailcrypt status temp"))
357 (if (get-buffer mc-gpg-debug-buffer
)
358 (kill-buffer mc-gpg-debug-buffer
)))
360 (mm-set-handle-multipart-parameter
361 mm-security-handle
'gnus-details
(mml2015-format-error err
))
364 (mm-set-handle-multipart-parameter
365 mm-security-handle
'gnus-details
"Quit.")
367 (mm-set-handle-multipart-parameter
368 mm-security-handle
'gnus-info
"OK")
369 (mm-set-handle-multipart-parameter
370 mm-security-handle
'gnus-info
"Failed")))
371 (mml2015-extract-cleartext-signature))
373 (defun mml2015-mailcrypt-sign (cont)
374 (mc-sign-generic (message-options-get 'message-sender
)
376 (let ((boundary (mml-compute-boundary cont
))
378 (goto-char (point-min))
379 (unless (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\r?$" nil t
)
380 (error "Cannot find signed begin line"))
381 (goto-char (match-beginning 0))
383 (unless (looking-at "Hash:[ \t]*\\([a-zA-Z0-9]+\\)")
384 (error "Cannot not find PGP hash"))
385 (setq hash
(match-string 1))
386 (unless (re-search-forward "^$" nil t
)
387 (error "Cannot not find PGP message"))
389 (delete-region (point-min) (point))
390 (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
392 (insert (format "\tmicalg=pgp-%s; protocol=\"application/pgp-signature\"\n"
394 (insert (format "\n--%s\n" boundary
))
396 (goto-char (point-max))
397 (unless (re-search-backward "^-----END PGP SIGNATURE-----\r?$" nil t
)
398 (error "Cannot find signature part"))
399 (replace-match "-----END PGP MESSAGE-----" t t
)
400 (goto-char (match-beginning 0))
401 (unless (re-search-backward "^-----BEGIN PGP SIGNATURE-----\r?$"
403 (error "Cannot find signature part"))
404 (replace-match "-----BEGIN PGP MESSAGE-----" t t
)
405 (goto-char (match-beginning 0))
407 (narrow-to-region point
(point))
409 (while (re-search-forward "^- -" nil t
)
410 (replace-match "-" t t
))
411 (goto-char (point-max)))
412 (insert (format "--%s\n" boundary
))
413 (insert "Content-Type: application/pgp-signature\n\n")
414 (goto-char (point-max))
415 (insert (format "--%s--\n" boundary
))
416 (goto-char (point-max))))
418 ;; We require mm-decode, which requires mm-bodies, which autoloads
419 ;; message-options-get (!).
420 (declare-function message-options-set
"message" (symbol value
))
422 (defun mml2015-mailcrypt-encrypt (cont &optional sign
)
423 (let ((mc-pgp-always-sign
424 (or mc-pgp-always-sign
426 (eq t
(or (message-options-get 'message-sign-encrypt
)
428 'message-sign-encrypt
429 (or (y-or-n-p "Sign the message? ")
432 (mm-with-unibyte-current-buffer
434 (or (message-options-get 'message-recipients
)
435 (message-options-set 'message-recipients
436 (mc-cleanup-recipient-headers
437 (read-string "Recipients: "))))
439 (message-options-get 'message-sender
))))
440 (goto-char (point-min))
441 (unless (looking-at "-----BEGIN PGP MESSAGE-----")
442 (error "Fail to encrypt the message"))
443 (let ((boundary (mml-compute-boundary cont
)))
444 (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n"
446 (insert "\tprotocol=\"application/pgp-encrypted\"\n\n")
447 (insert (format "--%s\n" boundary
))
448 (insert "Content-Type: application/pgp-encrypted\n\n")
449 (insert "Version: 1\n\n")
450 (insert (format "--%s\n" boundary
))
451 (insert "Content-Type: application/octet-stream\n\n")
452 (goto-char (point-max))
453 (insert (format "--%s--\n" boundary
))
454 (goto-char (point-max))))
459 (autoload 'gpg-decrypt
"gpg")
460 (autoload 'gpg-verify
"gpg")
461 (autoload 'gpg-verify-cleartext
"gpg")
462 (autoload 'gpg-sign-detached
"gpg")
463 (autoload 'gpg-sign-encrypt
"gpg")
464 (autoload 'gpg-encrypt
"gpg")
465 (autoload 'gpg-passphrase-read
"gpg"))
467 (defun mml2015-gpg-passphrase ()
468 (or (message-options-get 'gpg-passphrase
)
469 (message-options-set 'gpg-passphrase
(gpg-passphrase-read))))
471 (defun mml2015-gpg-decrypt-1 ()
472 (let ((cipher (current-buffer)) plain result
)
473 (if (with-temp-buffer
475 (gpg-decrypt cipher
(setq plain
(current-buffer))
476 mml2015-result-buffer nil
)
477 (mm-set-handle-multipart-parameter
478 mm-security-handle
'gnus-details
479 (with-current-buffer mml2015-result-buffer
483 (insert-buffer-substring plain
)
484 (goto-char (point-min))
485 (while (search-forward "\r\n" nil t
)
486 (replace-match "\n" t t
))))
488 ;; Some wrong with the return value, check plain text buffer.
489 (if (> (point-max) (point-min))
493 (defun mml2015-gpg-decrypt (handle ctl
)
494 (let ((mml2015-decrypt-function 'mml2015-gpg-decrypt-1
))
495 (mml2015-mailcrypt-decrypt handle ctl
)))
497 (defun mml2015-gpg-clear-decrypt ()
499 (setq result
(mml2015-gpg-decrypt-1))
501 (mm-set-handle-multipart-parameter
502 mm-security-handle
'gnus-info
"OK")
503 (mm-set-handle-multipart-parameter
504 mm-security-handle
'gnus-info
"Failed"))))
506 (defun mml2015-gpg-pretty-print-fpr (fingerprint)
508 (fpr-length (string-width fingerprint
))
511 (setq fingerprint
(string-to-list fingerprint
))
513 (setq fpr-length
(- fpr-length
4))
514 (setq slice
(butlast fingerprint fpr-length
))
515 (setq fingerprint
(nthcdr 4 fingerprint
))
516 (setq n-slice
(1+ n-slice
))
522 (otherwise (concat " " slice
))))))
525 (defun mml2015-gpg-extract-signature-details ()
526 (goto-char (point-min))
527 (let* ((expired (re-search-forward
528 "^\\[GNUPG:\\] SIGEXPIRED$"
530 (signer (and (re-search-forward
531 "^\\[GNUPG:\\] GOODSIG \\([0-9A-Za-z]*\\) \\(.*\\)$"
533 (cons (match-string 1) (match-string 2))))
534 (fprint (and (re-search-forward
535 "^\\[GNUPG:\\] VALIDSIG \\([0-9a-zA-Z]*\\) "
538 (trust (and (re-search-forward
539 "^\\[GNUPG:\\] \\(TRUST_.*\\)$"
543 (cdr (assoc trust mml2015-unabbrev-trust-alist
))))
544 (cond ((and signer fprint
)
546 (unless trust-good-enough-p
547 (concat "\nUntrusted, Fingerprint: "
548 (mml2015-gpg-pretty-print-fpr fprint
)))
550 (format "\nWARNING: Signature from expired key (%s)"
553 "^\\(gpg: \\)?Good signature from \"\\(.*\\)\"$" nil t
)
556 "From unknown user"))))
558 (defun mml2015-gpg-verify (handle ctl
)
560 (let (part message signature info-is-set-p
)
561 (unless (setq part
(mm-find-raw-part-by-type
562 ctl
(or (mm-handle-multipart-ctl-parameter
564 "application/pgp-signature")
566 (mm-set-handle-multipart-parameter
567 mm-security-handle
'gnus-info
"Corrupted")
568 (throw 'error handle
))
570 (setq message
(current-buffer))
572 ;; Convert <LF> to <CR><LF> in signed text. If --textmode is
573 ;; specified when signing, the conversion is not necessary.
574 (goto-char (point-min))
577 (unless (eq (char-before) ?
\r)
582 (setq signature
(current-buffer))
583 (unless (setq part
(mm-find-part-by-type
584 (cdr handle
) "application/pgp-signature" nil t
))
585 (mm-set-handle-multipart-parameter
586 mm-security-handle
'gnus-info
"Corrupted")
587 (throw 'error handle
))
588 (mm-insert-part part
)
589 (unless (condition-case err
591 (gpg-verify message signature mml2015-result-buffer
)
592 (mm-set-handle-multipart-parameter
593 mm-security-handle
'gnus-details
594 (with-current-buffer mml2015-result-buffer
597 (mm-set-handle-multipart-parameter
598 mm-security-handle
'gnus-details
(mml2015-format-error err
))
599 (mm-set-handle-multipart-parameter
600 mm-security-handle
'gnus-info
"Error.")
601 (setq info-is-set-p t
)
604 (mm-set-handle-multipart-parameter
605 mm-security-handle
'gnus-details
"Quit.")
606 (mm-set-handle-multipart-parameter
607 mm-security-handle
'gnus-info
"Quit.")
608 (setq info-is-set-p t
)
610 (unless info-is-set-p
611 (mm-set-handle-multipart-parameter
612 mm-security-handle
'gnus-info
"Failed"))
613 (throw 'error handle
)))
614 (mm-set-handle-multipart-parameter
615 mm-security-handle
'gnus-info
616 (with-current-buffer mml2015-result-buffer
617 (mml2015-gpg-extract-signature-details))))
620 (defun mml2015-gpg-clear-verify ()
621 (if (condition-case err
623 (gpg-verify-cleartext (current-buffer) mml2015-result-buffer
)
624 (mm-set-handle-multipart-parameter
625 mm-security-handle
'gnus-details
626 (with-current-buffer mml2015-result-buffer
629 (mm-set-handle-multipart-parameter
630 mm-security-handle
'gnus-details
(mml2015-format-error err
))
633 (mm-set-handle-multipart-parameter
634 mm-security-handle
'gnus-details
"Quit.")
636 (mm-set-handle-multipart-parameter
637 mm-security-handle
'gnus-info
638 (with-current-buffer mml2015-result-buffer
639 (mml2015-gpg-extract-signature-details)))
640 (mm-set-handle-multipart-parameter
641 mm-security-handle
'gnus-info
"Failed"))
642 (mml2015-extract-cleartext-signature))
644 (defun mml2015-gpg-sign (cont)
645 (let ((boundary (mml-compute-boundary cont
))
646 (text (current-buffer)) signature
)
647 (goto-char (point-max))
651 (unless (gpg-sign-detached text
(setq signature
(current-buffer))
652 mml2015-result-buffer
654 (message-options-get 'message-sender
)
655 t t
) ; armor & textmode
656 (unless (> (point-max) (point-min))
657 (pop-to-buffer mml2015-result-buffer
)
658 (error "Sign error")))
659 (goto-char (point-min))
660 (while (re-search-forward "\r+$" nil t
)
661 (replace-match "" t t
))
663 (goto-char (point-min))
664 (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
666 ;;; FIXME: what is the micalg?
667 (insert "\tmicalg=pgp-sha1; protocol=\"application/pgp-signature\"\n")
668 (insert (format "\n--%s\n" boundary
))
669 (goto-char (point-max))
670 (insert (format "\n--%s\n" boundary
))
671 (insert "Content-Type: application/pgp-signature\n\n")
672 (insert-buffer-substring signature
)
673 (goto-char (point-max))
674 (insert (format "--%s--\n" boundary
))
675 (goto-char (point-max)))))
677 (defun mml2015-gpg-encrypt (cont &optional sign
)
678 (let ((boundary (mml-compute-boundary cont
))
679 (text (current-buffer))
681 (mm-with-unibyte-current-buffer
683 ;; set up a function to call the correct gpg encrypt routine
684 ;; with the right arguments. (FIXME: this should be done
686 (flet ((gpg-encrypt-func
687 (sign plaintext ciphertext result recipients
&optional
688 passphrase sign-with-key armor textmode
)
691 plaintext ciphertext result recipients passphrase
692 sign-with-key armor textmode
)
694 plaintext ciphertext result recipients passphrase
696 (unless (gpg-encrypt-func
697 sign
; passed in when using signencrypt
698 text
(setq cipher
(current-buffer))
699 mml2015-result-buffer
702 (message-options-get 'message-recipients
)
703 (message-options-set 'message-recipients
704 (read-string "Recipients: ")))
707 (message-options-get 'message-sender
)
708 t t
) ; armor & textmode
709 (unless (> (point-max) (point-min))
710 (pop-to-buffer mml2015-result-buffer
)
711 (error "Encrypt error"))))
712 (goto-char (point-min))
713 (while (re-search-forward "\r+$" nil t
)
714 (replace-match "" t t
))
716 (delete-region (point-min) (point-max))
717 (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n"
719 (insert "\tprotocol=\"application/pgp-encrypted\"\n\n")
720 (insert (format "--%s\n" boundary
))
721 (insert "Content-Type: application/pgp-encrypted\n\n")
722 (insert "Version: 1\n\n")
723 (insert (format "--%s\n" boundary
))
724 (insert "Content-Type: application/octet-stream\n\n")
725 (insert-buffer-substring cipher
)
726 (goto-char (point-max))
727 (insert (format "--%s--\n" boundary
))
728 (goto-char (point-max))))))
732 (defvar pgg-default-user-id
)
733 (defvar pgg-errors-buffer
)
734 (defvar pgg-output-buffer
)
737 (autoload 'pgg-decrypt-region
"pgg")
738 (autoload 'pgg-verify-region
"pgg")
739 (autoload 'pgg-sign-region
"pgg")
740 (autoload 'pgg-encrypt-region
"pgg")
741 (autoload 'pgg-parse-armor
"pgg-parse"))
743 (defun mml2015-pgg-decrypt (handle ctl
)
745 (let ((pgg-errors-buffer mml2015-result-buffer
)
746 child handles result decrypt-status
)
747 (unless (setq child
(mm-find-part-by-type
749 "application/octet-stream" nil t
))
750 (mm-set-handle-multipart-parameter
751 mm-security-handle
'gnus-info
"Corrupted")
752 (throw 'error handle
))
754 (mm-insert-part child
)
755 (if (condition-case err
757 (pgg-decrypt-region (point-min) (point-max))
759 (with-current-buffer mml2015-result-buffer
761 (mm-set-handle-multipart-parameter
762 mm-security-handle
'gnus-details
765 (mm-set-handle-multipart-parameter
766 mm-security-handle
'gnus-details
(mml2015-format-error err
))
769 (mm-set-handle-multipart-parameter
770 mm-security-handle
'gnus-details
"Quit.")
772 (with-current-buffer pgg-output-buffer
773 (goto-char (point-min))
774 (while (search-forward "\r\n" nil t
)
775 (replace-match "\n" t t
))
776 (setq handles
(mm-dissect-buffer t
))
777 (mm-destroy-parts handle
)
778 (mm-set-handle-multipart-parameter
779 mm-security-handle
'gnus-info
"OK")
780 (mm-set-handle-multipart-parameter
781 mm-security-handle
'gnus-details
782 (concat decrypt-status
783 (when (stringp (car handles
))
784 "\n" (mm-handle-multipart-ctl-parameter
785 handles
'gnus-details
))))
786 (if (listp (car handles
))
789 (mm-set-handle-multipart-parameter
790 mm-security-handle
'gnus-info
"Failed")
791 (throw 'error handle
))))))
793 (defun mml2015-pgg-clear-decrypt ()
794 (let ((pgg-errors-buffer mml2015-result-buffer
))
796 (pgg-decrypt-region (point-min) (point-max))
797 (mm-set-handle-multipart-parameter
798 mm-security-handle
'gnus-details
799 (with-current-buffer mml2015-result-buffer
803 ;; Treat data which pgg returns as a unibyte string.
804 (mm-disable-multibyte)
805 (insert-buffer-substring pgg-output-buffer
)
806 (goto-char (point-min))
807 (while (search-forward "\r\n" nil t
)
808 (replace-match "\n" t t
))
809 (mm-set-handle-multipart-parameter
810 mm-security-handle
'gnus-info
"OK"))
811 (mm-set-handle-multipart-parameter
812 mm-security-handle
'gnus-info
"Failed"))))
814 (defun mml2015-pgg-verify (handle ctl
)
815 (let ((pgg-errors-buffer mml2015-result-buffer
)
816 signature-file part signature
)
817 (if (or (null (setq part
(mm-find-raw-part-by-type
818 ctl
(or (mm-handle-multipart-ctl-parameter
820 "application/pgp-signature")
822 (null (setq signature
(mm-find-part-by-type
823 (cdr handle
) "application/pgp-signature" nil t
))))
825 (mm-set-handle-multipart-parameter
826 mm-security-handle
'gnus-info
"Corrupted")
830 ;; Convert <LF> to <CR><LF> in signed text. If --textmode is
831 ;; specified when signing, the conversion is not necessary.
832 (goto-char (point-min))
835 (unless (eq (char-before) ?
\r)
839 (with-temp-file (setq signature-file
(mm-make-temp-file "pgg"))
840 (mm-insert-part signature
))
841 (if (condition-case err
843 (pgg-verify-region (point-min) (point-max)
845 (goto-char (point-min))
846 (while (search-forward "\r\n" nil t
)
847 (replace-match "\n" t t
))
848 (mm-set-handle-multipart-parameter
849 mm-security-handle
'gnus-details
850 (concat (with-current-buffer pgg-output-buffer
852 (with-current-buffer pgg-errors-buffer
855 (mm-set-handle-multipart-parameter
856 mm-security-handle
'gnus-details
(mml2015-format-error err
))
859 (mm-set-handle-multipart-parameter
860 mm-security-handle
'gnus-details
"Quit.")
863 (delete-file signature-file
)
864 (mm-set-handle-multipart-parameter
865 mm-security-handle
'gnus-info
866 (with-current-buffer pgg-errors-buffer
867 (mml2015-gpg-extract-signature-details))))
868 (delete-file signature-file
)
869 (mm-set-handle-multipart-parameter
870 mm-security-handle
'gnus-info
"Failed")))))
873 (defun mml2015-pgg-clear-verify ()
874 (let ((pgg-errors-buffer mml2015-result-buffer
)
875 (text (buffer-string))
876 (coding-system buffer-file-coding-system
))
877 (if (condition-case err
879 (mm-with-unibyte-buffer
880 (insert (mm-encode-coding-string text coding-system
))
881 (pgg-verify-region (point-min) (point-max) nil t
))
882 (goto-char (point-min))
883 (while (search-forward "\r\n" nil t
)
884 (replace-match "\n" t t
))
885 (mm-set-handle-multipart-parameter
886 mm-security-handle
'gnus-details
887 (concat (with-current-buffer pgg-output-buffer
889 (with-current-buffer pgg-errors-buffer
892 (mm-set-handle-multipart-parameter
893 mm-security-handle
'gnus-details
(mml2015-format-error err
))
896 (mm-set-handle-multipart-parameter
897 mm-security-handle
'gnus-details
"Quit.")
899 (mm-set-handle-multipart-parameter
900 mm-security-handle
'gnus-info
901 (with-current-buffer pgg-errors-buffer
902 (mml2015-gpg-extract-signature-details)))
903 (mm-set-handle-multipart-parameter
904 mm-security-handle
'gnus-info
"Failed")))
905 (mml2015-extract-cleartext-signature))
907 (defun mml2015-pgg-sign (cont)
908 (let ((pgg-errors-buffer mml2015-result-buffer
)
909 (boundary (mml-compute-boundary cont
))
910 (pgg-default-user-id (or (message-options-get 'mml-sender
)
911 pgg-default-user-id
))
914 (unless (pgg-sign-region (point-min) (point-max))
915 (pop-to-buffer mml2015-result-buffer
)
916 (error "Sign error"))
917 (goto-char (point-min))
918 (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
920 (if (setq entry
(assq 2 (pgg-parse-armor
921 (with-current-buffer pgg-output-buffer
923 (setq entry
(assq 'hash-algorithm
(cdr entry
))))
924 (insert (format "\tmicalg=%s; "
926 (downcase (format "pgp-%s" (cdr entry
)))
928 (insert "protocol=\"application/pgp-signature\"\n")
929 (insert (format "\n--%s\n" boundary
))
930 (goto-char (point-max))
931 (insert (format "\n--%s\n" boundary
))
932 (insert "Content-Type: application/pgp-signature\n\n")
933 (insert-buffer-substring pgg-output-buffer
)
934 (goto-char (point-max))
935 (insert (format "--%s--\n" boundary
))
936 (goto-char (point-max))))
938 (defun mml2015-pgg-encrypt (cont &optional sign
)
939 (let ((pgg-errors-buffer mml2015-result-buffer
)
941 (boundary (mml-compute-boundary cont
)))
942 (unless (pgg-encrypt-region (point-min) (point-max)
945 (message-options-get 'message-recipients
)
946 (message-options-set 'message-recipients
947 (read-string "Recipients: ")))
950 (pop-to-buffer mml2015-result-buffer
)
951 (error "Encrypt error"))
952 (delete-region (point-min) (point-max))
953 (goto-char (point-min))
954 (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n"
956 (insert "\tprotocol=\"application/pgp-encrypted\"\n\n")
957 (insert (format "--%s\n" boundary
))
958 (insert "Content-Type: application/pgp-encrypted\n\n")
959 (insert "Version: 1\n\n")
960 (insert (format "--%s\n" boundary
))
961 (insert "Content-Type: application/octet-stream\n\n")
962 (insert-buffer-substring pgg-output-buffer
)
963 (goto-char (point-max))
964 (insert (format "--%s--\n" boundary
))
965 (goto-char (point-max))))
969 (defvar epg-user-id-alist
)
970 (defvar epg-digest-algorithm-alist
)
971 (defvar inhibit-redisplay
)
974 (autoload 'epg-make-context
"epg")
975 (autoload 'epg-context-set-armor
"epg")
976 (autoload 'epg-context-set-textmode
"epg")
977 (autoload 'epg-context-set-signers
"epg")
978 (autoload 'epg-context-result-for
"epg")
979 (autoload 'epg-new-signature-digest-algorithm
"epg")
980 (autoload 'epg-verify-result-to-string
"epg")
981 (autoload 'epg-list-keys
"epg")
982 (autoload 'epg-decrypt-string
"epg")
983 (autoload 'epg-verify-string
"epg")
984 (autoload 'epg-sign-string
"epg")
985 (autoload 'epg-encrypt-string
"epg")
986 (autoload 'epg-passphrase-callback-function
"epg")
987 (autoload 'epg-context-set-passphrase-callback
"epg")
988 (autoload 'epg-key-sub-key-list
"epg")
989 (autoload 'epg-sub-key-capability
"epg")
990 (autoload 'epg-sub-key-validity
"epg")
991 (autoload 'epg-configuration
"epg-config")
992 (autoload 'epg-expand-group
"epg-config")
993 (autoload 'epa-select-keys
"epa"))
995 (defvar password-cache-expiry
)
997 (defvar mml2015-epg-secret-key-id-list nil
)
999 (defun mml2015-epg-passphrase-callback (context key-id ignore
)
1000 (if (eq key-id
'SYM
)
1001 (epg-passphrase-callback-function context key-id nil
)
1002 (let* ((password-cache-key-id
1003 (if (eq key-id
'PIN
)
1009 (if (eq key-id
'PIN
)
1010 "Passphrase for PIN: "
1011 (if (setq entry
(assoc key-id epg-user-id-alist
))
1012 (format "Passphrase for %s %s: " key-id
(cdr entry
))
1013 (format "Passphrase for %s: " key-id
)))
1014 password-cache-key-id
)))
1016 (let ((password-cache-expiry mml2015-passphrase-cache-expiry
))
1017 (password-cache-add password-cache-key-id passphrase
))
1018 (setq mml2015-epg-secret-key-id-list
1019 (cons password-cache-key-id mml2015-epg-secret-key-id-list
))
1020 (copy-sequence passphrase
)))))
1022 (defun mml2015-epg-find-usable-key (keys usage
)
1025 (let ((pointer (epg-key-sub-key-list (car keys
))))
1027 (if (and (memq usage
(epg-sub-key-capability (car pointer
)))
1028 (not (memq (epg-sub-key-validity (car pointer
))
1029 '(revoked expired
))))
1030 (throw 'found
(car keys
)))
1031 (setq pointer
(cdr pointer
))))
1032 (setq keys
(cdr keys
)))))
1034 (defun mml2015-epg-decrypt (handle ctl
)
1036 (let ((inhibit-redisplay t
)
1037 context plain child handles result decrypt-status
)
1038 (unless (setq child
(mm-find-part-by-type
1040 "application/octet-stream" nil t
))
1041 (mm-set-handle-multipart-parameter
1042 mm-security-handle
'gnus-info
"Corrupted")
1043 (throw 'error handle
))
1044 (setq context
(epg-make-context))
1045 (if mml2015-cache-passphrase
1046 (epg-context-set-passphrase-callback
1048 #'mml2015-epg-passphrase-callback
))
1049 (condition-case error
1050 (setq plain
(epg-decrypt-string context
(mm-get-part child
))
1051 mml2015-epg-secret-key-id-list nil
)
1053 (while mml2015-epg-secret-key-id-list
1054 (password-cache-remove (car mml2015-epg-secret-key-id-list
))
1055 (setq mml2015-epg-secret-key-id-list
1056 (cdr mml2015-epg-secret-key-id-list
)))
1057 (mm-set-handle-multipart-parameter
1058 mm-security-handle
'gnus-info
"Failed")
1059 (if (eq (car error
) 'quit
)
1060 (mm-set-handle-multipart-parameter
1061 mm-security-handle
'gnus-details
"Quit.")
1062 (mm-set-handle-multipart-parameter
1063 mm-security-handle
'gnus-details
(mml2015-format-error error
)))
1064 (throw 'error handle
)))
1067 (goto-char (point-min))
1068 (while (search-forward "\r\n" nil t
)
1069 (replace-match "\n" t t
))
1070 (setq handles
(mm-dissect-buffer t
))
1071 (mm-destroy-parts handle
)
1072 (if (epg-context-result-for context
'verify
)
1073 (mm-set-handle-multipart-parameter
1074 mm-security-handle
'gnus-info
1076 (epg-verify-result-to-string
1077 (epg-context-result-for context
'verify
))))
1078 (mm-set-handle-multipart-parameter
1079 mm-security-handle
'gnus-info
"OK"))
1080 (if (stringp (car handles
))
1081 (mm-set-handle-multipart-parameter
1082 mm-security-handle
'gnus-details
1083 (mm-handle-multipart-ctl-parameter handles
'gnus-details
))))
1084 (if (listp (car handles
))
1088 (defun mml2015-epg-clear-decrypt ()
1089 (let ((inhibit-redisplay t
)
1090 (context (epg-make-context))
1092 (if mml2015-cache-passphrase
1093 (epg-context-set-passphrase-callback
1095 #'mml2015-epg-passphrase-callback
))
1096 (condition-case error
1097 (setq plain
(epg-decrypt-string context
(buffer-string))
1098 mml2015-epg-secret-key-id-list nil
)
1100 (while mml2015-epg-secret-key-id-list
1101 (password-cache-remove (car mml2015-epg-secret-key-id-list
))
1102 (setq mml2015-epg-secret-key-id-list
1103 (cdr mml2015-epg-secret-key-id-list
)))
1104 (mm-set-handle-multipart-parameter
1105 mm-security-handle
'gnus-info
"Failed")
1106 (if (eq (car error
) 'quit
)
1107 (mm-set-handle-multipart-parameter
1108 mm-security-handle
'gnus-details
"Quit.")
1109 (mm-set-handle-multipart-parameter
1110 mm-security-handle
'gnus-details
(mml2015-format-error error
)))))
1113 ;; Treat data which epg returns as a unibyte string.
1114 (mm-disable-multibyte)
1116 (goto-char (point-min))
1117 (while (search-forward "\r\n" nil t
)
1118 (replace-match "\n" t t
))
1119 (mm-set-handle-multipart-parameter
1120 mm-security-handle
'gnus-info
"OK")
1121 (if (epg-context-result-for context
'verify
)
1122 (mm-set-handle-multipart-parameter
1123 mm-security-handle
'gnus-details
1124 (epg-verify-result-to-string
1125 (epg-context-result-for context
'verify
)))))))
1127 (defun mml2015-epg-verify (handle ctl
)
1129 (let ((inhibit-redisplay t
)
1130 context plain signature-file part signature
)
1131 (when (or (null (setq part
(mm-find-raw-part-by-type
1132 ctl
(or (mm-handle-multipart-ctl-parameter
1134 "application/pgp-signature")
1136 (null (setq signature
(mm-find-part-by-type
1137 (cdr handle
) "application/pgp-signature"
1139 (mm-set-handle-multipart-parameter
1140 mm-security-handle
'gnus-info
"Corrupted")
1141 (throw 'error handle
))
1142 (setq part
(mm-replace-in-string part
"\n" "\r\n" t
)
1143 signature
(mm-get-part signature
)
1144 context
(epg-make-context))
1145 (condition-case error
1146 (setq plain
(epg-verify-string context signature part
))
1148 (mm-set-handle-multipart-parameter
1149 mm-security-handle
'gnus-info
"Failed")
1150 (if (eq (car error
) 'quit
)
1151 (mm-set-handle-multipart-parameter
1152 mm-security-handle
'gnus-details
"Quit.")
1153 (mm-set-handle-multipart-parameter
1154 mm-security-handle
'gnus-details
(mml2015-format-error error
)))
1155 (throw 'error handle
)))
1156 (mm-set-handle-multipart-parameter
1157 mm-security-handle
'gnus-info
1158 (epg-verify-result-to-string (epg-context-result-for context
'verify
)))
1161 (defun mml2015-epg-clear-verify ()
1162 (let ((inhibit-redisplay t
)
1163 (context (epg-make-context))
1164 (signature (mm-encode-coding-string (buffer-string)
1165 coding-system-for-write
))
1167 (condition-case error
1168 (setq plain
(epg-verify-string context signature
))
1170 (mm-set-handle-multipart-parameter
1171 mm-security-handle
'gnus-info
"Failed")
1172 (if (eq (car error
) 'quit
)
1173 (mm-set-handle-multipart-parameter
1174 mm-security-handle
'gnus-details
"Quit.")
1175 (mm-set-handle-multipart-parameter
1176 mm-security-handle
'gnus-details
(mml2015-format-error error
)))))
1179 (mm-set-handle-multipart-parameter
1180 mm-security-handle
'gnus-info
1181 (epg-verify-result-to-string
1182 (epg-context-result-for context
'verify
)))
1183 (delete-region (point-min) (point-max))
1184 (insert (mm-decode-coding-string plain coding-system-for-read
)))
1185 (mml2015-extract-cleartext-signature))))
1187 (defun mml2015-epg-sign (cont)
1188 (let* ((inhibit-redisplay t
)
1189 (context (epg-make-context))
1190 (boundary (mml-compute-boundary cont
))
1193 (or (message-options-get 'mml2015-epg-signers
)
1194 (message-options-set
1195 'mml2015-epg-signers
1197 (epa-select-keys context
"\
1198 Select keys for signing.
1199 If no one is selected, default secret key is used. "
1205 (setq signer-key
(mml2015-epg-find-usable-key
1206 (epg-list-keys context signer t
)
1208 (unless (or signer-key
1211 "No secret key for %s; skip it? "
1213 (error "No secret key for %s" signer
))
1215 mml2015-signers
)))))))
1217 (epg-context-set-armor context t
)
1218 (epg-context-set-textmode context t
)
1219 (epg-context-set-signers context signers
)
1220 (if mml2015-cache-passphrase
1221 (epg-context-set-passphrase-callback
1223 #'mml2015-epg-passphrase-callback
))
1224 (condition-case error
1225 (setq signature
(epg-sign-string context
(buffer-string) t
)
1226 mml2015-epg-secret-key-id-list nil
)
1228 (while mml2015-epg-secret-key-id-list
1229 (password-cache-remove (car mml2015-epg-secret-key-id-list
))
1230 (setq mml2015-epg-secret-key-id-list
1231 (cdr mml2015-epg-secret-key-id-list
)))
1232 (signal (car error
) (cdr error
))))
1233 (if (epg-context-result-for context
'sign
)
1234 (setq micalg
(epg-new-signature-digest-algorithm
1235 (car (epg-context-result-for context
'sign
)))))
1236 (goto-char (point-min))
1237 (insert (format "Content-Type: multipart/signed; boundary=\"%s\";\n"
1240 (insert (format "\tmicalg=pgp-%s; "
1243 epg-digest-algorithm-alist
))))))
1244 (insert "protocol=\"application/pgp-signature\"\n")
1245 (insert (format "\n--%s\n" boundary
))
1246 (goto-char (point-max))
1247 (insert (format "\n--%s\n" boundary
))
1248 (insert "Content-Type: application/pgp-signature\n\n")
1250 (goto-char (point-max))
1251 (insert (format "--%s--\n" boundary
))
1252 (goto-char (point-max))))
1254 (defun mml2015-epg-encrypt (cont &optional sign
)
1255 (let ((inhibit-redisplay t
)
1256 (context (epg-make-context))
1257 (config (epg-configuration))
1258 (recipients (message-options-get 'mml2015-epg-recipients
))
1260 (boundary (mml-compute-boundary cont
))
1261 recipient-key signer-key
)
1267 (or (epg-expand-group config recipient
)
1268 (list (concat "<" recipient
">"))))
1270 (or (message-options-get 'message-recipients
)
1271 (message-options-set 'message-recipients
1272 (read-string "Recipients: ")))
1273 "[ \f\t\n\r\v,]+"))))
1274 (when mml2015-encrypt-to-self
1275 (unless mml2015-signers
1276 (error "mml2015-signers not set"))
1277 (setq recipients
(nconc recipients mml2015-signers
)))
1280 (epa-select-keys context
"\
1281 Select recipients for encryption.
1282 If no one is selected, symmetric encryption will be performed. "
1288 (setq recipient-key
(mml2015-epg-find-usable-key
1289 (epg-list-keys context recipient
)
1291 (unless (or recipient-key
1293 (format "No public key for %s; skip it? "
1295 (error "No public key for %s" recipient
))
1299 (error "No recipient specified")))
1300 (message-options-set 'mml2015-epg-recipients recipients
))
1303 (or (message-options-get 'mml2015-epg-signers
)
1304 (message-options-set
1305 'mml2015-epg-signers
1307 (epa-select-keys context
"\
1308 Select keys for signing.
1309 If no one is selected, default secret key is used. "
1315 (setq signer-key
(mml2015-epg-find-usable-key
1316 (epg-list-keys context signer t
)
1318 (unless (or signer-key
1321 "No secret key for %s; skip it? "
1323 (error "No secret key for %s" signer
))
1325 mml2015-signers
)))))))
1326 (epg-context-set-signers context signers
))
1327 (epg-context-set-armor context t
)
1328 (epg-context-set-textmode context t
)
1329 (if mml2015-cache-passphrase
1330 (epg-context-set-passphrase-callback
1332 #'mml2015-epg-passphrase-callback
))
1333 (condition-case error
1335 (epg-encrypt-string context
(buffer-string) recipients sign
1336 mml2015-always-trust
)
1337 mml2015-epg-secret-key-id-list nil
)
1339 (while mml2015-epg-secret-key-id-list
1340 (password-cache-remove (car mml2015-epg-secret-key-id-list
))
1341 (setq mml2015-epg-secret-key-id-list
1342 (cdr mml2015-epg-secret-key-id-list
)))
1343 (signal (car error
) (cdr error
))))
1344 (delete-region (point-min) (point-max))
1345 (goto-char (point-min))
1346 (insert (format "Content-Type: multipart/encrypted; boundary=\"%s\";\n"
1348 (insert "\tprotocol=\"application/pgp-encrypted\"\n\n")
1349 (insert (format "--%s\n" boundary
))
1350 (insert "Content-Type: application/pgp-encrypted\n\n")
1351 (insert "Version: 1\n\n")
1352 (insert (format "--%s\n" boundary
))
1353 (insert "Content-Type: application/octet-stream\n\n")
1355 (goto-char (point-max))
1356 (insert (format "--%s--\n" boundary
))
1357 (goto-char (point-max))))
1361 (autoload 'gnus-buffer-live-p
"gnus-util")
1362 (autoload 'gnus-get-buffer-create
"gnus")
1364 (defun mml2015-clean-buffer ()
1365 (if (gnus-buffer-live-p mml2015-result-buffer
)
1366 (with-current-buffer mml2015-result-buffer
1369 (setq mml2015-result-buffer
1370 (gnus-get-buffer-create " *MML2015 Result*"))
1373 (defsubst mml2015-clear-decrypt-function
()
1374 (nth 6 (assq mml2015-use mml2015-function-alist
)))
1376 (defsubst mml2015-clear-verify-function
()
1377 (nth 5 (assq mml2015-use mml2015-function-alist
)))
1380 (defun mml2015-decrypt (handle ctl
)
1381 (mml2015-clean-buffer)
1382 (let ((func (nth 4 (assq mml2015-use mml2015-function-alist
))))
1384 (funcall func handle ctl
)
1388 (defun mml2015-decrypt-test (handle ctl
)
1392 (defun mml2015-verify (handle ctl
)
1393 (mml2015-clean-buffer)
1394 (let ((func (nth 3 (assq mml2015-use mml2015-function-alist
))))
1396 (funcall func handle ctl
)
1400 (defun mml2015-verify-test (handle ctl
)
1404 (defun mml2015-encrypt (cont &optional sign
)
1405 (mml2015-clean-buffer)
1406 (let ((func (nth 2 (assq mml2015-use mml2015-function-alist
))))
1408 (funcall func cont sign
)
1409 (error "Cannot find encrypt function"))))
1412 (defun mml2015-sign (cont)
1413 (mml2015-clean-buffer)
1414 (let ((func (nth 1 (assq mml2015-use mml2015-function-alist
))))
1417 (error "Cannot find sign function"))))
1420 (defun mml2015-self-encrypt ()
1421 (mml2015-encrypt nil
))
1425 ;; arch-tag: b04701d5-0b09-44d8-bed8-de901bf435f2
1426 ;;; mml2015.el ends here