File: pgp-api.texi

package info (click to toggle)
gnutls13 1.4.4-3%2Betch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 24,052 kB
  • ctags: 12,507
  • sloc: ansic: 94,474; xml: 17,016; sh: 9,652; perl: 628; makefile: 607; sed: 16
file content (485 lines) | stat: -rw-r--r-- 18,717 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485




@subheading gnutls_certificate_set_openpgp_key_file
@anchor{gnutls_certificate_set_openpgp_key_file}
@deftypefun {int} {gnutls_certificate_set_openpgp_key_file} (gnutls_certificate_credentials_t       @var{res}, const char * @var{certfile}, const char * @var{keyfile})
@var{res}: the destination context to save the data.

@var{certfile}: the file that contains the public key.

@var{keyfile}: the file that contains the secret key.

This funtion is used to load OpenPGP keys into the GnuTLS credentials structure.
It doesn't matter whether the keys are armored or but, but the files
should only contain one key which should not be encrypted.
@end deftypefun
@subheading gnutls_certificate_set_openpgp_key_mem
@anchor{gnutls_certificate_set_openpgp_key_mem}
@deftypefun {int} {gnutls_certificate_set_openpgp_key_mem} (gnutls_certificate_credentials_t      @var{res}, const gnutls_datum_t * @var{cert}, const gnutls_datum_t * @var{key})
@var{res}: the destination context to save the data.

@var{cert}: the datum that contains the public key.

@var{key}: the datum that contains the secret key.

This funtion is used to load OpenPGP keys into the GnuTLS credential structure.
It doesn't matter whether the keys are armored or but, but the files
should only contain one key which should not be encrypted.
@end deftypefun

@subheading gnutls_certificate_set_openpgp_keyring_file
@anchor{gnutls_certificate_set_openpgp_keyring_file}
@deftypefun {int} {gnutls_certificate_set_openpgp_keyring_file} (gnutls_certificate_credentials_t @var{c}, const char * @var{file})
@var{c}: A certificate credentials structure

@var{file}: filename of the keyring.

The function is used to set keyrings that will be used internally
by various OpenPGP functions. For example to find a key when it
is needed for an operations. The keyring will also be used at the
verification functions.
@end deftypefun

@subheading gnutls_certificate_set_openpgp_keyring_mem
@anchor{gnutls_certificate_set_openpgp_keyring_mem}
@deftypefun {int} {gnutls_certificate_set_openpgp_keyring_mem} (gnutls_certificate_credentials_t          @var{c}, const opaque * @var{data}, size_t @var{dlen})
@var{c}: A certificate credentials structure

@var{data}: buffer with keyring data.

@var{dlen}: length of data buffer.

The function is used to set keyrings that will be used internally
by various OpenPGP functions. For example to find a key when it
is needed for an operations. The keyring will also be used at the
verification functions.
@end deftypefun

@subheading gnutls_certificate_set_openpgp_keyserver
@anchor{gnutls_certificate_set_openpgp_keyserver}
@deftypefun {int} {gnutls_certificate_set_openpgp_keyserver} (gnutls_certificate_credentials_t        @var{res}, const char * @var{keyserver}, int @var{port})
@var{res}: the destination context to save the data.

@var{keyserver}: is the key server address

@var{port}: is the key server port to connect to

This funtion will set a key server for use with openpgp keys. This
key server will only be used if the peer sends a key fingerprint instead
of a key in the handshake. Using a key server may delay the handshake
process.
@end deftypefun

@subheading gnutls_certificate_set_openpgp_key
@anchor{gnutls_certificate_set_openpgp_key}
@deftypefun {int} {gnutls_certificate_set_openpgp_key} (gnutls_certificate_credentials_t         @var{res}, gnutls_openpgp_key_t @var{key}, gnutls_openpgp_privkey_t @var{pkey})
@var{res}: is an @code{gnutls_certificate_credentials_t} structure.

@var{key}: contains an openpgp public key

@var{pkey}: is an openpgp private key

