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