fa162eb2d786cccb49fadd64a1273c8b9c91a90c
[gnus] / texi / epa.texi
1 \input texinfo                  @c -*- mode: texinfo -*-
2 @c %**start of header
3 @setfilename epa
4 @settitle EasyPG Assistant User's Manual
5 @c %**end of header
6
7 @set VERSION 1.0.0
8
9 @copying
10 This file describes EasyPG Assistant @value{VERSION}.
11
12 Copyright @copyright{} 2007--2013 Free Software Foundation, Inc.
13
14 @quotation
15 Permission is granted to copy, distribute and/or modify this document
16 under the terms of the GNU Free Documentation License, Version 1.3 or
17 any later version published by the Free Software Foundation; with no
18 Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
19 and with the Back-Cover Texts as in (a) below.  A copy of the license
20 is included in the section entitled ``GNU Free Documentation License''.
21
22 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
23 modify this GNU manual.''
24 @end quotation
25 @end copying
26
27 @dircategory Emacs misc features
28 @direntry
29 * EasyPG Assistant: (epa).      An Emacs user interface to GNU Privacy Guard.
30 @end direntry
31
32 @titlepage
33 @title EasyPG Assistant
34
35 @author by Daiki Ueno
36 @page
37
38 @vskip 0pt plus 1filll
39 @insertcopying
40 @end titlepage
41
42 @contents
43
44 @node Top
45 @top EasyPG Assistant user's manual
46
47 EasyPG Assistant is an Emacs user interface to GNU Privacy Guard
48 (GnuPG, @pxref{Top, , Top, gnupg, Using the GNU Privacy Guard}).
49
50 EasyPG Assistant is a part of the package called EasyPG, an all-in-one
51 GnuPG interface for Emacs.  EasyPG also contains the library interface
52 called EasyPG Library.
53
54 @ifnottex
55 @insertcopying
56 @end ifnottex
57
58 @menu
59 * Overview::
60 * Quick start::
61 * Commands::
62 * Caching Passphrases::
63 * Bug Reports::
64 * GNU Free Documentation License::  The license for this documentation.
65 @end menu
66
67 @node  Overview
68 @chapter Overview
69
70 EasyPG Assistant provides the following features.
71
72 @itemize @bullet
73 @item Key management.
74 @item Cryptographic operations on regions.
75 @item Cryptographic operations on files.
76 @item Dired integration.
77 @item Mail-mode integration.
78 @item Automatic encryption/decryption of *.gpg files.
79 @end itemize
80
81 @node  Quick start
82 @chapter Quick start
83
84 EasyPG Assistant commands are prefixed by @samp{epa-}.  For example,
85
86 @itemize @bullet
87 @item To browse your keyring, type @kbd{M-x epa-list-keys}
88
89 @item To create a cleartext signature of the region, type @kbd{M-x epa-sign-region}
90
91 @item To encrypt a file, type @kbd{M-x epa-encrypt-file}
92 @end itemize
93
94 EasyPG Assistant provides several cryptographic features which can be
95 integrated into other Emacs functionalities.  For example, automatic
96 encryption/decryption of @samp{*.gpg} files.
97
98 @node Commands
99 @chapter Commands
100
101 This chapter introduces various commands for typical use cases.
102
103 @menu
104 * Key management::
105 * Cryptographic operations on regions::
106 * Cryptographic operations on files::
107 * Dired integration::
108 * Mail-mode integration::
109 * Encrypting/decrypting gpg files::
110 @end menu
111
112 @node Key management
113 @section Key management
114 Probably the first step of using EasyPG Assistant is to browse your
115 keyring.  @kbd{M-x epa-list-keys} is corresponding to @samp{gpg
116 --list-keys} from the command line.
117
118 @deffn Command epa-list-keys name mode
119 Show all keys matched with @var{name} from the public keyring.
120 @end deffn
121
122 @noindent
123 The output looks as follows.
124
125 @example
126   u A5B6B2D4B15813FE Daiki Ueno <ueno@@unixuser.org>
127 @end example
128
129 @noindent
130 A character on the leftmost column indicates the trust level of the
131 key.  If it is @samp{u}, the key is marked as ultimately trusted.  The
132 second column is the key ID, and the rest is the user ID.
133
134 You can move over entries by @key{TAB}.  If you type @key{RET} or
135 click button1 on an entry, you will see more detailed information
136 about the key you selected.
137
138 @example
139  u Daiki Ueno <ueno@@unixuser.org>
140  u A5B6B2D4B15813FE 1024bits DSA
141         Created: 2001-10-09
142         Expires: 2007-09-04
143         Capabilities: sign certify
144         Fingerprint: 8003 7CD0 0F1A 9400 03CA  50AA A5B6 B2D4 B158 13FE
145  u 4447461B2A9BEA2D 2048bits ELGAMAL_E
146         Created: 2001-10-09
147         Expires: 2007-09-04
148         Capabilities: encrypt
149         Fingerprint: 9003 D76B 73B7 4A8A E588  10AF 4447 461B 2A9B EA2D
150 @end example
151
152 @noindent
153 To browse your private keyring, use @kbd{M-x epa-list-secret-keys}.
154
155 @deffn Command epa-list-secret-keys name
156 Show all keys matched with @var{name} from the private keyring.
157 @end deffn
158
159 @noindent
160 In @samp{*Keys*} buffer, several commands are available.  The common
161 use case is to export some keys to a file.  To do that, type @kbd{m}
162 to select keys, type @kbd{o}, and then supply the filename.
163
164 Below are other commands related to key management.  Some of them take
165 a file as input/output, and others take the current region.
166
167 @deffn Command epa-insert-keys keys
168 Insert selected @var{keys} after the point.  It will let you select
169 keys before insertion.  By default, it will encode keys in the OpenPGP
170 armor format.
171 @end deffn
172
173 @deffn Command epa-import-keys file
174 Import keys from @var{file} to your keyring.
175 @end deffn
176
177 @deffn Command epa-import-keys-region start end
178 Import keys from the current region between @var{start} and @var{end}
179 to your keyring.
180 @end deffn
181
182 @deffn Command epa-import-armor-in-region start end
183 Import keys in the OpenPGP armor format in the current region between
184 @var{start} and @var{end}.  The difference from
185 @code{epa-import-keys-region} is that
186 @code{epa-import-armor-in-region} searches armors in the region and
187 applies @code{epa-import-keys-region} to each of them.
188 @end deffn
189
190 @deffn Command epa-delete-keys allow-secret
191 Delete selected keys.  If @var{allow-secret} is non-@code{nil}, it
192 also delete the secret keys.
193 @end deffn
194
195 @node Cryptographic operations on regions
196 @section Cryptographic operations on regions
197
198 @deffn Command epa-decrypt-region start end
199 Decrypt the current region between @var{start} and @var{end}.  It
200 replaces the region with the decrypted text.
201 @end deffn
202
203 @deffn Command epa-decrypt-armor-in-region start end
204 Decrypt OpenPGP armors in the current region between @var{start} and
205 @var{end}.  The difference from @code{epa-decrypt-region} is that
206 @code{epa-decrypt-armor-in-region} searches armors in the region
207 and applies @code{epa-decrypt-region} to each of them.  That is, this
208 command does not alter the original text around armors.
209 @end deffn
210
211 @deffn Command epa-verify-region start end
212 Verify the current region between @var{start} and @var{end}.  It sends
213 the verification result to the minibuffer or a popup window.  It
214 replaces the region with the signed text.
215 @end deffn
216
217 @deffn Command epa-verify-cleartext-in-region
218 Verify OpenPGP cleartext blocks in the current region between
219 @var{start} and @var{end}.  The difference from
220 @code{epa-verify-region} is that @code{epa-verify-cleartext-in-region}
221 searches OpenPGP cleartext blocks in the region and applies
222 @code{epa-verify-region} to each of them.  That is, this command does
223 not alter the original text around OpenPGP cleartext blocks.
224 @end deffn
225
226 @deffn Command epa-sign-region start end signers type
227 Sign the current region between @var{start} and @var{end}.  By
228 default, it creates a cleartext signature.  If a prefix argument is
229 given, it will let you select signing keys, and then a signature
230 type.
231 @end deffn
232
233 @deffn Command epa-encrypt-region start end recipients sign signers
234 Encrypt the current region between @var{start} and @var{end}.  It will
235 let you select recipients.  If a prefix argument is given, it will
236 also ask you whether or not to sign the text before encryption and if
237 you answered yes, it will let you select the signing keys.
238 @end deffn
239
240 @node Cryptographic operations on files
241 @section Cryptographic operations on files
242
243 @deffn Command epa-decrypt-file file &optional output
244 Decrypt @var{file}.  If you do not specify the name @var{output} to
245 use for the decrypted file, this function prompts for the value to use.
246 @end deffn
247
248 @deffn Command epa-verify-file file
249 Verify @var{file}.
250 @end deffn
251
252 @deffn Command epa-sign-file file signers type
253 Sign @var{file}.  If a prefix argument is given, it will let you
254 select signing keys, and then a signature type.
255 @end deffn
256
257 @deffn Command epa-encrypt-file file recipients
258 Encrypt @var{file}.  It will let you select recipients.
259 @end deffn
260
261 @node Dired integration
262 @section Dired integration
263
264 EasyPG Assistant extends Dired Mode for GNU Emacs to allow users to
265 easily do cryptographic operations on files.  For example,
266
267 @example
268 M-x dired
269 (mark some files)
270 : e (or M-x epa-dired-do-encrypt)
271 (select recipients by 'm' and click [OK])
272 @end example
273
274 @noindent
275 The following keys are assigned.
276
277 @table @kbd
278 @item : d
279 @kindex @kbd{: d}
280 @findex epa-dired-do-decrypt
281 Decrypt marked files.
282
283 @item : v
284 @kindex @kbd{: v}
285 @findex epa-dired-do-verify
286 Verify marked files.
287
288 @item : s
289 @kindex @kbd{: s}
290 @findex epa-dired-do-sign
291 Sign marked files.
292
293 @item : e
294 @kindex @kbd{: e}
295 @findex epa-dired-do-encrypt
296 Encrypt marked files.
297
298 @end table
299
300 @node Mail-mode integration
301 @section Mail-mode integration
302
303 EasyPG Assistant provides a minor mode @code{epa-mail-mode} to help
304 user compose inline OpenPGP messages.  Inline OpenPGP is a traditional
305 style of sending signed/encrypted emails by embedding raw OpenPGP
306 blobs inside a message body, not using modern MIME format.
307
308 NOTE: Inline OpenPGP is not recommended and you should consider to use
309 PGP/MIME@.  See
310 @uref{http://josefsson.org/inline-openpgp-considered-harmful.html,
311 Inline OpenPGP in E-mail is bad@comma{} Mm'kay?}.
312
313 @noindent
314 Once @code{epa-mail-mode} is enabled, the following keys are assigned.
315 You can do it by @kbd{C-u 1 M-x epa-mail-mode} or through the Customize
316 interface.  Try @kbd{M-x customize-variable epa-global-mail-mode}.
317
318 @table @kbd
319 @item C-c C-e C-d and C-c C-e d
320 @kindex @kbd{C-c C-e C-d}
321 @kindex @kbd{C-c C-e d}
322 @findex epa-mail-decrypt
323 Decrypt OpenPGP armors in the current buffer.
324
325 @item C-c C-e C-v and C-c C-e v
326 @kindex @kbd{C-c C-e C-v}
327 @kindex @kbd{C-c C-e v}
328 @findex epa-mail-verify
329 Verify OpenPGP cleartext signed messages in the current buffer.
330
331 @item C-c C-e C-s and C-c C-e s
332 @kindex @kbd{C-c C-e C-s}
333 @kindex @kbd{C-c C-e s}
334 @findex epa-mail-sign
335 Compose a signed message from the current buffer.
336
337 @item C-c C-e C-e and C-c C-e e
338 @kindex @kbd{C-c C-e C-e}
339 @kindex @kbd{C-c C-e e}
340 @findex epa-mail-encrypt
341 Compose an encrypted message from the current buffer.
342 By default it tries to build the recipient list from @samp{to},
343 @samp{cc}, and @samp{bcc} fields of the mail header.  To include your
344 key in the recipient list, use @samp{encrypt-to} option in
345 @file{~/.gnupg/gpg.conf}.
346
347 @end table
348
349 @node Encrypting/decrypting gpg files
350 @section Encrypting/decrypting gpg files
351 By default, every file whose name ends with @samp{.gpg} will be
352 treated as encrypted.  That is, when you open such a file, the
353 decrypted text is inserted in the buffer rather than encrypted one.
354 Similarly, when you save the buffer to a @samp{foo.gpg} file,
355 encrypted data is written.
356
357 The file name pattern for encrypted files can be controlled by
358 @var{epa-file-name-regexp}.
359
360 @defvar epa-file-name-regexp
361 Regexp which matches filenames treated as encrypted.
362 @end defvar
363
364 You can disable this behavior with @kbd{M-x epa-file-disable}, and
365 then get it back with @kbd{M-x epa-file-enable}.
366
367 @deffn Command epa-file-disable
368 Disable automatic encryption/decryption of *.gpg files.
369 @end deffn
370
371 @deffn Command epa-file-enable
372 Enable automatic encryption/decryption of *.gpg files.
373 @end deffn
374
375 @noindent
376 By default, @code{epa-file} will try to use symmetric encryption, aka
377 password-based encryption.  If you want to use public key encryption
378 instead, do @kbd{M-x epa-file-select-keys}, which will pops up the key
379 selection dialog.
380
381 @deffn Command epa-file-select-keys
382 Select recipient keys to encrypt the currently visiting file with
383 public key encryption.
384 @end deffn
385
386 You can also change the default behavior with the variable
387 @var{epa-file-select-keys}.
388
389 @defvar epa-file-select-keys
390 Control whether or not to pop up the key selection dialog.
391 @end defvar
392
393 For frequently visited files, it might be a good idea to tell Emacs
394 which encryption method should be used through @xref{File Variables, ,
395 , emacs, the Emacs Manual}.  Use the @code{epa-file-encrypt-to} local
396 variable for this.
397 @vindex epa-file-encrypt-to
398
399 For example, if you want an Elisp file to be encrypted with a
400 public key associated with an email address @samp{ueno@@unixuser.org},
401 add the following line to the beginning of the file.
402
403 @cartouche
404 @lisp
405 ;; -*- epa-file-encrypt-to: ("ueno@@unixuser.org") -*-
406 @end lisp
407 @end cartouche
408
409 Instead, if you want the file always (regardless of the value of the
410 @code{epa-file-select-keys} variable) encrypted with symmetric
411 encryption, change the line as follows.
412
413 @cartouche
414 @lisp
415 ;; -*- epa-file-encrypt-to: nil -*-
416 @end lisp
417 @end cartouche
418
419 Other variables which control the automatic encryption/decryption
420 behavior are below.
421
422 @defvar epa-file-cache-passphrase-for-symmetric-encryption
423 If non-@code{nil}, cache passphrase for symmetric encryption.  The
424 default value is @code{nil}.
425 @end defvar
426
427 @defvar epa-file-inhibit-auto-save
428 If non-@code{nil}, disable auto-saving when opening an encrypted file.
429 The default value is @code{t}.
430 @end defvar
431
432 @node Caching Passphrases
433 @chapter Caching Passphrases
434
435 Typing passphrases is an irritating task if you frequently open and
436 close the same file.  GnuPG and EasyPG Assistant provide mechanisms to
437 remember your passphrases.  However, the configuration is a bit
438 confusing since it depends on your GnuPG installation (GnuPG version 1 or
439 GnuPG version 2), encryption method (symmetric or public key), and whether or
440 not you want to use gpg-agent.  Here are some questions:
441
442 @enumerate
443 @item Do you use GnuPG version 2 instead of GnuPG version 1?
444 @item Do you use symmetric encryption rather than public key encryption?
445 @item Do you want to use gpg-agent?
446 @end enumerate
447
448 Here are configurations depending on your answers:
449
450 @multitable {111} {222} {333} {configuration configuration configuration}
451 @item @b{1} @tab @b{2} @tab @b{3} @tab Configuration
452 @item Yes @tab Yes @tab Yes @tab Set up gpg-agent.
453 @item Yes @tab Yes @tab No @tab You can't, without gpg-agent.
454 @item Yes @tab No @tab Yes @tab Set up gpg-agent.
455 @item Yes @tab No @tab No @tab You can't, without gpg-agent.
456 @item No @tab Yes @tab Yes @tab Set up elisp passphrase cache.
457 @item No @tab Yes @tab No @tab Set up elisp passphrase cache.
458 @item No @tab No @tab Yes @tab Set up gpg-agent.
459 @item No @tab No @tab No @tab You can't, without gpg-agent.
460 @end multitable
461
462 To set up gpg-agent, follow the instruction in GnuPG manual.
463 @pxref{Invoking GPG-AGENT, , Invoking GPG-AGENT, gnupg}.
464
465 To set up elisp passphrase cache, set
466 @code{epa-file-cache-passphrase-for-symmetric-encryption}.
467 @xref{Encrypting/decrypting gpg files}.
468
469 @node Bug Reports
470 @chapter Bug Reports
471
472 Bugs and problems with EasyPG Assistant are actively worked on by the
473 Emacs development team.  Feature requests and suggestions are also
474 more than welcome.  Use @kbd{M-x report-emacs-bug}, @pxref{Bugs, ,
475 Bugs, emacs, Reporting Bugs}.
476
477 When submitting a bug report, please try to describe in excruciating
478 detail the steps required to reproduce the problem.  Also try to
479 collect necessary information to fix the bug, such as:
480
481 @itemize @bullet
482 @item the GnuPG version.  Send the output of @samp{gpg --version}.
483 @item the GnuPG configuration.  Send the contents of @file{~/.gnupg/gpg.conf}.
484 @end itemize
485
486 Before reporting the bug, you should set @code{epg-debug} in the
487 @file{~/.emacs} file and repeat the bug.  Then, include the contents
488 of the @samp{ *epg-debug*} buffer.  Note that the first letter of the
489 buffer name is a whitespace.
490
491 @node GNU Free Documentation License
492 @appendix GNU Free Documentation License
493 @include doclicense.texi
494
495 @bye
496
497 @c End: