xref: /minix3/crypto/external/bsd/netpgp/dist/src/lib/libnetpgp.3 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\" $NetBSD: libnetpgp.3,v 1.16 2014/02/17 07:23:18 agc Exp $
2ebfedea0SLionel Sambuc.\"
3ebfedea0SLionel Sambuc.\" Copyright (c) 2009,2010 The NetBSD Foundation, Inc.
4ebfedea0SLionel Sambuc.\" All rights reserved.
5ebfedea0SLionel Sambuc.\"
6ebfedea0SLionel Sambuc.\" This manual page is derived from software contributed to The
7ebfedea0SLionel Sambuc.\" NetBSD Foundation by Alistair Crooks (agc@NetBSD.org)
8ebfedea0SLionel Sambuc.\"
9ebfedea0SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
10ebfedea0SLionel Sambuc.\" modification, are permitted provided that the following conditions
11ebfedea0SLionel Sambuc.\" are met:
12ebfedea0SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
13ebfedea0SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
14ebfedea0SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
15ebfedea0SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
16ebfedea0SLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
17ebfedea0SLionel Sambuc.\"
18ebfedea0SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19ebfedea0SLionel Sambuc.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20ebfedea0SLionel Sambuc.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21ebfedea0SLionel Sambuc.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22ebfedea0SLionel Sambuc.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23ebfedea0SLionel Sambuc.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24ebfedea0SLionel Sambuc.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25ebfedea0SLionel Sambuc.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26ebfedea0SLionel Sambuc.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27ebfedea0SLionel Sambuc.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28ebfedea0SLionel Sambuc.\" POSSIBILITY OF SUCH DAMAGE.
29ebfedea0SLionel Sambuc.\"
30*0a6a1f1dSLionel Sambuc.Dd February 16, 2014
31ebfedea0SLionel Sambuc.Dt LIBNETPGP 3
32ebfedea0SLionel Sambuc.Os
33ebfedea0SLionel Sambuc.Sh NAME
34ebfedea0SLionel Sambuc.Nm libnetpgp
35ebfedea0SLionel Sambuc.Nd digital signing and verification, encryption and decryption
36ebfedea0SLionel Sambuc.Sh LIBRARY
37ebfedea0SLionel Sambuc.Lb libnetpgp
38ebfedea0SLionel Sambuc.Sh SYNOPSIS
39ebfedea0SLionel Sambuc.In netpgp.h
40ebfedea0SLionel Sambuc.Pp
41ebfedea0SLionel SambucThe following functions relate to initialisations and finalisations:
42ebfedea0SLionel Sambuc.Ft int
43ebfedea0SLionel Sambuc.Fo netpgp_init
44ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp"
45ebfedea0SLionel Sambuc.Fc
46ebfedea0SLionel Sambuc.Ft int
47ebfedea0SLionel Sambuc.Fo netpgp_end
48ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp"
49ebfedea0SLionel Sambuc.Fc
50ebfedea0SLionel Sambuc.Pp
51ebfedea0SLionel SambucThe following functions are for debugging, reflection and information:
52ebfedea0SLionel Sambuc.Ft int
53ebfedea0SLionel Sambuc.Fo netpgp_set_debug
54ebfedea0SLionel Sambuc.Fa "const char *filename"
55ebfedea0SLionel Sambuc.Fc
56ebfedea0SLionel Sambuc.Ft int
57ebfedea0SLionel Sambuc.Fo netpgp_get_debug
58ebfedea0SLionel Sambuc.Fa "const char *filename"
59ebfedea0SLionel Sambuc.Fc
60ebfedea0SLionel Sambuc.Ft int
61ebfedea0SLionel Sambuc.Fo netpgp_get_info
62ebfedea0SLionel Sambuc.Fa "const char *type"
63ebfedea0SLionel Sambuc.Fc
64ebfedea0SLionel Sambuc.Ft int
65ebfedea0SLionel Sambuc.Fo netpgp_list_packets
66ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *filename" "int armour" "char *pubringname"
67ebfedea0SLionel Sambuc.Fc
68ebfedea0SLionel Sambuc.Pp
69ebfedea0SLionel SambucThe following functions are for variable management:
70ebfedea0SLionel Sambuc.Ft int
71ebfedea0SLionel Sambuc.Fo netpgp_setvar
72ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const char *name" "const char *value"
73ebfedea0SLionel Sambuc.Fc
74ebfedea0SLionel Sambuc.Ft char *
75ebfedea0SLionel Sambuc.Fo netpgp_getvar
76ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const char *name"
77ebfedea0SLionel Sambuc.Fc
78ebfedea0SLionel Sambuc.Ft int
79ebfedea0SLionel Sambuc.Fo netpgp_incvar
80ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const char *name" "const int delta"
81ebfedea0SLionel Sambuc.Fc
82ebfedea0SLionel Sambuc.Pp
83ebfedea0SLionel SambucThe following function sets the home directory:
84ebfedea0SLionel Sambuc.Ft int
85ebfedea0SLionel Sambuc.Fo netpgp_set_homedir
86ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *homedir" "char *subdir" "const int quiet"
87ebfedea0SLionel Sambuc.Fc
88ebfedea0SLionel Sambuc.Pp
89ebfedea0SLionel SambucThe following functions are used for key management:
90ebfedea0SLionel Sambuc.Ft int
91ebfedea0SLionel Sambuc.Fo netpgp_list_keys
92ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const int printsigs"
93ebfedea0SLionel Sambuc.Fc
94ebfedea0SLionel Sambuc.Ft int
95ebfedea0SLionel Sambuc.Fo netpgp_match_list_keys
96ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *pattern"
97ebfedea0SLionel Sambuc.Fc
98ebfedea0SLionel Sambuc.Ft int
99ebfedea0SLionel Sambuc.Fo netpgp_find_key
100ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *userid"
101ebfedea0SLionel Sambuc.Fc
102ebfedea0SLionel Sambuc.Ft char *
103ebfedea0SLionel Sambuc.Fo netpgp_get_key
104ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const char *id"
105ebfedea0SLionel Sambuc.Fc
106ebfedea0SLionel Sambuc.Ft int
107ebfedea0SLionel Sambuc.Fo netpgp_export_key
108ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *userid"
109ebfedea0SLionel Sambuc.Fc
110ebfedea0SLionel Sambuc.Ft int
111ebfedea0SLionel Sambuc.Fo netpgp_import_key
112ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *file"
113ebfedea0SLionel Sambuc.Fc
114ebfedea0SLionel Sambuc.Ft int
115ebfedea0SLionel Sambuc.Fo netpgp_generate_key
116ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *userid" "int numbits"
117ebfedea0SLionel Sambuc.Fc
118ebfedea0SLionel Sambuc.Pp
119ebfedea0SLionel SambucThe following functions are used for file management:
120ebfedea0SLionel Sambuc.Ft int
121ebfedea0SLionel Sambuc.Fo netpgp_encrypt_file
122ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *userid" "char *filename" "char *out"
123ebfedea0SLionel Sambuc.Fa "int armored"
124ebfedea0SLionel Sambuc.Fc
125ebfedea0SLionel Sambuc.Ft int
126ebfedea0SLionel Sambuc.Fo netpgp_decrypt_file
127ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *filename" "char *out" "int armored"
128ebfedea0SLionel Sambuc.Fc
129ebfedea0SLionel Sambuc.Ft int
130ebfedea0SLionel Sambuc.Fo netpgp_sign_file
131ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *userid" "char *filename" "char *out"
132ebfedea0SLionel Sambuc.Fa "int armored" "int cleartext" "int detached"
133ebfedea0SLionel Sambuc.Fc
134ebfedea0SLionel Sambuc.Ft int
135ebfedea0SLionel Sambuc.Fo netpgp_verify_file
136ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *f" "int armored"
137ebfedea0SLionel Sambuc.Fc
138ebfedea0SLionel Sambuc.Pp
139ebfedea0SLionel SambucThe following functions are used for memory signing and encryption:
140ebfedea0SLionel Sambuc.Ft int
141ebfedea0SLionel Sambuc.Fo netpgp_encrypt_memory
142ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "char *userid" "void *in" "const size_t insize"
143ebfedea0SLionel Sambuc.Fa "char *out" "size_t outsize" "int armored"
144ebfedea0SLionel Sambuc.Fc
145ebfedea0SLionel Sambuc.Ft int
146ebfedea0SLionel Sambuc.Fo netpgp_decrypt_memory
147ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const void *input" "const size_t insize"
148ebfedea0SLionel Sambuc.Fa "char *out" "size_t outsize" "const int armored"
149ebfedea0SLionel Sambuc.Fc
150ebfedea0SLionel Sambuc.Ft int
151ebfedea0SLionel Sambuc.Fo netpgp_sign_memory
152ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const char *userid" "char *mem"
153ebfedea0SLionel Sambuc.Fa "size_t size" "char *out" "size_t outsize"
154ebfedea0SLionel Sambuc.Fa "const unsigned armored" "const unsigned cleartext"
155ebfedea0SLionel Sambuc.Fc
156ebfedea0SLionel Sambuc.Ft int
157ebfedea0SLionel Sambuc.Fo netpgp_verify_memory
158ebfedea0SLionel Sambuc.Fa "netpgp_t *netpgp" "const void *in" "const size_t insize"
159ebfedea0SLionel Sambuc.Fa "void *out" "size_t outsize" "const int armored"
160ebfedea0SLionel Sambuc.Fc
161ebfedea0SLionel Sambuc.Sh DESCRIPTION
162ebfedea0SLionel Sambuc.Nm
163ebfedea0SLionel Sambucis a library interface to enable digital signatures to be created and
164ebfedea0SLionel Sambucverified, and also for files and memory to be encrypted and decrypted.
165ebfedea0SLionel SambucFunctions are also provided for management of user keys.
166ebfedea0SLionel Sambuc.Pp
167ebfedea0SLionel SambucThe library uses functions from the openssl library for multi-precision
168ebfedea0SLionel Sambucinteger arithmetic, and for RSA and DSA key signing and verification,
169ebfedea0SLionel Sambucencryption and decryption.
170ebfedea0SLionel Sambuc.Pp
171ebfedea0SLionel SambucNormal operation sees the
172ebfedea0SLionel Sambuc.Nm
173ebfedea0SLionel Sambucprocess be initialised using the
174ebfedea0SLionel Sambuc.Fn netpgp_init
175ebfedea0SLionel Sambucfunction, which will set up the public and private keyrings, and set the
176ebfedea0SLionel Sambucuser identity to the
177ebfedea0SLionel Sambuc.Ar userid
178ebfedea0SLionel Sambucargument passed stored in the
179ebfedea0SLionel Sambuc.Dv netpgp_t
180ebfedea0SLionel Sambucstructure, and set using the
181ebfedea0SLionel Sambuc.Fn netpgp_setvar
182ebfedea0SLionel Sambucfunction.
183ebfedea0SLionel SambucIf no public key ring file is set, initial values will be taken from those
184ebfedea0SLionel Sambucin the
185ebfedea0SLionel Sambuc.Pa .gnupg/pubring.gpg
186ebfedea0SLionel Sambucfile in the user's home directory.
187*0a6a1f1dSLionel SambucSimilarly, if no secret key ring file is set,
188ebfedea0SLionel Sambucinitial values will be taken from those
189ebfedea0SLionel Sambucin the
190ebfedea0SLionel Sambuc.Pa .gnupg/secring.gpg
191ebfedea0SLionel Sambucfile in the user's home directory.
192ebfedea0SLionel SambucThe
193ebfedea0SLionel Sambuc.Fn netpgp_init
194*0a6a1f1dSLionel Sambucfunction returns 1 on success, 0 on failure.
195ebfedea0SLionel Sambuc.Pp
196ebfedea0SLionel SambucTo list all the keys in a keyring, the
197ebfedea0SLionel Sambuc.Fn netpgp_list_keys
198ebfedea0SLionel Sambucfunction is used.
199ebfedea0SLionel SambucThe signature subkey fields can also be displayed
200ebfedea0SLionel Sambucusing this function.
201ebfedea0SLionel SambucThe
202ebfedea0SLionel Sambuc.Fn netpgp_match_list_keys
203ebfedea0SLionel Sambucfunction is used to match (via regular expression)
204ebfedea0SLionel Sambuca subset of the keys in the keyring.
205ebfedea0SLionel SambucIf the expression to match is NULL,
206ebfedea0SLionel Sambucthe search will degenerate into a
207ebfedea0SLionel Sambuclisting of all keys in the keyring.
208ebfedea0SLionel Sambuc.Pp
209ebfedea0SLionel SambucThe home directory is specified as an internal variable,
210ebfedea0SLionel Sambucand its existence is checked using the
211ebfedea0SLionel Sambuc.Fn netpgp_set_homedir
212ebfedea0SLionel Sambucfunction.
213ebfedea0SLionel SambucThis function can operate in a verbose or quiet
214ebfedea0SLionel Sambucmanner, depending on the value of the argument provided.
215ebfedea0SLionel SambucIf the subdirectory argument is provided, this subdirectory
216ebfedea0SLionel Sambucis appended to the home directory in order to search for
217ebfedea0SLionel Sambucthe keyrings.
218ebfedea0SLionel Sambuc.Pp
219ebfedea0SLionel SambucTo export a key, the
220ebfedea0SLionel Sambuc.Fn netpgp_export_key
221*0a6a1f1dSLionel Sambucfunction is used.
222ebfedea0SLionel SambucOutput is sent to the standard output.
223ebfedea0SLionel Sambuc.Pp
224ebfedea0SLionel SambucTo import a key onto the public keyring, the
225ebfedea0SLionel Sambuc.Fn netpgp_import_key
226ebfedea0SLionel Sambucis used.
227ebfedea0SLionel SambucThe name of the file containing the key to be imported is provided
228ebfedea0SLionel Sambucas the filename argument.
229ebfedea0SLionel Sambuc.Pp
230ebfedea0SLionel SambucTo generate a key, the
231ebfedea0SLionel Sambuc.Fn netpgp_generate_key
232ebfedea0SLionel Sambucis used.
233ebfedea0SLionel SambucIt takes an argument of the number of bits to use in the key.
234ebfedea0SLionel SambucAt the time that this manual page was created (April 2009),
235ebfedea0SLionel Sambucthe recommendations are that the bare minimum key size
236ebfedea0SLionel Sambucof at least 2048 bits is used, and it would be much better
237ebfedea0SLionel Sambucto use at least 4096 or 8192 bits.
238ebfedea0SLionel SambucThis situation should be monitored to ensure that it does
239ebfedea0SLionel Sambucnot go out of date.
240ebfedea0SLionel Sambuc.Pp
241ebfedea0SLionel SambucEncryption, decryption, signing and verification of
242ebfedea0SLionel Sambucfiles are the lifeblood of the
243ebfedea0SLionel Sambuc.Nm
244ebfedea0SLionel Sambuclibrary.
245ebfedea0SLionel SambucTo encrypt a file, the
246ebfedea0SLionel Sambuc.Fn netpgp_encrypt_file
247*0a6a1f1dSLionel Sambucfunction is used, and the
248ebfedea0SLionel Sambuc.Fn netpgp_decrypt_file
249*0a6a1f1dSLionel Sambucfunction is used to decrypt the results of the encryption.
250ebfedea0SLionel SambucTo sign a file, the
251ebfedea0SLionel Sambuc.Fn netpgp_sign_file
252*0a6a1f1dSLionel Sambucfunction is used, and the resulting signed file can be verified
253ebfedea0SLionel Sambucusing the
254ebfedea0SLionel Sambuc.Fn netpgp_verify_file
255ebfedea0SLionel Sambucfunction.
256ebfedea0SLionel Sambuc.Pp
257ebfedea0SLionel Sambuc.Fn netpgp_sign_memory
258ebfedea0SLionel Sambucis a function which can sign an area
259ebfedea0SLionel Sambucof memory, and
260ebfedea0SLionel Sambuc.Fn netpgp_verify_memory
261ebfedea0SLionel Sambucverifies the digital signature produced.
262ebfedea0SLionel Sambuc.Pp
263ebfedea0SLionel SambucInternally, an encrypted or signed file
264ebfedea0SLionel Sambucis made up of
265ebfedea0SLionel Sambuc.Dq packets
266ebfedea0SLionel Sambucwhich hold information pertaining to the signature,
267ebfedea0SLionel Sambucencryption method, and the data which is being protected.
268ebfedea0SLionel SambucThis information can be displayed in a verbose manner using
269ebfedea0SLionel Sambucthe
270ebfedea0SLionel Sambuc.Fn netpgp_list_packets
271ebfedea0SLionel Sambucfunction.
272ebfedea0SLionel Sambuc.Pp
273ebfedea0SLionel SambucThe
274ebfedea0SLionel Sambuc.Fn netpgp_setvar
275ebfedea0SLionel Sambucand
276ebfedea0SLionel Sambuc.Fn netpgp_getvar
277ebfedea0SLionel Sambucfunctions are used to manage the hash algorithm that
278ebfedea0SLionel Sambucis used with RSA signatures.
279ebfedea0SLionel SambucThese functions are general purpose functions, and
280ebfedea0SLionel Sambucare used to set and retrieve values for internal variables.
281ebfedea0SLionel SambucFor example, they
282ebfedea0SLionel Sambuccan be used to set and to retrieve the
283ebfedea0SLionel Sambucvalue of the user id
284ebfedea0SLionel Sambucwhich has been set,
285ebfedea0SLionel Sambucthe home directory from which to find the keyrings,
286ebfedea0SLionel Sambucthe verbosity settings, and many more.
287ebfedea0SLionel SambucThe
288ebfedea0SLionel Sambuc.Fn netpgp_incvar
289ebfedea0SLionel Sambucfunction is used to add a numeric increment to the
290ebfedea0SLionel Sambucinternal variable.
291ebfedea0SLionel SambucThis incremental value can be negative.
292ebfedea0SLionel SambucIt is primarily used to increase the verbosity settings.
293ebfedea0SLionel Sambuc.Pp
294ebfedea0SLionel SambucIn
295ebfedea0SLionel Sambuc.Nm
296ebfedea0SLionel Sambucfiles are encrypted using the public key of the userid.
297ebfedea0SLionel SambucThe secret key is used to decrypt the results of that encryption.
298ebfedea0SLionel SambucFiles are signed using the secret key of the userid.
299ebfedea0SLionel SambucThe public key is used to verify that the file was signed,
300ebfedea0SLionel Sambucwho signed the file, and the date and time at which it was signed.
301ebfedea0SLionel Sambuc.Pp
302ebfedea0SLionel SambucSome utility functions are also provided for debugging, and for
303ebfedea0SLionel Sambucfinding out version and maintainer information from calling programs.
304ebfedea0SLionel SambucThese are the
305ebfedea0SLionel Sambuc.Fn netpgp_set_debug
306ebfedea0SLionel Sambucand the
307ebfedea0SLionel Sambuc.Fn netpgp_get_debug
308ebfedea0SLionel Sambucfunctions (for getting verbose debugging information on a per-source
309ebfedea0SLionel Sambucfile basis).
310ebfedea0SLionel Sambuc.Pp
311ebfedea0SLionel SambucThe
312ebfedea0SLionel Sambuc.Fn netpgp_get_info
313*0a6a1f1dSLionel Sambucfunction returns the version or maintainer information depending upon the
314ebfedea0SLionel Sambuc.Ar type
315ebfedea0SLionel Sambucargument.
316ebfedea0SLionel SambucAt the present time, two types are defined:
317ebfedea0SLionel Sambuc.Dq version
318ebfedea0SLionel Sambucand
319ebfedea0SLionel Sambuc.Dq maintainer .
320ebfedea0SLionel SambucA failure to present a known
321ebfedea0SLionel Sambuc.Ar type
322ebfedea0SLionel Sambucargument to
323ebfedea0SLionel Sambuc.Fn netpgp_get_info
324ebfedea0SLionel Sambucwill result in the string
325ebfedea0SLionel Sambuc.Dq [unknown]
326ebfedea0SLionel Sambucbeing returned.
327ebfedea0SLionel Sambuc.Sh SEE ALSO
328ebfedea0SLionel Sambuc.Xr netpgp 1 ,
329ebfedea0SLionel Sambuc.Xr ssl 3
330ebfedea0SLionel Sambuc.Sh HISTORY
331ebfedea0SLionel SambucThe
332ebfedea0SLionel Sambuc.Nm
333ebfedea0SLionel Sambuclibrary first appeared in
334ebfedea0SLionel Sambuc.Nx 6.0 .
335ebfedea0SLionel Sambuc.Sh AUTHORS
336*0a6a1f1dSLionel Sambuc.An -nosplit
337ebfedea0SLionel Sambuc.An Ben Laurie ,
338ebfedea0SLionel Sambuc.An Rachel Willmer .
339ebfedea0SLionel Sambuc.An Alistair Crooks Aq Mt agc@NetBSD.org
340ebfedea0SLionel Sambucwrote this high-level interface.
341ebfedea0SLionel Sambuc.Pp
342ebfedea0SLionel SambucThis manual page was written by
343ebfedea0SLionel Sambuc.An Alistair Crooks .
344