This function sets a certificate/private key pair in the 
gnutls_certificate_credentials_t structure. This function may be called
more than once (in case multiple keys/certificates exist for the
server).
@end deftypefun

@subheading gnutls_certificate_set_openpgp_trustdb
@anchor{gnutls_certificate_set_openpgp_trustdb}
@deftypefun {int} {gnutls_certificate_set_openpgp_trustdb} (gnutls_certificate_credentials_t      @var{res}, const char * @var{trustdb})
@var{res}: the destination context to save the data.

@var{trustdb}: is the trustdb filename

This funtion will set a GnuPG trustdb which will be used in key
verification functions. Only version 3 trustdb files are supported.
@end deftypefun

@subheading gnutls_openpgp_key_check_hostname
@anchor{gnutls_openpgp_key_check_hostname}
@deftypefun {int} {gnutls_openpgp_key_check_hostname} (gnutls_openpgp_key_t @var{key}, const char * @var{hostname})
@var{key}: should contain an gnutls_openpgp_key_t structure

@var{hostname}: A null terminated string that contains a DNS name

This function will check if the given key's owner matches
the given hostname. This is a basic implementation of the matching 
described in RFC2818 (HTTPS), which takes into account wildcards.

Returns non zero on success, and zero on failure.
@end deftypefun

@subheading gnutls_openpgp_key_deinit
@anchor{gnutls_openpgp_key_deinit}
@deftypefun {void} {gnutls_openpgp_key_deinit} (gnutls_openpgp_key_t @var{key})
@var{key}: The structure to be initialized

This function will deinitialize a key structure. 
@end deftypefun

