1 \input texinfo @c -*-texinfo-*-
9 This file describes the PGG.
11 Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
12 Copyright (C) 2001 Daiki Ueno.
15 Permission is granted to copy, distribute and/or modify this document
16 under the terms of the GNU Free Documentation License, Version 1.2 or
17 any later version published by the Free Software Foundation; with no
18 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
19 Texts. A copy of the license is included in the section entitled ``GNU
20 Free Documentation License''.
26 * PGG: (pgg). Emacs interface to various PGP implementations.
29 @settitle PGG @value{VERSION}
38 @vskip 0pt plus 1filll
45 This manual describes PGG. PGG is an interface library between Emacs
46 and various tools for secure communication. PGG also provides a simple
47 user interface to encrypt, decrypt, sign, and verify MIME messages.
50 * Overview:: What PGG is.
51 * Prerequisites:: Complicated stuff you may have to do.
52 * How to use:: Getting started quickly.
54 * Parsing OpenPGP packets::
62 PGG is an interface library between Emacs and various tools for secure
63 communication. Even though Mailcrypt has similar feature, it does not
64 deal with detached PGP messages, normally used in PGP/MIME
65 infrastructure. This was the main reason why I wrote the new library.
67 PGP/MIME is an application of MIME Object Security Services (RFC1848).
68 The standard is documented in RFC2015.
71 @chapter Prerequisites
73 PGG requires at least one implementation of privacy guard system.
74 This document assumes that you have already obtained and installed them
75 and that you are familiar with its basic functions.
77 By default, PGG uses GnuPG, but Pretty Good Privacy version 2 or version
78 5 are also supported. If you are new to such a system, I recommend that
79 you should look over the GNU Privacy Handbook (GPH) which is available
80 at @uref{http://www.gnupg.org/gph/}.
85 The toplevel interface of this library is quite simple, and only
86 intended to use with public-key cryptographic operation.
88 To use PGG, evaluate following expression at the beginning of your
95 If you want to check existence of pgg.el at runtime, instead you can
96 list autoload setting for desired functions as follows.
99 (autoload 'pgg-encrypt-region "pgg"
100 "Encrypt the current region." t)
101 (autoload 'pgg-decrypt-region "pgg"
102 "Decrypt the current region." t)
103 (autoload 'pgg-sign-region "pgg"
104 "Sign the current region." t)
105 (autoload 'pgg-verify-region "pgg"
106 "Verify the current region." t)
107 (autoload 'pgg-insert-key "pgg"
108 "Insert the ASCII armored public key." t)
109 (autoload 'pgg-snarf-keys-region "pgg"
110 "Import public keys in the current region." t)
115 * Selecting an implementation::
116 * Caching passphrase::
117 * Default user identity::
121 @section User Commands
123 At this time you can use some cryptographic commands. The behavior of
124 these commands relies on a fashion of invocation because they are also
125 intended to be used as library functions. In case you don't have the
126 signer's public key, for example, the function @code{pgg-verify-region}
127 fails immediately, but if the function had been called interactively, it
128 would ask you to retrieve the signer's public key from the server.
130 @deffn Command pgg-encrypt-region start end recipients &optional sign
131 Encrypt the current region between @var{start} and @var{end} for
132 @var{recipients}. When the function were called interactively, you
133 would be asked about the recipients.
135 If encryption is successful, it replaces the current region contents (in
136 the accessible portion) with the resulting data.
138 If optional argument @var{sign} is non-@code{nil}, the function is
139 request to do a combined sign and encrypt. This currently only work
143 @deffn Command pgg-decrypt-region start end
144 Decrypt the current region between @var{start} and @var{end}. If
145 decryption is successful, it replaces the current region contents (in
146 the accessible portion) with the resulting data.
149 @deffn Command pgg-sign-region start end &optional cleartext
150 Make the signature from text between @var{start} and @var{end}. If the
151 optional third argument @var{cleartext} is non-@code{nil}, or the
152 function is called interactively, it does not create a detached
153 signature. In such a case, it replaces the current region contents (in
154 the accessible portion) with the resulting data.
157 @deffn Command pgg-verify-region start end &optional signature fetch
158 Verify the current region between @var{start} and @var{end}. If the
159 optional third argument @var{signature} is non-@code{nil}, it is treated
160 as the detached signature file of the current region.
162 If the optional 4th argument @var{fetch} is non-@code{nil}, or the
163 function is called interactively, we attempt to fetch the signer's
164 public key from the key server.
167 @deffn Command pgg-insert-key
168 Retrieve the user's public key and insert it as ASCII-armored format.
171 @deffn Command pgg-snarf-keys-region start end
172 Collect public keys in the current region between @var{start} and
173 @var{end}, and add them into the user's keyring.
176 @node Selecting an implementation
177 @section Selecting an implementation
179 Since PGP has a long history and there are a number of PGP
180 implementations available today, the function which each one has differs
181 considerably. For example, if you are using GnuPG, you know you can
182 select cipher algorithm from 3DES, CAST5, BLOWFISH, and so on, but on
183 the other hand the version 2 of PGP only supports IDEA.
185 Which implementation is used is controlled by the @code{pgg-scheme}
186 variable. If it is @code{nil} (the default), the value of the
187 @code{pgg-default-scheme} variable will be used instead.
190 Force specify the scheme of PGP implementation. The value can be set to
191 @code{gpg}, @code{pgp}, and @code{pgp5}. The default is @code{nil}.
194 @defvar pgg-default-scheme
195 The default scheme of PGP implementation. The value should be one of
196 @code{gpg}, @code{pgp}, and @code{pgp5}. The default is @code{gpg}.
199 @node Caching passphrase
200 @section Caching passphrase
202 PGG uses a simple passphrase caching mechanism, which is enabled by
205 @defvar pgg-cache-passphrase
206 If non-@code{nil}, store passphrases. The default value of this
207 variable is @code{t}. If you were worry about security issue, however,
208 you could stop caching with setting it @code{nil}.
211 @defvar pgg-passphrase-cache-expiry
212 Elapsed time for expiration in seconds.
215 @node Default user identity
216 @section Default user identity
218 The PGP implementation is usually able to select the proper key to use
219 for signing and decryption, but if you have more than one key, you may
220 need to specify the key id to use.
222 @defvar pgg-default-user-id
223 User ID of your default identity. It defaults to the value returned
224 by @samp{(user-login-name)}. You can customize this variable.
227 @defvar pgg-gpg-user-id
228 User ID of the GnuPG default identity. It defaults to @samp{nil}.
229 This overrides @samp{pgg-default-user-id}. You can customize this
233 @defvar pgg-pgp-user-id
234 User ID of the PGP 2.x/6.x default identity. It defaults to
235 @samp{nil}. This overrides @samp{pgg-default-user-id}. You can
236 customize this variable.
239 @defvar pgg-pgp5-user-id
240 User ID of the PGP 5.x default identity. It defaults to @samp{nil}.
241 This overrides @samp{pgg-default-user-id}. You can customize this
246 @chapter Architecture
248 PGG introduces the notion of a "scheme of PGP implementation" (used
249 interchangeably with "scheme" in this document). This term refers to a
250 singleton object wrapped with the luna object system.
252 Since PGG was designed for accessing and developing PGP functionality,
253 the architecture had to be designed not just for interoperability but
254 also for extensiblity. In this chapter we explore the architecture
255 while finding out how to write the PGG back end.
264 @section Initializing
266 A scheme must be initialized before it is used.
267 It had better guarantee to keep only one instance of a scheme.
269 The following code is snipped out of @file{pgg-gpg.el}. Once an
270 instance of @code{pgg-gpg} scheme is initialized, it's stored to the
271 variable @code{pgg-scheme-gpg-instance} and will be reused from now on.
274 (defvar pgg-scheme-gpg-instance nil)
276 (defun pgg-make-scheme-gpg ()
277 (or pgg-scheme-gpg-instance
278 (setq pgg-scheme-gpg-instance
279 (luna-make-entity 'pgg-scheme-gpg))))
282 The name of the function must follow the
283 regulation---@code{pgg-make-scheme-} follows the back end name.
285 @node Back end methods
286 @section Back end methods
288 In each back end, these methods must be present. The output of these
289 methods is stored in special buffers (@ref{Getting output}), so that
290 these methods must tell the status of the execution.
292 @deffn Method pgg-scheme-lookup-key scheme string &optional type
293 Return keys associated with @var{string}. If the optional third
294 argument @var{type} is non-@code{nil}, it searches from the secret
298 @deffn Method pgg-scheme-encrypt-region scheme start end recipients &optional sign
299 Encrypt the current region between @var{start} and @var{end} for
300 @var{recipients}. If @var{sign} is non-@code{nil}, do a combined sign
301 and encrypt. If encryption is successful, it returns @code{t},
302 otherwise @code{nil}.
305 @deffn Method pgg-scheme-decrypt-region scheme start end
306 Decrypt the current region between @var{start} and @var{end}. If
307 decryption is successful, it returns @code{t}, otherwise @code{nil}.
310 @deffn Method pgg-scheme-sign-region scheme start end &optional cleartext
311 Make the signature from text between @var{start} and @var{end}. If the
312 optional third argument @var{cleartext} is non-@code{nil}, it does not
313 create a detached signature. If signing is successful, it returns
314 @code{t}, otherwise @code{nil}.
317 @deffn Method pgg-scheme-verify-region scheme start end &optional signature
318 Verify the current region between @var{start} and @var{end}. If the
319 optional third argument @var{signature} is non-@code{nil}, it is treated
320 as the detached signature of the current region. If the signature is
321 successfully verified, it returns @code{t}, otherwise @code{nil}.
324 @deffn Method pgg-scheme-insert-key scheme
325 Retrieve the user's public key and insert it as ASCII-armored format.
326 On success, it returns @code{t}, otherwise @code{nil}.
329 @deffn Method pgg-scheme-snarf-keys-region scheme start end
330 Collect public keys in the current region between @var{start} and
331 @var{end}, and add them into the user's keyring.
332 On success, it returns @code{t}, otherwise @code{nil}.
336 @section Getting output
338 The output of the back end methods (@ref{Back end methods}) is stored in
339 special buffers, so that these methods must tell the status of the
342 @defvar pgg-errors-buffer
343 The standard error output of the execution of the PGP command is stored
347 @defvar pgg-output-buffer
348 The standard output of the execution of the PGP command is stored here.
351 @defvar pgg-status-buffer
352 The rest of status information of the execution of the PGP command is
356 @node Parsing OpenPGP packets
357 @chapter Parsing OpenPGP packets
359 The format of OpenPGP messages is maintained in order to publish all
360 necessary information needed to develop interoperable applications.
361 The standard is documented in RFC 2440.
363 PGG has its own parser for the OpenPGP packets.
365 @defun pgg-parse-armor string
366 List the sequence of packets in @var{string}.
369 @defun pgg-parse-armor-region start end
370 List the sequence of packets in the current region between @var{start}
374 @defvar pgg-ignore-packet-checksum
375 If non-@code{nil}, don't check the checksum of the packets.
379 @chapter Function Index
383 @chapter Variable Index
393 arch-tag: 0c205838-34b9-41a5-b9d7-49ae57ccac85