2000-11-13 15:29:58 ShengHuo ZHU <zsh@cs.rochester.edu>
[gnus] / lisp / mml-smime.el
1 ;;; mml-smime.el --- S/MIME support for MML
2 ;; Copyright (c) 2000 Free Software Foundation, Inc.
3
4 ;; Author: Simon Josefsson <simon@josefsson.org>
5 ;; Keywords: Gnus, MIME, SMIME, MML
6
7 ;; This file is a part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;; todo: move s/mime code from mml-sec.el here.
27
28 ;;; Code:
29
30 (require 'smime)
31 (require 'mm-decode)
32
33 (defun mml-smime-verify (handle ctl)
34   (with-current-buffer (mm-handle-multipart-original-buffer ctl)
35     ;; xxx modifies buffer -- noone else uses the buffer, so what the heck
36     (goto-char (point-min))
37     (insert (format "Content-Type: %s; " (mm-handle-media-type ctl)))
38     (insert (format "protocol=\"%s\"; " 
39                     (mm-handle-multipart-ctl-parameter ctl 'protocol)))
40     (insert (format "micalg=\"%s\"; " 
41                     (mm-handle-multipart-ctl-parameter ctl 'micalg)))
42     (insert (format "boundary=\"%s\"\n\n"
43                     (mm-handle-multipart-ctl-parameter ctl 'boundary)))
44     (when (get-buffer smime-details-buffer)
45       (kill-buffer smime-details-buffer))
46     (if (smime-verify-buffer)
47         (progn
48           (mm-set-handle-multipart-parameter 
49            mm-security-handle 'gnus-info "OK")
50           (kill-buffer smime-details-buffer))
51       (mm-set-handle-multipart-parameter 
52        mm-security-handle 'gnus-info "Failed")
53       (mm-set-handle-multipart-parameter
54        mm-security-handle 'gnus-details (with-current-buffer smime-details-buffer 
55                                           (buffer-string))))
56     handle))
57
58 (defun mml-smime-verify-test (handle ctl)
59   smime-openssl-program)
60
61 (provide 'mml-smime)
62
63 ;;; mml-smime.el ends here