annotate lisp/pgg-parse.el @ 78327:61e58bfd905f

*** empty log message ***
author Glenn Morris <rgm@gnu.org>
date Wed, 25 Jul 2007 08:15:13 +0000
parents 9355f9b7bbff
children 73661ddc7ac7 b7d08fe21e5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
1 ;;; pgg-parse.el --- OpenPGP packet parsing
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
2
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 66383
diff changeset
3 ;; Copyright (C) 1999, 2002, 2003, 2004, 2005,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
4 ;; 2006, 2007 Free Software Foundation, Inc.
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
5
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
6 ;; Author: Daiki Ueno <ueno@unixuser.org>
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
7 ;; Created: 1999/10/28
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
8 ;; Keywords: PGP, OpenPGP, GnuPG
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
9
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
11
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
66383
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
15 ;; any later version.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
16
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
21
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02110-1301, USA.
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
26
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
28
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
29 ;; This module is based on
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
30
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
31 ;; [OpenPGP] RFC 2440: "OpenPGP Message Format"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
32 ;; by John W. Noerenberg, II <jwn2@qualcomm.com>,
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
33 ;; Jon Callas <jon@pgp.com>, Lutz Donnerhacke <lutz@iks-jena.de>,
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
34 ;; Hal Finney <hal@pgp.com> and Rodney Thayer <rodney@unitran.com>
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
35 ;; (1998/11)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
36
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
37 ;;; Code:
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
38
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
39 (eval-when-compile (require 'cl))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
40
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
41 (defgroup pgg-parse ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
42 "OpenPGP packet parsing."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
43 :group 'pgg)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
44
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
45 (defcustom pgg-parse-public-key-algorithm-alist
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
46 '((1 . RSA) (2 . RSA-E) (3 . RSA-S) (16 . ELG-E) (17 . DSA) (20 . ELG))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
47 "Alist of the assigned number to the public key algorithm."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
48 :group 'pgg-parse
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
49 :type '(repeat
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
50 (cons (sexp :tag "Number") (sexp :tag "Type"))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
51
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
52 (defcustom pgg-parse-symmetric-key-algorithm-alist
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
53 '((1 . IDEA) (2 . 3DES) (4 . CAST5) (5 . SAFER-SK128))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
54 "Alist of the assigned number to the simmetric key algorithm."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
55 :group 'pgg-parse
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
56 :type '(repeat
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
57 (cons (sexp :tag "Number") (sexp :tag "Type"))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
58
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
59 (defcustom pgg-parse-hash-algorithm-alist
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
60 '((1 . MD5) (2 . SHA1) (3 . RIPEMD160) (5 . MD2) (8 . SHA256) (9 . SHA384)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
61 (10 . SHA512))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
62 "Alist of the assigned number to the cryptographic hash algorithm."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
63 :group 'pgg-parse
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
64 :type '(repeat
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
65 (cons (sexp :tag "Number") (sexp :tag "Type"))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
66
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
67 (defcustom pgg-parse-compression-algorithm-alist
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
68 '((0 . nil); Uncompressed
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
69 (1 . ZIP)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
70 (2 . ZLIB))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
71 "Alist of the assigned number to the compression algorithm."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
72 :group 'pgg-parse
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
73 :type '(repeat
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
74 (cons (sexp :tag "Number") (sexp :tag "Type"))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
75
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
76 (defcustom pgg-parse-signature-type-alist
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
77 '((0 . "Signature of a binary document")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
78 (1 . "Signature of a canonical text document")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
79 (2 . "Standalone signature")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
80 (16 . "Generic certification of a User ID and Public Key packet")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
81 (17 . "Persona certification of a User ID and Public Key packet")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
82 (18 . "Casual certification of a User ID and Public Key packet")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
83 (19 . "Positive certification of a User ID and Public Key packet")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
84 (24 . "Subkey Binding Signature")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
85 (31 . "Signature directly on a key")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
86 (32 . "Key revocation signature")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
87 (40 . "Subkey revocation signature")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
88 (48 . "Certification revocation signature")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
89 (64 . "Timestamp signature."))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
90 "Alist of the assigned number to the signature type."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
91 :group 'pgg-parse
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
92 :type '(repeat
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
93 (cons (sexp :tag "Number") (sexp :tag "Type"))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
94
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
95 (defcustom pgg-ignore-packet-checksum t; XXX
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
96 "If non-nil checksum of each ascii armored packet will be ignored."
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
97 :group 'pgg-parse
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
98 :type 'boolean)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
99
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
100 (defvar pgg-armor-header-lines
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
101 '("^-----BEGIN PGP MESSAGE\\(, PART [0-9]+\\(/[0-9]+\\)?\\)?-----\r?$"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
102 "^-----BEGIN PGP PUBLIC KEY BLOCK-----\r?$"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
103 "^-----BEGIN PGP PRIVATE KEY BLOCK-----\r?$"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
104 "^-----BEGIN PGP SIGNATURE-----\r?$")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
105 "Armor headers.")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
106
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
107 (eval-and-compile
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
108 (defalias 'pgg-char-int (if (fboundp 'char-int)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
109 'char-int
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
110 'identity)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
111
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
112 (defmacro pgg-format-key-identifier (string)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
113 `(mapconcat (lambda (c) (format "%02X" (pgg-char-int c)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
114 ,string "")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
115 ;; `(upcase (apply #'format "%02x%02x%02x%02x%02x%02x%02x%02x"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
116 ;; (string-to-number-list ,string)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
117 )
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
118
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
119 (defmacro pgg-parse-time-field (bytes)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
120 `(list (logior (lsh (car ,bytes) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
121 (nth 1 ,bytes))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
122 (logior (lsh (nth 2 ,bytes) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
123 (nth 3 ,bytes))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
124 0))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
125
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
126 (defmacro pgg-byte-after (&optional pos)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
127 `(pgg-char-int (char-after ,(or pos `(point)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
128
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
129 (defmacro pgg-read-byte ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
130 `(pgg-char-int (char-after (prog1 (point) (forward-char)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
131
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
132 (defmacro pgg-read-bytes-string (nbytes)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
133 `(buffer-substring
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
134 (point) (prog1 (+ ,nbytes (point))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
135 (forward-char ,nbytes))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
136
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
137 (defmacro pgg-read-bytes (nbytes)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
138 `(mapcar #'pgg-char-int (pgg-read-bytes-string ,nbytes))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
139 ;; `(string-to-number-list (pgg-read-bytes-string ,nbytes))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
140 )
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
141
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
142 (defmacro pgg-read-body-string (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
143 `(if (nth 1 ,ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
144 (pgg-read-bytes-string (nth 1 ,ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
145 (pgg-read-bytes-string (- (point-max) (point)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
146
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
147 (defmacro pgg-read-body (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
148 `(mapcar #'pgg-char-int (pgg-read-body-string ,ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
149 ;; `(string-to-number-list (pgg-read-body-string ,ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
150 )
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
151
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
152 (defalias 'pgg-skip-bytes 'forward-char)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
153
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
154 (defmacro pgg-skip-header (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
155 `(pgg-skip-bytes (nth 2 ,ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
156
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
157 (defmacro pgg-skip-body (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
158 `(pgg-skip-bytes (nth 1 ,ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
159
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
160 (defmacro pgg-set-alist (alist key value)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
161 `(setq ,alist (nconc ,alist (list (cons ,key ,value)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
162
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
163 (when (fboundp 'define-ccl-program)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
164
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
165 (define-ccl-program pgg-parse-crc24
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
166 '(1
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
167 ((loop
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
168 (read r0) (r1 ^= r0) (r2 ^= 0)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
169 (r5 = 0)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
170 (loop
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
171 (r1 <<= 1)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
172 (r1 += ((r2 >> 15) & 1))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
173 (r2 <<= 1)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
174 (if (r1 & 256)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
175 ((r1 ^= 390) (r2 ^= 19707)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
176 (if (r5 < 7)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
177 ((r5 += 1)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
178 (repeat))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
179 (repeat)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
180
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
181 (defun pgg-parse-crc24-string (string)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
182 (let ((h (vector nil 183 1230 nil nil nil nil nil nil)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
183 (ccl-execute-on-string pgg-parse-crc24 h string)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
184 (format "%c%c%c"
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
185 (logand (aref h 1) 255)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
186 (logand (lsh (aref h 2) -8) 255)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
187 (logand (aref h 2) 255)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
188
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
189 (defmacro pgg-parse-length-type (c)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
190 `(cond
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
191 ((< ,c 192) (cons ,c 1))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
192 ((< ,c 224)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
193 (cons (+ (lsh (- ,c 192) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
194 (pgg-byte-after (+ 2 (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
195 192)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
196 2))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
197 ((= ,c 255)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
198 (cons (cons (logior (lsh (pgg-byte-after (+ 2 (point))) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
199 (pgg-byte-after (+ 3 (point))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
200 (logior (lsh (pgg-byte-after (+ 4 (point))) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
201 (pgg-byte-after (+ 5 (point)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
202 5))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
203 (t;partial body length
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
204 '(0 . 0))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
205
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
206 (defun pgg-parse-packet-header ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
207 (let ((ptag (pgg-byte-after))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
208 length-type content-tag packet-bytes header-bytes)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
209 (if (zerop (logand 64 ptag));Old format
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
210 (progn
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
211 (setq length-type (logand ptag 3)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
212 length-type (if (= 3 length-type) 0 (lsh 1 length-type))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
213 content-tag (logand 15 (lsh ptag -2))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
214 packet-bytes 0
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
215 header-bytes (1+ length-type))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
216 (dotimes (i length-type)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
217 (setq packet-bytes
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
218 (logior (lsh packet-bytes 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
219 (pgg-byte-after (+ 1 i (point)))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
220 (setq content-tag (logand 63 ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
221 length-type (pgg-parse-length-type
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
222 (pgg-byte-after (1+ (point))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
223 packet-bytes (car length-type)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
224 header-bytes (1+ (cdr length-type))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
225 (list content-tag packet-bytes header-bytes)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
226
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
227 (defun pgg-parse-packet (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
228 (case (car ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
229 (1 ;Public-Key Encrypted Session Key Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
230 (pgg-parse-public-key-encrypted-session-key-packet ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
231 (2 ;Signature Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
232 (pgg-parse-signature-packet ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
233 (3 ;Symmetric-Key Encrypted Session Key Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
234 (pgg-parse-symmetric-key-encrypted-session-key-packet ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
235 ;; 4 -- One-Pass Signature Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
236 ;; 5 -- Secret Key Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
237 (6 ;Public Key Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
238 (pgg-parse-public-key-packet ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
239 ;; 7 -- Secret Subkey Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
240 ;; 8 -- Compressed Data Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
241 (9 ;Symmetrically Encrypted Data Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
242 (pgg-read-body-string ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
243 (10 ;Marker Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
244 (pgg-read-body-string ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
245 (11 ;Literal Data Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
246 (pgg-read-body-string ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
247 ;; 12 -- Trust Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
248 (13 ;User ID Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
249 (pgg-read-body-string ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
250 ;; 14 -- Public Subkey Packet
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
251 ;; 60 .. 63 -- Private or Experimental Values
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
252 ))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
253
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
254 (defun pgg-parse-packets (&optional header-parser body-parser)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
255 (let ((header-parser
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
256 (or header-parser
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
257 (function pgg-parse-packet-header)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
258 (body-parser
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
259 (or body-parser
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
260 (function pgg-parse-packet)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
261 result ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
262 (while (> (point-max) (1+ (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
263 (setq ptag (funcall header-parser))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
264 (pgg-skip-header ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
265 (push (cons (car ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
266 (save-excursion
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
267 (funcall body-parser ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
268 result)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
269 (if (zerop (nth 1 ptag))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
270 (goto-char (point-max))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
271 (forward-char (nth 1 ptag))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
272 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
273
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
274 (defun pgg-parse-signature-subpacket-header ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
275 (let ((length-type (pgg-parse-length-type (pgg-byte-after))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
276 (list (pgg-byte-after (+ (cdr length-type) (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
277 (1- (car length-type))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
278 (1+ (cdr length-type)))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
279
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
280 (defun pgg-parse-signature-subpacket (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
281 (case (car ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
282 (2 ;signature creation time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
283 (cons 'creation-time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
284 (let ((bytes (pgg-read-bytes 4)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
285 (pgg-parse-time-field bytes))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
286 (3 ;signature expiration time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
287 (cons 'signature-expiry
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
288 (let ((bytes (pgg-read-bytes 4)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
289 (pgg-parse-time-field bytes))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
290 (4 ;exportable certification
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
291 (cons 'exportability (pgg-read-byte)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
292 (5 ;trust signature
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
293 (cons 'trust-level (pgg-read-byte)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
294 (6 ;regular expression
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
295 (cons 'regular-expression
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
296 (pgg-read-body-string ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
297 (7 ;revocable
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
298 (cons 'revocability (pgg-read-byte)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
299 (9 ;key expiration time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
300 (cons 'key-expiry
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
301 (let ((bytes (pgg-read-bytes 4)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
302 (pgg-parse-time-field bytes))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
303 ;; 10 = placeholder for backward compatibility
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
304 (11 ;preferred symmetric algorithms
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
305 (cons 'preferred-symmetric-key-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
306 (cdr (assq (pgg-read-byte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
307 pgg-parse-symmetric-key-algorithm-alist))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
308 (12 ;revocation key
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
309 )
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
310 (16 ;issuer key ID
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
311 (cons 'key-identifier
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
312 (pgg-format-key-identifier (pgg-read-body-string ptag))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
313 (20 ;notation data
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
314 (pgg-skip-bytes 4)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
315 (cons 'notation
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
316 (let ((name-bytes (pgg-read-bytes 2))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
317 (value-bytes (pgg-read-bytes 2)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
318 (cons (pgg-read-bytes-string
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
319 (logior (lsh (car name-bytes) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
320 (nth 1 name-bytes)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
321 (pgg-read-bytes-string
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
322 (logior (lsh (car value-bytes) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
323 (nth 1 value-bytes)))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
324 (21 ;preferred hash algorithms
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
325 (cons 'preferred-hash-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
326 (cdr (assq (pgg-read-byte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
327 pgg-parse-hash-algorithm-alist))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
328 (22 ;preferred compression algorithms
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
329 (cons 'preferred-compression-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
330 (cdr (assq (pgg-read-byte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
331 pgg-parse-compression-algorithm-alist))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
332 (23 ;key server preferences
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
333 (cons 'key-server-preferences
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
334 (pgg-read-body ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
335 (24 ;preferred key server
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
336 (cons 'preferred-key-server
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
337 (pgg-read-body-string ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
338 ;; 25 = primary user id
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
339 (26 ;policy URL
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
340 (cons 'policy-url (pgg-read-body-string ptag)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
341 ;; 27 = key flags
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
342 ;; 28 = signer's user id
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
343 ;; 29 = reason for revocation
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
344 ;; 100 to 110 = internal or user-defined
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
345 ))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
346
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
347 (defun pgg-parse-signature-packet (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
348 (let* ((signature-version (pgg-byte-after))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
349 (result (list (cons 'version signature-version)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
350 hashed-material field n)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
351 (cond
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
352 ((= signature-version 3)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
353 (pgg-skip-bytes 2)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
354 (setq hashed-material (pgg-read-bytes 5))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
355 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
356 'signature-type
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
357 (cdr (assq (pop hashed-material)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
358 pgg-parse-signature-type-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
359 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
360 'creation-time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
361 (pgg-parse-time-field hashed-material))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
362 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
363 'key-identifier
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
364 (pgg-format-key-identifier
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
365 (pgg-read-bytes-string 8)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
366 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
367 'public-key-algorithm (pgg-read-byte))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
368 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
369 'hash-algorithm (pgg-read-byte)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
370 ((= signature-version 4)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
371 (pgg-skip-bytes 1)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
372 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
373 'signature-type
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
374 (cdr (assq (pgg-read-byte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
375 pgg-parse-signature-type-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
376 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
377 'public-key-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
378 (pgg-read-byte))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
379 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
380 'hash-algorithm (pgg-read-byte))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
381 (when (>= 10000 (setq n (pgg-read-bytes 2)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
382 n (logior (lsh (car n) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
383 (nth 1 n))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
384 (save-restriction
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
385 (narrow-to-region (point)(+ n (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
386 (nconc result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
387 (mapcar (function cdr) ;remove packet types
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
388 (pgg-parse-packets
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
389 #'pgg-parse-signature-subpacket-header
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
390 #'pgg-parse-signature-subpacket)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
391 (goto-char (point-max))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
392 (when (>= 10000 (setq n (pgg-read-bytes 2)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
393 n (logior (lsh (car n) 8)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
394 (nth 1 n))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
395 (save-restriction
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
396 (narrow-to-region (point)(+ n (point)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
397 (nconc result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
398 (mapcar (function cdr) ;remove packet types
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
399 (pgg-parse-packets
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
400 #'pgg-parse-signature-subpacket-header
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
401 #'pgg-parse-signature-subpacket)))))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
402
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
403 (setcdr (setq field (assq 'public-key-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
404 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
405 (cdr (assq (cdr field)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
406 pgg-parse-public-key-algorithm-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
407 (setcdr (setq field (assq 'hash-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
408 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
409 (cdr (assq (cdr field)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
410 pgg-parse-hash-algorithm-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
411 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
412
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
413 (defun pgg-parse-public-key-encrypted-session-key-packet (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
414 (let (result)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
415 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
416 'version (pgg-read-byte))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
417 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
418 'key-identifier
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
419 (pgg-format-key-identifier
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
420 (pgg-read-bytes-string 8)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
421 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
422 'public-key-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
423 (cdr (assq (pgg-read-byte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
424 pgg-parse-public-key-algorithm-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
425 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
426
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
427 (defun pgg-parse-symmetric-key-encrypted-session-key-packet (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
428 (let (result)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
429 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
430 'version
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
431 (pgg-read-byte))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
432 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
433 'symmetric-key-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
434 (cdr (assq (pgg-read-byte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
435 pgg-parse-symmetric-key-algorithm-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
436 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
437
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
438 (defun pgg-parse-public-key-packet (ptag)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
439 (let* ((key-version (pgg-read-byte))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
440 (result (list (cons 'version key-version)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
441 field)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
442 (cond
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
443 ((= 3 key-version)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
444 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
445 'creation-time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
446 (let ((bytes (pgg-read-bytes 4)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
447 (pgg-parse-time-field bytes)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
448 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
449 'key-expiry (pgg-read-bytes 2))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
450 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
451 'public-key-algorithm (pgg-read-byte)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
452 ((= 4 key-version)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
453 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
454 'creation-time
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
455 (let ((bytes (pgg-read-bytes 4)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
456 (pgg-parse-time-field bytes)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
457 (pgg-set-alist result
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
458 'public-key-algorithm (pgg-read-byte))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
459
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
460 (setcdr (setq field (assq 'public-key-algorithm
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
461 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
462 (cdr (assq (cdr field)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
463 pgg-parse-public-key-algorithm-alist)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
464 result))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
465
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
466 (defun pgg-decode-packets ()
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
467 (if (re-search-forward "^=\\([A-Za-z0-9+/]\\{4\\}\\)$" nil t)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
468 (let ((p (match-beginning 0))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
469 (checksum (match-string 1)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
470 (delete-region p (point-max))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
471 (if (ignore-errors (base64-decode-region (point-min) p))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
472 (or (not (fboundp 'pgg-parse-crc24-string))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
473 pgg-ignore-packet-checksum
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
474 (string-equal (base64-encode-string (pgg-parse-crc24-string
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
475 (buffer-string)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
476 checksum)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
477 (progn
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
478 (message "PGP packet checksum does not match")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
479 nil))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
480 (message "PGP packet contain invalid base64")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
481 nil))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
482 (message "PGP packet checksum not found")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
483 nil))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
484
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
485 (defun pgg-decode-armor-region (start end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
486 (save-restriction
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
487 (narrow-to-region start end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
488 (goto-char (point-min))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
489 (re-search-forward "^-+BEGIN PGP" nil t)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
490 (delete-region (point-min)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
491 (and (search-forward "\n\n")
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
492 (match-end 0)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
493 (when (pgg-decode-packets)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
494 (goto-char (point-min))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
495 (pgg-parse-packets))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
496
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
497 (defun pgg-parse-armor (string)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
498 (with-temp-buffer
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
499 (buffer-disable-undo)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
500 (if (fboundp 'set-buffer-multibyte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
501 (set-buffer-multibyte nil))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
502 (insert string)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
503 (pgg-decode-armor-region (point-min)(point))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
504
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
505 (eval-and-compile
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
506 (defalias 'pgg-string-as-unibyte (if (fboundp 'string-as-unibyte)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
507 'string-as-unibyte
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
508 'identity)))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
509
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
510 (defun pgg-parse-armor-region (start end)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
511 (pgg-parse-armor (pgg-string-as-unibyte (buffer-substring start end))))
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
512
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
513 (provide 'pgg-parse)
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
514
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
515 ;;; arch-tag: 16c2eb82-1313-4a7c-a70f-420709b5b43e
c82982d6cbc4 Moved pgg*.el files from lisp/gnus to lisp.
Eli Zaretskii <eliz@gnu.org>
parents:
diff changeset
516 ;;; pgg-parse.el ends here