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