@subheading gnutls_openpgp_key_export
@anchor{gnutls_openpgp_key_export}
@deftypefun {int} {gnutls_openpgp_key_export} (gnutls_openpgp_key_t @var{key}, gnutls_openpgp_key_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
@var{key}: Holds the key.

@var{format}: One of gnutls_openpgp_key_fmt_t elements.

@var{output_data}: will contain the key base64 encoded or raw

@var{output_data_size}: holds the size of output_data (and will be replaced by the actual size of parameters)

This function will convert the given key to RAW or Base64 format.
If the buffer provided is not long enough to hold the output, then
GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_key_get_creation_time
@anchor{gnutls_openpgp_key_get_creation_time}
@deftypefun {time_t} {gnutls_openpgp_key_get_creation_time} (gnutls_openpgp_key_t @var{key})
@var{key}: the structure that contains the OpenPGP public key.

Returns the timestamp when the OpenPGP key was created.
@end deftypefun

@subheading gnutls_openpgp_key_get_expiration_time
@anchor{gnutls_openpgp_key_get_expiration_time}
@deftypefun {time_t} {gnutls_openpgp_key_get_expiration_time} (gnutls_openpgp_key_t @var{key})
@var{key}: the structure that contains the OpenPGP public key.

Returns the time when the OpenPGP key expires. A value of '0' means
that the key doesn't expire at all.
@end deftypefun

@subheading gnutls_openpgp_key_get_fingerprint
@anchor{gnutls_openpgp_key_get_fingerprint}
@deftypefun {int} {gnutls_openpgp_key_get_fingerprint} (gnutls_openpgp_key_t @var{key}, void * @var{fpr}, size_t * @var{fprlen})
@var{key}: the raw data that contains the OpenPGP public key.

@var{fpr}: the buffer to save the fingerprint.

@var{fprlen}: the integer to save the length of the fingerprint.

Returns the fingerprint of the OpenPGP key. Depends on the algorithm,
the fingerprint can be 16 or 20 bytes.
@end deftypefun

@subheading gnutls_openpgp_key_get_id
@anchor{gnutls_openpgp_key_get_id}
@deftypefun {int} {gnutls_openpgp_key_get_id} (gnutls_openpgp_key_t @var{key}, unsigned char @var{keyid[8]})
@var{key}: the structure that contains the OpenPGP public key.

Returns the 64-bit keyID of the OpenPGP key.
@end deftypefun

@subheading gnutls_openpgp_key_get_key_usage
@anchor{gnutls_openpgp_key_get_key_usage}
@deftypefun {int} {gnutls_openpgp_key_get_key_usage} (gnutls_openpgp_key_t @var{key}, unsigned int * @var{key_usage})
@var{key}: should contain a gnutls_openpgp_key_t structure

@var{key_usage}: where the key usage bits will be stored

This function will return certificate's key usage, by checking the
key algorithm. The key usage value will ORed values of the:
GNUTLS_KEY_DIGITAL_SIGNATURE, GNUTLS_KEY_KEY_ENCIPHERMENT.

A negative value may be returned in case of parsing error.
@end deftypefun

@subheading gnutls_openpgp_key_get_name
@anchor{gnutls_openpgp_key_get_name}
@deftypefun {int} {gnutls_openpgp_key_get_name} (gnutls_openpgp_key_t @var{key}, int @var{idx}, char * @var{buf}, size_t * @var{sizeof_buf})
@var{key}: the structure that contains the OpenPGP public key.

@var{idx}: the index of the ID to extract

@var{buf}: a pointer to a structure to hold the name

@var{sizeof_buf}: holds the size of 'buf'

Extracts the userID from the parsed OpenPGP key.

Returns 0 on success, and GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE
if the index of the ID does not exist.
@end deftypefun

@subheading gnutls_openpgp_key_get_pk_algorithm
@anchor{gnutls_openpgp_key_get_pk_algorithm}
@deftypefun {int} {gnutls_openpgp_key_get_pk_algorithm} (gnutls_openpgp_key_t @var{key}, unsigned int * @var{bits})
@var{key}: is an OpenPGP key

@var{bits}: if bits is non null it will hold the size of the parameters' in bits

This function will return the public key algorithm of an OpenPGP
certificate.

If bits is non null, it should have enough size to hold the parameters
size in bits. For RSA the bits returned is the modulus. 
For DSA the bits returned are of the public exponent.

Returns a member of the GNUTLS_PKAlgorithm enumeration on success,
or a negative value on error.
@end deftypefun

@subheading gnutls_openpgp_key_get_version
@anchor{gnutls_openpgp_key_get_version}
@deftypefun {int} {gnutls_openpgp_key_get_version} (gnutls_openpgp_key_t @var{key})
@var{key}: the structure that contains the OpenPGP public key.

Extract the version of the OpenPGP key.
@end deftypefun

@subheading gnutls_openpgp_key_import
@anchor{gnutls_openpgp_key_import}
@deftypefun {int} {gnutls_openpgp_key_import} (gnutls_openpgp_key_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_openpgp_key_fmt_t @var{format})
@var{key}: The structure to store the parsed key.

@var{data}: The RAW or BASE64 encoded key.

@var{format}: One of gnutls_openpgp_key_fmt_t elements.

This function will convert the given RAW or Base64 encoded key
to the native gnutls_openpgp_key_t format. The output will be stored in 'key'.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_key_init
@anchor{gnutls_openpgp_key_init}
@deftypefun {int} {gnutls_openpgp_key_init} (gnutls_openpgp_key_t * @var{key})
@var{key}: The structure to be initialized

This function will initialize an OpenPGP key structure. 

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_key_to_xml
@anchor{gnutls_openpgp_key_to_xml}
@deftypefun {int} {gnutls_openpgp_key_to_xml} (gnutls_openpgp_key_t @var{key}, gnutls_datum_t * @var{xmlkey}, int @var{ext})
@var{xmlkey}: he datum struct to store the XML result.

@var{ext}: extension mode (1/0), 1 means include key signatures and key data.

This function will return the all OpenPGP key information encapsulated as
a XML string.
@end deftypefun

@subheading gnutls_openpgp_key_verify_ring
@anchor{gnutls_openpgp_key_verify_ring}
@deftypefun {int} {gnutls_openpgp_key_verify_ring} (gnutls_openpgp_key_t @var{key}, gnutls_openpgp_keyring_t @var{keyring}, unsigned int @var{flags}, unsigned int * @var{verify})
@var{key}: the structure that holds the key.

@var{keyring}: holds the keyring to check against

@var{flags}: unused (should be 0)

@var{verify}: will hold the certificate verification output.

Verify all signatures in the key, using the given set of keys (keyring). 

The key verification output will be put in @code{verify} and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.

@strong{GNUTLS_CERT_INVALID:} A signature on the key is invalid.

@strong{GNUTLS_CERT_REVOKED:} The key has been revoked.

Note that this function does not verify using any "web of
trust". You may use GnuPG for that purpose, or any other external
PGP application.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_key_verify_self
@anchor{gnutls_openpgp_key_verify_self}
@deftypefun {int} {gnutls_openpgp_key_verify_self} (gnutls_openpgp_key_t @var{key}, unsigned int @var{flags}, unsigned int * @var{verify})
@var{key}: the structure that holds the key.

@var{flags}: unused (should be 0)

@var{verify}: will hold the key verification output.

Verifies the self signature in the key.
The key verification output will be put in @code{verify} and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.

@strong{GNUTLS_CERT_INVALID:} The self signature on the key is invalid.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_key_verify_trustdb
@anchor{gnutls_openpgp_key_verify_trustdb}
@deftypefun {int} {gnutls_openpgp_key_verify_trustdb} (gnutls_openpgp_key_t @var{key}, gnutls_openpgp_trustdb_t @var{trustdb}, unsigned int @var{flags}, unsigned int * @var{verify})
@var{key}: the structure that holds the key.

@var{trustdb}: holds the trustdb to check against

@var{flags}: unused (should be 0)

@var{verify}: will hold the certificate verification output.

Checks if the key is revoked or disabled, in the trustdb.
The verification output will be put in @code{verify} and will be
one or more of the gnutls_certificate_status_t enumerated elements bitwise or'd.

@strong{GNUTLS_CERT_INVALID:} A signature on the key is invalid.

@strong{GNUTLS_CERT_REVOKED:} The key has been revoked.

Note that this function does not verify using any "web of
trust". You may use GnuPG for that purpose, or any other external
PGP application.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_keyring_check_id
@anchor{gnutls_openpgp_keyring_check_id}
@deftypefun {int} {gnutls_openpgp_keyring_check_id} (gnutls_openpgp_keyring_t @var{ring}, const unsigned char @var{keyid[8]}, unsigned int @var{flags})
@var{ring}: holds the keyring to check against

@var{flags}: unused (should be 0)

Check if a given key ID exists in the keyring.

Returns 0 on success (if keyid exists) and a negative error code
on failure.
@end deftypefun

@subheading gnutls_openpgp_keyring_deinit
@anchor{gnutls_openpgp_keyring_deinit}
@deftypefun {void} {gnutls_openpgp_keyring_deinit} (gnutls_openpgp_keyring_t @var{keyring})
@var{keyring}: The structure to be initialized

This function will deinitialize a CRL structure. 
@end deftypefun

@subheading gnutls_openpgp_keyring_import
@anchor{gnutls_openpgp_keyring_import}
@deftypefun {int} {gnutls_openpgp_keyring_import} (gnutls_openpgp_keyring_t @var{keyring}, const gnutls_datum_t * @var{data}, gnutls_openpgp_key_fmt_t @var{format})
@var{keyring}: The structure to store the parsed key.

@var{data}: The RAW or BASE64 encoded keyring.

@var{format}: One of gnutls_openpgp_keyring_fmt elements.

This function will convert the given RAW or Base64 encoded keyring
to the native gnutls_openpgp_keyring_t format. The output will be stored in 'keyring'.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_keyring_init
@anchor{gnutls_openpgp_keyring_init}
@deftypefun {int} {gnutls_openpgp_keyring_init} (gnutls_openpgp_keyring_t * @var{keyring})
@var{keyring}: The structure to be initialized

This function will initialize an OpenPGP keyring structure. 

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_privkey_deinit
@anchor{gnutls_openpgp_privkey_deinit}
@deftypefun {void} {gnutls_openpgp_privkey_deinit} (gnutls_openpgp_privkey_t @var{key})
@var{key}: The structure to be initialized

This function will deinitialize a key structure. 
@end deftypefun

@subheading gnutls_openpgp_privkey_get_pk_algorithm
@anchor{gnutls_openpgp_privkey_get_pk_algorithm}
@deftypefun {int} {gnutls_openpgp_privkey_get_pk_algorithm} (gnutls_openpgp_privkey_t @var{key}, unsigned int * @var{bits})
@var{key}: is an OpenPGP key

@var{bits}: if bits is non null it will hold the size of the parameters' in bits

This function will return the public key algorithm of an OpenPGP
certificate.

If bits is non null, it should have enough size to hold the parameters
size in bits. For RSA the bits returned is the modulus. 
For DSA the bits returned are of the public exponent.

Returns a member of the GNUTLS_PKAlgorithm enumeration on success,
or a negative value on error.
@end deftypefun

@subheading gnutls_openpgp_privkey_import
@anchor{gnutls_openpgp_privkey_import}
@deftypefun {int} {gnutls_openpgp_privkey_import} (gnutls_openpgp_privkey_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_openpgp_key_fmt_t @var{format}, const char * @var{pass}, unsigned int @var{flags})
@var{key}: The structure to store the parsed key.

@var{data}: The RAW or BASE64 encoded key.

@var{format}: One of gnutls_openpgp_key_fmt_t elements.

@var{pass}: Unused for now

@var{flags}: should be zero

This function will convert the given RAW or Base64 encoded key
to the native gnutls_openpgp_privkey_t format. The output will be stored in 'key'.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_privkey_init
@anchor{gnutls_openpgp_privkey_init}
@deftypefun {int} {gnutls_openpgp_privkey_init} (gnutls_openpgp_privkey_t * @var{key})
@var{key}: The structure to be initialized

This function will initialize an OpenPGP key structure. 

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_set_recv_key_function
@anchor{gnutls_openpgp_set_recv_key_function}
@deftypefun {void} {gnutls_openpgp_set_recv_key_function} (gnutls_session_t @var{session}, gnutls_openpgp_recv_key_func @var{func})
@var{session}: a TLS session

@var{func}: the callback

This funtion will set a key retrieval function for OpenPGP keys. This
callback is only useful in server side, and will be used if the peer
sent a key fingerprint instead of a full key.
@end deftypefun

@subheading gnutls_openpgp_trustdb_deinit
@anchor{gnutls_openpgp_trustdb_deinit}
@deftypefun {void} {gnutls_openpgp_trustdb_deinit} (gnutls_openpgp_trustdb_t @var{trustdb})
@var{trustdb}: The structure to be initialized

This function will deinitialize a CRL structure. 
@end deftypefun

@subheading gnutls_openpgp_trustdb_import_file
@anchor{gnutls_openpgp_trustdb_import_file}
@deftypefun {int} {gnutls_openpgp_trustdb_import_file} (gnutls_openpgp_trustdb_t @var{trustdb}, const char * @var{file})
@var{trustdb}: The structure to store the parsed key.

@var{file}: The file that holds the trustdb.

This function will convert the given RAW or Base64 encoded trustdb
to the native gnutls_openpgp_trustdb_t format. The output will be stored in 'trustdb'.

Returns 0 on success.
@end deftypefun

@subheading gnutls_openpgp_trustdb_init
@anchor{gnutls_openpgp_trustdb_init}
@deftypefun {int} {gnutls_openpgp_trustdb_init} (gnutls_openpgp_trustdb_t * @var{trustdb})
@var{trustdb}: The structure to be initialized

This function will initialize an OpenPGP trustdb structure. 

Returns 0 on success.
@end deftypefun