69b18b9cfeaae1528756dab20f8d7bda8ea95fe6
[elisp/gnus.git-] / texi / pgg.texi
1 \input texinfo                  @c -*-texinfo-*-
2
3 @setfilename pgg.info
4
5 @set VERSION 0.1
6
7 @direntry
8 * PGG: (pgg).   Emacs interface to various PGP implementations.
9 @end direntry
10
11 @settitle PGG @value{VERSION}
12
13 @ifinfo
14 This file describes the PGG.
15
16 Copyright (C) 2001 Daiki Ueno.
17
18 Permission is granted to copy, distribute and/or modify this document
19 under the terms of the GNU Free Documentation License, Version 1.1 or
20 any later version published by the Free Software Foundation; with no
21 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
22 Texts.  A copy of the license is included in the section entitled "GNU
23 Free Documentation License".
24 @end ifinfo
25
26 @tex
27
28 @titlepage
29 @title PGG
30
31 @author by Daiki Ueno
32 @page
33
34 @vskip 0pt plus 1filll
35 Copyright @copyright{} 2001 Daiki Ueno.
36
37 Permission is granted to copy, distribute and/or modify this document
38 under the terms of the GNU Free Documentation License, Version 1.1 or
39 any later version published by the Free Software Foundation; with no
40 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
41 Texts.  A copy of the license is included in the section entitled "GNU
42 Free Documentation License".
43 @end titlepage
44 @page
45
46 @end tex
47
48 @node Top
49 @top PGG
50 This manual describes PGG.  PGG is an interface library between Emacs
51 and various tools for secure communication.  PGG also provides a simple
52 user interface to encrypt, decrypt, sign, and verify MIME messages.
53
54 @menu
55 * Overview::                    What PGG is.
56 * Prerequisites::               Complicated stuff you may have to do.
57 * How to use::                  Getting started quickly.
58 * Architecture::                
59 * Parsing OpenPGP packets::     
60 * Function Index::              
61 * Variable Index::              
62 @end menu
63
64 @node Overview
65 @chapter Overview
66
67 PGG is an interface library between Emacs and various tools for secure
68 communication.  Even though Mailcrypt has similar feature, it does not
69 deal with detached PGP messages, normally used in PGP/MIME
70 infrastructure.  This was the main reason why I wrote the new library.
71
72 PGP/MIME is an application of MIME Object Security Services (RFC1848).
73 The standard is documented in RFC2015.
74
75 @node Prerequisites
76 @chapter Prerequisites
77
78 PGG requires at least one implementation of privacy guard system.
79 This document assumes that you have already obtained and installed them
80 and that you are familiar with its basic functions.
81
82 By default, PGG uses GnuPG, but Pretty Good Privacy version 2 or version
83 5 are also supported.  If you are new to such a system, I recomend that
84 you should look over the GNU Privacy Handbook (GPH) which is available
85 at @uref{http://www.gnupg.org/gph/}.
86
87 @node How to use
88 @chapter How to use
89
90 The toplevel interface of this library is quite simple, and only
91 intended to use with public-key cryptographic operation.
92
93 To use PGG, evaluate following expression at the beginning of your
94 application program.
95
96 @lisp
97 (require 'pgg)
98 @end lisp
99
100 If you want to check existence of pgg.el at runtime, instead you can
101 list autoload setting for desired functions as follows.
102
103 @lisp
104 (autoload 'pgg-encrypt-region "pgg"
105   "Encrypt the current region." t)
106 (autoload 'pgg-decrypt-region "pgg"
107   "Decrypt the current region." t)
108 (autoload 'pgg-sign-region "pgg"
109   "Sign the current region." t)
110 (autoload 'pgg-verify-region "pgg"
111   "Verify the current region." t)
112 (autoload 'pgg-insert-key "pgg"
113   "Insert the ASCII armored public key." t)
114 (autoload 'pgg-snarf-keys-region "pgg"
115   "Import public keys in the current region." t)
116 @end lisp
117
118 @menu
119 * User Commands::               
120 * Selecting an implementation::  
121 * Caching passphrase::          
122 @end menu
123
124 @node User Commands
125 @section User Commands
126
127 At this time you can use some cryptographic commands.  The behavior of
128 these commands relies on a fashion of invocation because they are also
129 intended to be used as library functions.  In case you don't have the
130 signer's public key, for example, the function @code{pgg-verify-region}
131 fails immediately, but if the function had been called interactively, it
132 would ask you to retrieve the signer's public key from the server.
133
134 @deffn Command pgg-encrypt-region start end recipients &optional sign
135 Encrypt the current region between @var{start} and @var{end} for
136 @var{recipients}.  When the function were called interactively, you
137 would be asked about the recipients.
138
139 If encryption is successful, it replaces the current region contents (in
140 the accessible portion) with the resulting data.
141
142 If optional argument @var{sign} is non-nil, the function is request to
143 do a combined sign and encrypt.  This currently only work with GnuPG.
144 @end deffn
145
146 @deffn Command pgg-decrypt-region start end
147 Decrypt the current region between @var{start} and @var{end}.  If
148 decryption is successful, it replaces the current region contents (in
149 the accessible portion) with the resulting data.
150 @end deffn
151
152 @deffn Command pgg-sign-region start end &optional cleartext
153 Make the signature from text between @var{start} and @var{end}.  If the
154 optional third argument @var{cleartext} is non-@code{nil}, or the
155 function is called interactively, it does not create a detached
156 signature.  In such a case, it replaces the current region contents (in
157 the accessible portion) with the resulting data.
158 @end deffn
159
160 @deffn Command pgg-verify-region start end &optional signature fetch
161 Verify the current region between @var{start} and @var{end}.  If the
162 optional third argument @var{signature} is non-@code{nil}, or the function
163 is called interactively, it is treated as the detached signature of the
164 current region.
165
166 If the optional 4th argument @var{fetch} is non-@code{nil}, or the
167 function is called interactively, we attempt to fetch the signer's
168 public key from the key server.
169 @end deffn
170
171 @deffn Command pgg-insert-key
172 Retrieve the user's public key and insert it as ASCII-armored format.
173 @end deffn
174
175 @deffn Command pgg-snarf-keys-region start end
176 Collect public keys in the current region between @var{start} and
177 @var{end}, and add them into the user's keyring.
178 @end deffn
179
180 @node Selecting an implementation
181 @section Selecting an implementation
182
183 Since PGP has a long history and there are a number of PGP
184 implementations available today, the function which each one has differs
185 considerably.  For example, if you are using GnuPG, you know you can
186 select cipher algorithm from 3DES, CAST5, BLOWFISH, and so on, but on
187 the other hand the version 2 of PGP only supports IDEA.
188
189 By default, if the variable @var{pgg-scheme} is not set, PGG searches the
190 registered scheme for an implementation of the requested service
191 associated with the named algorithm.  If there are no match, PGG uses
192 @var{pgg-default-scheme}.  In other words, there are two options to
193 control which command is used to process the incoming PGP armors.  One
194 is for encrypting and signing, the other is for decrypting and
195 verifying.
196
197 @defvar pgg-scheme
198 Force specify the scheme of PGP implementation for decrypting and verifying.
199 The value can be @code{gpg}, @code{pgp}, and @code{pgp5}.
200 @end defvar
201
202 @defvar pgg-default-scheme
203 Force specify the scheme of PGP implementation for encrypting and signing.
204 The value can be @code{gpg}, @code{pgp}, and @code{pgp5}.
205 @end defvar
206
207 @node Caching passphrase
208 @section Caching passphrase
209
210 PGG provides a simple passphrase caching mechanism.  If you want to
211 arrange the interaction, set the variable @var{pgg-read-passphrase}.
212
213 @defvar pgg-cache-passphrase
214 If non-@code{nil}, store passphrases.  The default value of this
215 variable is @code{t}.  If you were worry about security issue, however,
216 you could stop caching with setting it @code{nil}.
217 @end defvar
218
219 @defvar pgg-passphrase-cache-expiry
220 Elapsed time for expiration in seconds.
221 @end defvar
222
223 @node Architecture
224 @chapter Architecture
225
226 PGG introduces the notion of a "scheme of PGP implementation" (used
227 interchangeably with "scheme" in this document).  This term refers to a
228 singleton object wrapped with the luna object system.
229
230 Since PGG was designed for accessing and developing PGP functionality,
231 the architecture had to be designed not just for interoperablity but
232 also for extensiblity.  In this chapter we explore the architecture
233 while finding out how to write the PGG backend.
234
235 @menu
236 * Initializing::                
237 * Backend methods::             
238 * Getting output::              
239 @end menu
240
241 @node Initializing
242 @section Initializing
243
244 A scheme must be initialized before it is used.
245 It had better guarantee to keep only one instance of a scheme.
246
247 The following code is snipped out of @file{pgg-gpg.el}.  Once an
248 instance of @code{pgg-gpg} scheme is initialized, it's stored to the
249 variable @var{pgg-scheme-gpg-instance} and will be reused from now on.
250
251 @lisp
252 (defvar pgg-scheme-gpg-instance nil)
253
254 (defun pgg-make-scheme-gpg ()
255   (or pgg-scheme-gpg-instance
256       (setq pgg-scheme-gpg-instance
257             (luna-make-entity 'pgg-scheme-gpg))))
258 @end lisp
259
260 The name of the function must follow the
261 regulation---@code{pgg-make-scheme-} follows the backend name.
262
263 @node Backend methods
264 @section Backend methods
265
266 In each backend, these methods must be present.  The output of these
267 methods is stored in special buffers (@ref{Getting output}), so that
268 these methods must tell the status of the execution.
269
270 @deffn Method pgg-scheme-lookup-key scheme string &optional type
271 Return keys associated with @var{string}.  If the optional third
272 argument @var{type} is non-@code{nil}, it searches from the secret
273 keyrings.
274 @end deffn
275
276 @deffn Method pgg-scheme-encrypt-region scheme start end recipients &optional sign
277 Encrypt the current region between @var{start} and @var{end} for
278 @var{recipients}.  If @var{sign} is non-nil, do a combined sign and
279 encrypt.  If encryption is successful, it returns @code{t}, otherwise
280 @code{nil}.
281 @end deffn
282
283 @deffn Method pgg-scheme-decrypt-region scheme start end
284 Decrypt the current region between @var{start} and @var{end}.  If
285 decryption is successful, it returns @code{t}, otherwise @code{nil}.
286 @end deffn
287
288 @deffn Method pgg-scheme-sign-region scheme start end &optional cleartext
289 Make the signature from text between @var{start} and @var{end}.  If the
290 optional third argument @var{cleartext} is non-@code{nil}, it does not
291 create a detached signature.  If signing is successful, it returns
292 @code{t}, otherwise @code{nil}.
293 @end deffn
294
295 @deffn Method pgg-scheme-verify-region scheme start end &optional signature
296 Verify the current region between @var{start} and @var{end}.  If the
297 optional third argument @var{signature} is non-@code{nil}, it is treated
298 as the detached signature of the current region.  If the signature is
299 successflly verified, it returns @code{t}, otherwise @code{nil}.
300 @end deffn
301
302 @deffn Method pgg-scheme-insert-key scheme
303 Retrieve the user's public key and insert it as ASCII-armored format.
304 On success, it returns @code{t}, otherwise @code{nil}.
305 @end deffn
306
307 @deffn Method pgg-scheme-snarf-keys-region scheme start end
308 Collect public keys in the current region between @var{start} and
309 @var{end}, and add them into the user's keyring.
310 On success, it returns @code{t}, otherwise @code{nil}.
311 @end deffn
312
313 @node Getting output
314 @section Getting output
315
316 The output of the backend methods (@ref{Backend methods}) is stored in
317 special buffers, so that these methods must tell the status of the
318 execution.
319
320 @defvar pgg-errors-buffer
321 The standard error output of the execution of the PGP command is stored
322 here.
323 @end defvar
324
325 @defvar pgg-output-buffer
326 The standard output of the execution of the PGP command is stored here.
327 @end defvar
328
329 @defvar pgg-status-buffer
330 The rest of status information of the execution of the PGP command is
331 stored here.
332 @end defvar
333
334 @node Parsing OpenPGP packets
335 @chapter Parsing OpenPGP packets
336
337 The format of OpenPGP messages is maintained in order to publish all
338 necessary information needed to develop interoperable applications.
339 The standard is documented in RFC 2440.
340
341 PGG has its own parser for the OpenPGP packets.
342
343 @defun pgg-parse-armor string
344 List the sequence of packets in @var{string}.
345 @end defun
346
347 @defun pgg-parse-armor-region start end
348 List the sequence of packets in the current region between @var{start}
349 and @var{end}.
350 @end defun
351
352 @defvar pgg-ignore-packet-checksum
353 If non-@code{nil}, don't check the checksum of the packets.
354 @end defvar
355
356 @node Function Index
357 @chapter Function Index
358 @printindex fn
359
360 @node Variable Index
361 @chapter Variable Index
362 @printindex vr
363
364 @summarycontents
365 @contents
366 @bye
367
368 @c End: