~ubuntu-branches/ubuntu/oneiric/gnupg2/oneiric-updates

« back to all changes in this revision

Viewing changes to doc/HACKING

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-10-04 10:25:53 UTC
  • mfrom: (5.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20081004102553-fv62pp8dsitxli47
Tags: 2.0.9-3.1
* Non-maintainer upload.
* agent/gpg-agent.c: Deinit the threading library before exec'ing
  the command to run in --daemon mode. And because that still doesn't
  restore the sigprocmask, do that manually. Closes: #499569

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
                   ===> Under construction <=======
7
7
 
8
8
 
9
 
CVS Access
10
 
==========
11
 
Anonymous read-only CVS access is available:
12
 
 
13
 
  cvs -z3 -d :pserver:anoncvs@cvs.gnupg.org:/cvs/gnupg login
14
 
 
15
 
use the password "anoncvs".  To check out the the complete
16
 
archive use:
17
 
 
18
 
  cvs -z3 -d :pserver:anoncvs@cvs.gnupg.org:/cvs/gnupg \
19
 
        checkout -R STABLE-BRANCH-1-0 gnupg
20
 
 
21
 
This service is provided to help you in hunting bugs and not to deliver
22
 
stable snapshots; it may happen that it even does not compile, so please
23
 
don't complain. CVS may put a high load on a server, so please don't poll
24
 
poll for new updates but wait for an announcement; to receive this you may
25
 
want to subscribe to:
26
 
 
27
 
    gnupg-commit-watchers@gnupg.org
28
 
 
29
 
by sending a mail with subject "subscribe" to
30
 
 
31
 
    gnupg-commit-watchers-request@gnupg.org
32
 
 
33
 
 
34
 
You must run scripts/autogen.sh before doing the ./configure,
35
 
as this creates some needed while which are not in the CVS.
36
 
autogen.sh should checks that you have all required tools
37
 
installed.
38
 
 
39
 
 
40
 
RSYNC access
41
 
============
42
 
The FTP archive is also available by anonymous rsync.  A daily snapshot
43
 
of the CVS head revision is also available.  See rsync(1) and try
44
 
"rsync ftp.gnupg.org::" to see available resources.
45
 
 
46
 
 
47
 
 
48
 
Special Tools
49
 
=============
50
 
Documentation is based on the docbook DTD.  Actually we have only the
51
 
man page for now.  To build a man page you need the docbook-to-man
52
 
tool and all the other thinks needed for SGML processing.  Debian
53
 
comes with the docbook tools and you only need this docbook-to-man
54
 
script which is comes with gtk-doc or download it from
55
 
ftp.openit.de:/pub/devel/sgml.  If you don't have it everything
56
 
should still work fine but you will have only a dummy man page.
57
 
 
58
 
 
59
9
RFCs
60
10
====
61
11
 
78
28
 
79
29
 
80
30
 
81
 
Debug Flags
82
 
-----------
83
 
Use the option "--debug n" to output debug information. This option
84
 
can be used multiple times, all values are ORed; n maybe prefixed with
85
 
0x to use hex-values.
86
 
 
87
 
     value  used for
88
 
     -----  ----------------------------------------------
89
 
      1     packet reading/writing
90
 
      2     MPI details
91
 
      4     ciphers and primes (may reveal sensitive data)
92
 
      8     iobuf filter functions
93
 
      16    iobuf stuff
94
 
      32    memory allocation stuff
95
 
      64    caching
96
 
      128   show memory statistics at exit
97
 
      256   trust verification stuff
98
 
 
99
 
 
100
 
 
101
 
 
102
31
Directory Layout
103
32
----------------
104
 
  ./            Readme, configure
105
 
  ./scripts     Scripts needed by configure and others
106
 
  ./doc         Documentation
107
 
  ./util        General purpose utility function
108
 
  ./mpi         Multi precision integer library
109
 
  ./cipher      Cryptographic functions
110
 
  ./g10         GnuPG application
111
 
  ./tools       Some helper and demo programs
112
 
  ./keybox      The keybox library (under construction)
113
 
  ./gcrypt      Stuff needed to build libgcrypt (under construction)
 
33
  ./           Readme, configure
 
34
  ./agent      Gpg-agent and related tools
 
35
  ./doc        Documentation
 
36
  ./doc        Documentation
 
37
  ./g10        Gpg program here called gpg2
 
38
  ./jnlib      Utility functions
 
39
  ./kbx        Keybox library
 
40
  ./scd        Smartcard daemon
 
41
  ./scripts    Scripts needed by configure and others
 
42
  ./sm         Gpgsm program
114
43
 
115
44
 
116
45
Detailed Roadmap
117
46
----------------
118
 
g10/g10.c       Main module with option parsing and all the stuff you have
 
47
g10/gpg.c       Main module with option parsing and all the stuff you have
119
48
                to do on startup.  Also has the exout handler and some
120
49
                helper functions.
121
50
g10/sign.c      Create signature and optionally encrypt
188
117
-----------------
189
118
Use only the functions:
190
119
 
191
 
    m_alloc()
192
 
    m_alloc_clear()
193
 
    m_strdup()
194
 
    m_free()
195
 
 
196
 
If you want to store a passphrase or some other sensitive data you may
197
 
want to use m_alloc_secure() instead of m_alloc(), as this puts the data
198
 
into a memory region which is protected from swapping (on some platforms).
199
 
m_free() works for both.  This functions will not return if there is not
200
 
enough memory available.
201
 
 
 
120
    xmalloc
 
121
    xmalloc_secure
 
122
    xtrymalloc
 
123
    xtrymalloc_secure
 
124
    xcalloc
 
125
    xcalloc_secure
 
126
    xtrycalloc
 
127
    xtrycalloc_secure
 
128
    xrealloc
 
129
    xtryrealloc
 
130
    xstrdup
 
131
    xtrystrdup
 
132
    xfree
 
133
 
 
134
 
 
135
The *secure versions allocated memory in the secure memory. That is,
 
136
swapping out of this memory is avoided and is gets overwritten on
 
137
free.  Use this for passphrases, session keys and other sensitive
 
138
material.  This memory set aside for secure memory is linited to a few
 
139
k.  In general the function don't print a memeory message and
 
140
terminate the process if there is not enough memory available.  The
 
141
"try" versions of the functions return NULL instead.
202
142
 
203
143
 
204
144
Logging
234
174
easier to understand.
235
175
 
236
176
 
237
 
How to use the message digest functions
238
 
---------------------------------------
239
 
cipher/md.c implements an interface to hash (message digest functions).
240
 
 
241
 
a) If you have a common part of data and some variable parts
242
 
   and you need to hash of the concatenated parts, you can use this:
243
 
        md = md_open(...)
244
 
        md_write( md,  common_part )
245
 
        md1 = md_copy( md )
246
 
        md_write(md1, part1)
247
 
        md_final(md1);
248
 
        digest1 = md_read(md1)
249
 
        md2 = md_copy( md )
250
 
        md_write(md2, part2)
251
 
        md_final(md2);
252
 
        digest2 = md_read(md2)
253
 
 
254
 
   An example are key signatures; the key packet is the common part
255
 
   and the user-id packets are the variable parts.
256
 
 
257
 
b) If you need a running digest you should use this:
258
 
        md = md_open(...)
259
 
        md_write( md, part1 )
260
 
        digest_of_part1 = md_digest( md );
261
 
        md_write( md, part2 )
262
 
        digest_of_part1_cat_part2 = md_digest( md );
263
 
        ....
264
 
 
265
 
Both methods may be combined. [Please see the source for the real syntax]
266
 
 
267
 
 
268
 
 
269
 
 
270
 
How to use the cipher functions
271
 
-------------------------------
272
 
cipher/cipher.c implements the interface to symmetric encryption functions.
273
 
As usual you have a function to open a cipher (which returns a handle to be used
274
 
with all other functions), some functions to set the key and other stuff and
275
 
a encrypt and decrypt function which does the real work.  You probably know
276
 
how to work with files - so it should really be easy to work with these
277
 
functions.  Here is an example:
278
 
 
279
 
    CIPHER_HANDLE hd;
280
 
 
281
 
    hd = cipher_open( CIPHER_ALGO_TWOFISH, CIPHER_MODE_CFB, 0 );
282
 
    if( !hd )
283
 
        oops( use other function to check for the real error );
284
 
    rc = cipher_setkey( hd, key256bit, 32 ) )
285
 
    if( rc )
286
 
        oops( weak key or something like this );
287
 
    cipher_setiv( hd, some_IV_or_NULL_for_all_zeroes );
288
 
    cipher_encrypt( hd, plain, cipher, size );
289
 
    cipher_close( hd );
290
 
 
291
 
 
292
 
 
293
 
How to use the public key functions
294
 
-----------------------------------
295
 
cipher/pubkey.c implements the interface to asymmetric encryption and
296
 
signature functions. This is basically the same as with the symmetric
297
 
counterparts, but due to their nature it is a little bit more complicated.
298
 
 
299
 
   [Give an example]
300
 
 
301