Tizen 2.0 Release
[external/libgnutls26.git] / doc / x509-api.texi
1
2
3
4
5 @subheading gnutls_pkcs12_bag_decrypt
6 @anchor{gnutls_pkcs12_bag_decrypt}
7 @deftypefun {int} {gnutls_pkcs12_bag_decrypt} (gnutls_pkcs12_bag_t @var{bag}, const char * @var{pass})
8 @var{bag}: The bag
9
10 @var{pass}: The password used for encryption, must be ASCII.
11
12 This function will decrypt the given encrypted bag and return 0 on
13 success.
14
15 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
16 otherwise an error code is returned.
17 @end deftypefun
18
19 @subheading gnutls_pkcs12_bag_deinit
20 @anchor{gnutls_pkcs12_bag_deinit}
21 @deftypefun {void} {gnutls_pkcs12_bag_deinit} (gnutls_pkcs12_bag_t @var{bag})
22 @var{bag}: The structure to be initialized
23
24 This function will deinitialize a PKCS12 Bag structure.
25 @end deftypefun
26
27 @subheading gnutls_pkcs12_bag_encrypt
28 @anchor{gnutls_pkcs12_bag_encrypt}
29 @deftypefun {int} {gnutls_pkcs12_bag_encrypt} (gnutls_pkcs12_bag_t @var{bag}, const char * @var{pass}, unsigned int @var{flags})
30 @var{bag}: The bag
31
32 @var{pass}: The password used for encryption, must be ASCII
33
34 @var{flags}: should be one of @code{gnutls_pkcs_encrypt_flags_t} elements bitwise or'd
35
36 This function will encrypt the given bag.
37
38 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
39 otherwise an error code is returned.
40 @end deftypefun
41
42 @subheading gnutls_pkcs12_bag_get_count
43 @anchor{gnutls_pkcs12_bag_get_count}
44 @deftypefun {int} {gnutls_pkcs12_bag_get_count} (gnutls_pkcs12_bag_t @var{bag})
45 @var{bag}: The bag
46
47 This function will return the number of the elements withing the bag.
48
49 @strong{Returns:} Number of elements in bag, or an negative error code on
50 error.
51 @end deftypefun
52
53 @subheading gnutls_pkcs12_bag_get_data
54 @anchor{gnutls_pkcs12_bag_get_data}
55 @deftypefun {int} {gnutls_pkcs12_bag_get_data} (gnutls_pkcs12_bag_t @var{bag}, int @var{indx}, gnutls_datum_t * @var{data})
56 @var{bag}: The bag
57
58 @var{indx}: The element of the bag to get the data from
59
60 @var{data}: where the bag's data will be. Should be treated as constant.
61
62 This function will return the bag's data. The data is a constant
63 that is stored into the bag.  Should not be accessed after the bag
64 is deleted.
65
66 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
67 negative error value.
68 @end deftypefun
69
70 @subheading gnutls_pkcs12_bag_get_friendly_name
71 @anchor{gnutls_pkcs12_bag_get_friendly_name}
72 @deftypefun {int} {gnutls_pkcs12_bag_get_friendly_name} (gnutls_pkcs12_bag_t @var{bag}, int @var{indx}, char ** @var{name})
73 @var{bag}: The bag
74
75 @var{indx}: The bag's element to add the id
76
77 @var{name}: will hold a pointer to the name (to be treated as const)
78
79 This function will return the friendly name, of the specified bag
80 element.  The key ID is usually used to distinguish the local
81 private key and the certificate pair.
82
83 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
84 negative error value. or a negative value on error.
85 @end deftypefun
86
87 @subheading gnutls_pkcs12_bag_get_key_id
88 @anchor{gnutls_pkcs12_bag_get_key_id}
89 @deftypefun {int} {gnutls_pkcs12_bag_get_key_id} (gnutls_pkcs12_bag_t @var{bag}, int @var{indx}, gnutls_datum_t * @var{id})
90 @var{bag}: The bag
91
92 @var{indx}: The bag's element to add the id
93
94 @var{id}: where the ID will be copied (to be treated as const)
95
96 This function will return the key ID, of the specified bag element.
97 The key ID is usually used to distinguish the local private key and
98 the certificate pair.
99
100 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
101 negative error value. or a negative value on error.
102 @end deftypefun
103
104 @subheading gnutls_pkcs12_bag_get_type
105 @anchor{gnutls_pkcs12_bag_get_type}
106 @deftypefun {gnutls_pkcs12_bag_type_t} {gnutls_pkcs12_bag_get_type} (gnutls_pkcs12_bag_t @var{bag}, int @var{indx})
107 @var{bag}: The bag
108
109 @var{indx}: The element of the bag to get the type
110
111 This function will return the bag's type.
112
113 @strong{Returns:} One of the @code{gnutls_pkcs12_bag_type_t} enumerations.
114 @end deftypefun
115
116 @subheading gnutls_pkcs12_bag_init
117 @anchor{gnutls_pkcs12_bag_init}
118 @deftypefun {int} {gnutls_pkcs12_bag_init} (gnutls_pkcs12_bag_t * @var{bag})
119 @var{bag}: The structure to be initialized
120
121 This function will initialize a PKCS12 bag structure. PKCS12 Bags
122 usually contain private keys, lists of X.509 Certificates and X.509
123 Certificate revocation lists.
124
125 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
126 negative error value.
127 @end deftypefun
128
129 @subheading gnutls_pkcs12_bag_set_crl
130 @anchor{gnutls_pkcs12_bag_set_crl}
131 @deftypefun {int} {gnutls_pkcs12_bag_set_crl} (gnutls_pkcs12_bag_t @var{bag}, gnutls_x509_crl_t @var{crl})
132 @var{bag}: The bag
133
134 @var{crl}: the CRL to be copied.
135
136 This function will insert the given CRL into the
137 bag. This is just a wrapper over @code{gnutls_pkcs12_bag_set_data()}.
138
139 @strong{Returns:} the index of the added bag on success, or a negative value
140 on failure.
141 @end deftypefun
142
143 @subheading gnutls_pkcs12_bag_set_crt
144 @anchor{gnutls_pkcs12_bag_set_crt}
145 @deftypefun {int} {gnutls_pkcs12_bag_set_crt} (gnutls_pkcs12_bag_t @var{bag}, gnutls_x509_crt_t @var{crt})
146 @var{bag}: The bag
147
148 @var{crt}: the certificate to be copied.
149
150 This function will insert the given certificate into the
151 bag. This is just a wrapper over @code{gnutls_pkcs12_bag_set_data()}.
152
153 @strong{Returns:} the index of the added bag on success, or a negative
154 value on failure.
155 @end deftypefun
156
157 @subheading gnutls_pkcs12_bag_set_data
158 @anchor{gnutls_pkcs12_bag_set_data}
159 @deftypefun {int} {gnutls_pkcs12_bag_set_data} (gnutls_pkcs12_bag_t @var{bag}, gnutls_pkcs12_bag_type_t @var{type}, const gnutls_datum_t * @var{data})
160 @var{bag}: The bag
161
162 @var{type}: The data's type
163
164 @var{data}: the data to be copied.
165
166 This function will insert the given data of the given type into
167 the bag.
168
169 @strong{Returns:} the index of the added bag on success, or a negative
170 value on error.
171 @end deftypefun
172
173 @subheading gnutls_pkcs12_bag_set_friendly_name
174 @anchor{gnutls_pkcs12_bag_set_friendly_name}
175 @deftypefun {int} {gnutls_pkcs12_bag_set_friendly_name} (gnutls_pkcs12_bag_t @var{bag}, int @var{indx}, const char * @var{name})
176 @var{bag}: The bag
177
178 @var{indx}: The bag's element to add the id
179
180 @var{name}: the name
181
182 This function will add the given key friendly name, to the
183 specified, by the index, bag element. The name will be encoded as
184 a 'Friendly name' bag attribute, which is usually used to set a
185 user name to the local private key and the certificate pair.
186
187 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
188 negative error value. or a negative value on error.
189 @end deftypefun
190
191 @subheading gnutls_pkcs12_bag_set_key_id
192 @anchor{gnutls_pkcs12_bag_set_key_id}
193 @deftypefun {int} {gnutls_pkcs12_bag_set_key_id} (gnutls_pkcs12_bag_t @var{bag}, int @var{indx}, const gnutls_datum_t * @var{id})
194 @var{bag}: The bag
195
196 @var{indx}: The bag's element to add the id
197
198 @var{id}: the ID
199
200 This function will add the given key ID, to the specified, by the
201 index, bag element. The key ID will be encoded as a 'Local key
202 identifier' bag attribute, which is usually used to distinguish
203 the local private key and the certificate pair.
204
205 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
206 negative error value. or a negative value on error.
207 @end deftypefun
208
209 @subheading gnutls_pkcs12_deinit
210 @anchor{gnutls_pkcs12_deinit}
211 @deftypefun {void} {gnutls_pkcs12_deinit} (gnutls_pkcs12_t @var{pkcs12})
212 @var{pkcs12}: The structure to be initialized
213
214 This function will deinitialize a PKCS12 structure.
215 @end deftypefun
216
217 @subheading gnutls_pkcs12_export
218 @anchor{gnutls_pkcs12_export}
219 @deftypefun {int} {gnutls_pkcs12_export} (gnutls_pkcs12_t @var{pkcs12}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
220 @var{pkcs12}: Holds the pkcs12 structure
221
222 @var{format}: the format of output params. One of PEM or DER.
223
224 @var{output_data}: will contain a structure PEM or DER encoded
225
226 @var{output_data_size}: holds the size of output_data (and will be
227 replaced by the actual size of parameters)
228
229 This function will export the pkcs12 structure to DER or PEM format.
230
231 If the buffer provided is not long enough to hold the output, then
232 *output_data_size will be updated and GNUTLS_E_SHORT_MEMORY_BUFFER
233 will be returned.
234
235 If the structure is PEM encoded, it will have a header
236 of "BEGIN PKCS12".
237
238 @strong{Return value:} In case of failure a negative value will be
239 returned, and 0 on success.
240 @end deftypefun
241
242 @subheading gnutls_pkcs12_generate_mac
243 @anchor{gnutls_pkcs12_generate_mac}
244 @deftypefun {int} {gnutls_pkcs12_generate_mac} (gnutls_pkcs12_t @var{pkcs12}, const char * @var{pass})
245 @var{pkcs12}: should contain a gnutls_pkcs12_t structure
246
247 @var{pass}: The password for the MAC
248
249 This function will generate a MAC for the PKCS12 structure.
250
251 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
252 negative error value.
253 @end deftypefun
254
255 @subheading gnutls_pkcs12_get_bag
256 @anchor{gnutls_pkcs12_get_bag}
257 @deftypefun {int} {gnutls_pkcs12_get_bag} (gnutls_pkcs12_t @var{pkcs12}, int @var{indx}, gnutls_pkcs12_bag_t @var{bag})
258 @var{pkcs12}: should contain a gnutls_pkcs12_t structure
259
260 @var{indx}: contains the index of the bag to extract
261
262 @var{bag}: An initialized bag, where the contents of the bag will be copied
263
264 This function will return a Bag from the PKCS12 structure.
265
266 After the last Bag has been read
267 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be returned.
268
269 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
270 negative error value.
271 @end deftypefun
272
273 @subheading gnutls_pkcs12_import
274 @anchor{gnutls_pkcs12_import}
275 @deftypefun {int} {gnutls_pkcs12_import} (gnutls_pkcs12_t @var{pkcs12}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
276 @var{pkcs12}: The structure to store the parsed PKCS12.
277
278 @var{data}: The DER or PEM encoded PKCS12.
279
280 @var{format}: One of DER or PEM
281
282 @var{flags}: an ORed sequence of gnutls_privkey_pkcs8_flags
283
284 This function will convert the given DER or PEM encoded PKCS12
285 to the native gnutls_pkcs12_t format. The output will be stored in 'pkcs12'.
286
287 If the PKCS12 is PEM encoded it should have a header of "PKCS12".
288
289 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
290 negative error value.
291 @end deftypefun
292
293 @subheading gnutls_pkcs12_init
294 @anchor{gnutls_pkcs12_init}
295 @deftypefun {int} {gnutls_pkcs12_init} (gnutls_pkcs12_t * @var{pkcs12})
296 @var{pkcs12}: The structure to be initialized
297
298 This function will initialize a PKCS12 structure. PKCS12 structures
299 usually contain lists of X.509 Certificates and X.509 Certificate
300 revocation lists.
301
302 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
303 negative error value.
304 @end deftypefun
305
306 @subheading gnutls_pkcs12_set_bag
307 @anchor{gnutls_pkcs12_set_bag}
308 @deftypefun {int} {gnutls_pkcs12_set_bag} (gnutls_pkcs12_t @var{pkcs12}, gnutls_pkcs12_bag_t @var{bag})
309 @var{pkcs12}: should contain a gnutls_pkcs12_t structure
310
311 @var{bag}: An initialized bag
312
313 This function will insert a Bag into the PKCS12 structure.
314
315 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
316 negative error value.
317 @end deftypefun
318
319 @subheading gnutls_pkcs12_verify_mac
320 @anchor{gnutls_pkcs12_verify_mac}
321 @deftypefun {int} {gnutls_pkcs12_verify_mac} (gnutls_pkcs12_t @var{pkcs12}, const char * @var{pass})
322 @var{pkcs12}: should contain a gnutls_pkcs12_t structure
323
324 @var{pass}: The password for the MAC
325
326 This function will verify the MAC for the PKCS12 structure.
327
328 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
329 negative error value.
330 @end deftypefun
331
332 @subheading gnutls_pkcs7_deinit
333 @anchor{gnutls_pkcs7_deinit}
334 @deftypefun {void} {gnutls_pkcs7_deinit} (gnutls_pkcs7_t @var{pkcs7})
335 @var{pkcs7}: The structure to be initialized
336
337 This function will deinitialize a PKCS7 structure.
338 @end deftypefun
339
340 @subheading gnutls_pkcs7_delete_crl
341 @anchor{gnutls_pkcs7_delete_crl}
342 @deftypefun {int} {gnutls_pkcs7_delete_crl} (gnutls_pkcs7_t @var{pkcs7}, int @var{indx})
343 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
344
345 @var{indx}: the index of the crl to delete
346
347 This function will delete a crl from a PKCS7 or RFC2630 crl set.
348 Index starts from 0. Returns 0 on success.
349
350 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
351 negative error value.
352 @end deftypefun
353
354 @subheading gnutls_pkcs7_delete_crt
355 @anchor{gnutls_pkcs7_delete_crt}
356 @deftypefun {int} {gnutls_pkcs7_delete_crt} (gnutls_pkcs7_t @var{pkcs7}, int @var{indx})
357 @var{pkcs7}: should contain a gnutls_pkcs7_t structure
358
359 @var{indx}: the index of the certificate to delete
360
361 This function will delete a certificate from a PKCS7 or RFC2630
362 certificate set.  Index starts from 0. Returns 0 on success.
363
364 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
365 negative error value.
366 @end deftypefun
367
368 @subheading gnutls_pkcs7_export
369 @anchor{gnutls_pkcs7_export}
370 @deftypefun {int} {gnutls_pkcs7_export} (gnutls_pkcs7_t @var{pkcs7}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
371 @var{pkcs7}: Holds the pkcs7 structure
372
373 @var{format}: the format of output params. One of PEM or DER.
374
375 @var{output_data}: will contain a structure PEM or DER encoded
376
377 @var{output_data_size}: holds the size of output_data (and will be
378 replaced by the actual size of parameters)
379
380 This function will export the pkcs7 structure to DER or PEM format.
381
382 If the buffer provided is not long enough to hold the output, then
383 *@code{output_data_size} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}
384 will be returned.
385
386 If the structure is PEM encoded, it will have a header
387 of "BEGIN PKCS7".
388
389 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
390 negative error value.
391 @end deftypefun
392
393 @subheading gnutls_pkcs7_get_crl_count
394 @anchor{gnutls_pkcs7_get_crl_count}
395 @deftypefun {int} {gnutls_pkcs7_get_crl_count} (gnutls_pkcs7_t @var{pkcs7})
396 @var{pkcs7}: should contain a gnutls_pkcs7_t structure
397
398 This function will return the number of certifcates in the PKCS7
399 or RFC2630 crl set.
400
401 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
402 negative error value.
403 @end deftypefun
404
405 @subheading gnutls_pkcs7_get_crl_raw
406 @anchor{gnutls_pkcs7_get_crl_raw}
407 @deftypefun {int} {gnutls_pkcs7_get_crl_raw} (gnutls_pkcs7_t @var{pkcs7}, int @var{indx}, void * @var{crl}, size_t * @var{crl_size})
408 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
409
410 @var{indx}: contains the index of the crl to extract
411
412 @var{crl}: the contents of the crl will be copied there (may be null)
413
414 @var{crl_size}: should hold the size of the crl
415
416 This function will return a crl of the PKCS7 or RFC2630 crl set.
417
418 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
419 negative error value.  If the provided buffer is not long enough,
420 then @code{crl_size} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} is
421 returned.  After the last crl has been read
422 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be returned.
423 @end deftypefun
424
425 @subheading gnutls_pkcs7_get_crt_count
426 @anchor{gnutls_pkcs7_get_crt_count}
427 @deftypefun {int} {gnutls_pkcs7_get_crt_count} (gnutls_pkcs7_t @var{pkcs7})
428 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
429
430 This function will return the number of certifcates in the PKCS7
431 or RFC2630 certificate set.
432
433 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
434 negative error value.
435 @end deftypefun
436
437 @subheading gnutls_pkcs7_get_crt_raw
438 @anchor{gnutls_pkcs7_get_crt_raw}
439 @deftypefun {int} {gnutls_pkcs7_get_crt_raw} (gnutls_pkcs7_t @var{pkcs7}, int @var{indx}, void * @var{certificate}, size_t * @var{certificate_size})
440 @var{pkcs7}: should contain a gnutls_pkcs7_t structure
441
442 @var{indx}: contains the index of the certificate to extract
443
444 @var{certificate}: the contents of the certificate will be copied
445 there (may be null)
446
447 @var{certificate_size}: should hold the size of the certificate
448
449 This function will return a certificate of the PKCS7 or RFC2630
450 certificate set.
451
452 After the last certificate has been read
453 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be returned.
454
455 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
456 negative error value.  If the provided buffer is not long enough,
457 then @code{certificate_size} is updated and
458 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} is returned.
459 @end deftypefun
460
461 @subheading gnutls_pkcs7_import
462 @anchor{gnutls_pkcs7_import}
463 @deftypefun {int} {gnutls_pkcs7_import} (gnutls_pkcs7_t @var{pkcs7}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
464 @var{pkcs7}: The structure to store the parsed PKCS7.
465
466 @var{data}: The DER or PEM encoded PKCS7.
467
468 @var{format}: One of DER or PEM
469
470 This function will convert the given DER or PEM encoded PKCS7 to
471 the native @code{gnutls_pkcs7_t} format.  The output will be stored in
472 @code{pkcs7}.
473
474 If the PKCS7 is PEM encoded it should have a header of "PKCS7".
475
476 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
477 negative error value.
478 @end deftypefun
479
480 @subheading gnutls_pkcs7_init
481 @anchor{gnutls_pkcs7_init}
482 @deftypefun {int} {gnutls_pkcs7_init} (gnutls_pkcs7_t * @var{pkcs7})
483 @var{pkcs7}: The structure to be initialized
484
485 This function will initialize a PKCS7 structure. PKCS7 structures
486 usually contain lists of X.509 Certificates and X.509 Certificate
487 revocation lists.
488
489 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
490 negative error value.
491 @end deftypefun
492
493 @subheading gnutls_pkcs7_set_crl_raw
494 @anchor{gnutls_pkcs7_set_crl_raw}
495 @deftypefun {int} {gnutls_pkcs7_set_crl_raw} (gnutls_pkcs7_t @var{pkcs7}, const gnutls_datum_t * @var{crl})
496 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
497
498 @var{crl}: the DER encoded crl to be added
499
500 This function will add a crl to the PKCS7 or RFC2630 crl set.
501
502 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
503 negative error value.
504 @end deftypefun
505
506 @subheading gnutls_pkcs7_set_crl
507 @anchor{gnutls_pkcs7_set_crl}
508 @deftypefun {int} {gnutls_pkcs7_set_crl} (gnutls_pkcs7_t @var{pkcs7}, gnutls_x509_crl_t @var{crl})
509 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
510
511 @var{crl}: the DER encoded crl to be added
512
513 This function will add a parsed CRL to the PKCS7 or RFC2630 crl
514 set.
515
516 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
517 negative error value.
518 @end deftypefun
519
520 @subheading gnutls_pkcs7_set_crt_raw
521 @anchor{gnutls_pkcs7_set_crt_raw}
522 @deftypefun {int} {gnutls_pkcs7_set_crt_raw} (gnutls_pkcs7_t @var{pkcs7}, const gnutls_datum_t * @var{crt})
523 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
524
525 @var{crt}: the DER encoded certificate to be added
526
527 This function will add a certificate to the PKCS7 or RFC2630
528 certificate set.
529
530 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
531 negative error value.
532 @end deftypefun
533
534 @subheading gnutls_pkcs7_set_crt
535 @anchor{gnutls_pkcs7_set_crt}
536 @deftypefun {int} {gnutls_pkcs7_set_crt} (gnutls_pkcs7_t @var{pkcs7}, gnutls_x509_crt_t @var{crt})
537 @var{pkcs7}: should contain a @code{gnutls_pkcs7_t} structure
538
539 @var{crt}: the certificate to be copied.
540
541 This function will add a parsed certificate to the PKCS7 or
542 RFC2630 certificate set.  This is a wrapper function over
543 @code{gnutls_pkcs7_set_crt_raw()} .
544
545 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
546 negative error value.
547 @end deftypefun
548
549 @subheading gnutls_x509_crl_check_issuer
550 @anchor{gnutls_x509_crl_check_issuer}
551 @deftypefun {int} {gnutls_x509_crl_check_issuer} (gnutls_x509_crl_t @var{cert}, gnutls_x509_crt_t @var{issuer})
552 @var{issuer}: is the certificate of a possible issuer
553
554 This function will check if the given CRL was issued by the given
555 issuer certificate.  It will return true (1) if the given CRL was
556 issued by the given issuer, and false (0) if not.
557
558 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
559 negative error value.
560 @end deftypefun
561
562 @subheading gnutls_x509_crl_deinit
563 @anchor{gnutls_x509_crl_deinit}
564 @deftypefun {void} {gnutls_x509_crl_deinit} (gnutls_x509_crl_t @var{crl})
565 @var{crl}: The structure to be initialized
566
567 This function will deinitialize a CRL structure.
568 @end deftypefun
569
570 @subheading gnutls_x509_crl_export
571 @anchor{gnutls_x509_crl_export}
572 @deftypefun {int} {gnutls_x509_crl_export} (gnutls_x509_crl_t @var{crl}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
573 @var{crl}: Holds the revocation list
574
575 @var{format}: the format of output params. One of PEM or DER.
576
577 @var{output_data}: will contain a private key PEM or DER encoded
578
579 @var{output_data_size}: holds the size of output_data (and will
580 be replaced by the actual size of parameters)
581
582 This function will export the revocation list to DER or PEM format.
583
584 If the buffer provided is not long enough to hold the output, then
585 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will be returned.
586
587 If the structure is PEM encoded, it will have a header
588 of "BEGIN X509 CRL".
589
590 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
591 negative error value. and a negative value on failure.
592 @end deftypefun
593
594 @subheading gnutls_x509_crl_get_authority_key_id
595 @anchor{gnutls_x509_crl_get_authority_key_id}
596 @deftypefun {int} {gnutls_x509_crl_get_authority_key_id} (gnutls_x509_crl_t @var{crl}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{critical})
597 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
598
599 @var{ret}: The place where the identifier will be copied
600
601 @var{ret_size}: Holds the size of the result field.
602
603 @var{critical}: will be non zero if the extension is marked as critical
604 (may be null)
605
606 This function will return the CRL authority's key identifier.  This
607 is obtained by the X.509 Authority Key identifier extension field
608 (2.5.29.35).  Note that this function only returns the
609 keyIdentifier field of the extension.
610
611 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
612 negative value in case of an error.
613
614 @strong{Since:} 2.8.0
615 @end deftypefun
616
617 @subheading gnutls_x509_crl_get_crt_count
618 @anchor{gnutls_x509_crl_get_crt_count}
619 @deftypefun {int} {gnutls_x509_crl_get_crt_count} (gnutls_x509_crl_t @var{crl})
620 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
621
622 This function will return the number of revoked certificates in the
623 given CRL.
624
625 @strong{Returns:} number of certificates, a negative value on failure.
626 @end deftypefun
627
628 @subheading gnutls_x509_crl_get_crt_serial
629 @anchor{gnutls_x509_crl_get_crt_serial}
630 @deftypefun {int} {gnutls_x509_crl_get_crt_serial} (gnutls_x509_crl_t @var{crl}, int @var{indx}, unsigned char * @var{serial}, size_t * @var{serial_size}, time_t * @var{t})
631 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
632
633 @var{indx}: the index of the certificate to extract (starting from 0)
634
635 @var{serial}: where the serial number will be copied
636
637 @var{serial_size}: initially holds the size of serial
638
639 @var{t}: if non null, will hold the time this certificate was revoked
640
641 This function will retrieve the serial number of the specified, by
642 the index, revoked certificate.
643
644 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
645 negative error value. and a negative value on error.
646 @end deftypefun
647
648 @subheading gnutls_x509_crl_get_dn_oid
649 @anchor{gnutls_x509_crl_get_dn_oid}
650 @deftypefun {int} {gnutls_x509_crl_get_dn_oid} (gnutls_x509_crl_t @var{crl}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
651 @var{crl}: should contain a gnutls_x509_crl_t structure
652
653 @var{indx}: Specifies which DN OID to send. Use zero to get the first one.
654
655 @var{oid}: a pointer to a structure to hold the name (may be null)
656
657 @var{sizeof_oid}: initially holds the size of 'oid'
658
659 This function will extract the requested OID of the name of the CRL
660 issuer, specified by the given index.
661
662 If oid is null then only the size will be filled.
663
664 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
665 not long enough, and in that case the sizeof_oid will be updated
666 with the required size.  On success 0 is returned.
667 @end deftypefun
668
669 @subheading gnutls_x509_crl_get_extension_data
670 @anchor{gnutls_x509_crl_get_extension_data}
671 @deftypefun {int} {gnutls_x509_crl_get_extension_data} (gnutls_x509_crl_t @var{crl}, int @var{indx}, void * @var{data}, size_t * @var{sizeof_data})
672 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
673
674 @var{indx}: Specifies which extension OID to send. Use zero to get the first one.
675
676 @var{data}: a pointer to a structure to hold the data (may be null)
677
678 @var{sizeof_data}: initially holds the size of @code{oid}
679
680 This function will return the requested extension data in the CRL.
681 The extension data will be stored as a string in the provided
682 buffer.
683
684 Use @code{gnutls_x509_crl_get_extension_info()} to extract the OID and
685 critical flag.  Use @code{gnutls_x509_crl_get_extension_info()} instead,
686 if you want to get data indexed by the extension OID rather than
687 sequence.
688
689 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
690 negative value in case of an error.  If your have reached the
691 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
692 will be returned.
693
694 @strong{Since:} 2.8.0
695 @end deftypefun
696
697 @subheading gnutls_x509_crl_get_extension_info
698 @anchor{gnutls_x509_crl_get_extension_info}
699 @deftypefun {int} {gnutls_x509_crl_get_extension_info} (gnutls_x509_crl_t @var{crl}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid}, int * @var{critical})
700 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
701
702 @var{indx}: Specifies which extension OID to send, use zero to get the first one.
703
704 @var{oid}: a pointer to a structure to hold the OID
705
706 @var{sizeof_oid}: initially holds the maximum size of @code{oid}, on return
707 holds actual size of @code{oid}.
708
709 @var{critical}: output variable with critical flag, may be NULL.
710
711 This function will return the requested extension OID in the CRL,
712 and the critical flag for it.  The extension OID will be stored as
713 a string in the provided buffer.  Use
714 @code{gnutls_x509_crl_get_extension_data()} to extract the data.
715
716 If the buffer provided is not long enough to hold the output, then
717 *@code{sizeof_oid} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will be
718 returned.
719
720 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
721 negative value in case of an error.  If your have reached the
722 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
723 will be returned.
724
725 @strong{Since:} 2.8.0
726 @end deftypefun
727
728 @subheading gnutls_x509_crl_get_extension_oid
729 @anchor{gnutls_x509_crl_get_extension_oid}
730 @deftypefun {int} {gnutls_x509_crl_get_extension_oid} (gnutls_x509_crl_t @var{crl}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
731 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
732
733 @var{indx}: Specifies which extension OID to send, use zero to get the first one.
734
735 @var{oid}: a pointer to a structure to hold the OID (may be null)
736
737 @var{sizeof_oid}: initially holds the size of @code{oid}
738
739 This function will return the requested extension OID in the CRL.
740 The extension OID will be stored as a string in the provided
741 buffer.
742
743 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
744 negative value in case of an error.  If your have reached the
745 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
746 will be returned.
747
748 @strong{Since:} 2.8.0
749 @end deftypefun
750
751 @subheading gnutls_x509_crl_get_issuer_dn_by_oid
752 @anchor{gnutls_x509_crl_get_issuer_dn_by_oid}
753 @deftypefun {int} {gnutls_x509_crl_get_issuer_dn_by_oid} (gnutls_x509_crl_t @var{crl}, const char * @var{oid}, int @var{indx}, unsigned int @var{raw_flag}, void * @var{buf}, size_t * @var{sizeof_buf})
754 @var{crl}: should contain a gnutls_x509_crl_t structure
755
756 @var{oid}: holds an Object Identified in null terminated string
757
758 @var{indx}: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
759
760 @var{raw_flag}: If non zero returns the raw DER data of the DN part.
761
762 @var{buf}: a pointer to a structure to hold the peer's name (may be null)
763
764 @var{sizeof_buf}: initially holds the size of @code{buf}
765
766 This function will extract the part of the name of the CRL issuer
767 specified by the given OID. The output will be encoded as described
768 in RFC2253. The output string will be ASCII or UTF-8 encoded,
769 depending on the certificate data.
770
771 Some helper macros with popular OIDs can be found in gnutls/x509.h
772 If raw flag is zero, this function will only return known OIDs as
773 text. Other OIDs will be DER encoded, as described in RFC2253 -- in
774 hex format with a '\#' prefix.  You can check about known OIDs
775 using @code{gnutls_x509_dn_oid_known()}.
776
777 If buf is null then only the size will be filled.
778
779 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
780 not long enough, and in that case the sizeof_buf will be updated
781 with the required size, and 0 on success.
782 @end deftypefun
783
784 @subheading gnutls_x509_crl_get_issuer_dn
785 @anchor{gnutls_x509_crl_get_issuer_dn}
786 @deftypefun {int} {gnutls_x509_crl_get_issuer_dn} (const gnutls_x509_crl_t @var{crl}, char * @var{buf}, size_t * @var{sizeof_buf})
787 @var{crl}: should contain a gnutls_x509_crl_t structure
788
789 @var{buf}: a pointer to a structure to hold the peer's name (may be null)
790
791 @var{sizeof_buf}: initially holds the size of @code{buf}
792
793 This function will copy the name of the CRL issuer in the provided
794 buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as
795 described in RFC2253. The output string will be ASCII or UTF-8
796 encoded, depending on the certificate data.
797
798 If buf is @code{NULL} then only the size will be filled.
799
800 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
801 not long enough, and in that case the sizeof_buf will be updated
802 with the required size, and 0 on success.
803 @end deftypefun
804
805 @subheading gnutls_x509_crl_get_next_update
806 @anchor{gnutls_x509_crl_get_next_update}
807 @deftypefun {time_t} {gnutls_x509_crl_get_next_update} (gnutls_x509_crl_t @var{crl})
808 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
809
810 This function will return the time the next CRL will be issued.
811 This field is optional in a CRL so it might be normal to get an
812 error instead.
813
814 @strong{Returns:} when the next CRL will be issued, or (time_t)-1 on error.
815 @end deftypefun
816
817 @subheading gnutls_x509_crl_get_number
818 @anchor{gnutls_x509_crl_get_number}
819 @deftypefun {int} {gnutls_x509_crl_get_number} (gnutls_x509_crl_t @var{crl}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{critical})
820 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
821
822 @var{ret}: The place where the number will be copied
823
824 @var{ret_size}: Holds the size of the result field.
825
826 @var{critical}: will be non zero if the extension is marked as critical
827 (may be null)
828
829 This function will return the CRL number extension.  This is
830 obtained by the CRL Number extension field (2.5.29.20).
831
832 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
833 negative value in case of an error.
834
835 @strong{Since:} 2.8.0
836 @end deftypefun
837
838 @subheading gnutls_x509_crl_get_raw_issuer_dn
839 @anchor{gnutls_x509_crl_get_raw_issuer_dn}
840 @deftypefun {int} {gnutls_x509_crl_get_raw_issuer_dn} (gnutls_x509_crl_t @var{crl}, gnutls_datum_t * @var{dn})
841 @var{crl}: should contain a gnutls_x509_crl_t structure
842
843 @var{dn}: will hold the starting point of the DN
844
845 This function will return a pointer to the DER encoded DN structure
846 and the length.
847
848 @strong{Returns:} a negative value on error, and zero on success.
849
850 @strong{Since:} 2.12.0
851 @end deftypefun
852
853 @subheading gnutls_x509_crl_get_signature_algorithm
854 @anchor{gnutls_x509_crl_get_signature_algorithm}
855 @deftypefun {int} {gnutls_x509_crl_get_signature_algorithm} (gnutls_x509_crl_t @var{crl})
856 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
857
858 This function will return a value of the @code{gnutls_sign_algorithm_t}
859 enumeration that is the signature algorithm.
860
861 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
862 negative error value.
863 @end deftypefun
864
865 @subheading gnutls_x509_crl_get_signature
866 @anchor{gnutls_x509_crl_get_signature}
867 @deftypefun {int} {gnutls_x509_crl_get_signature} (gnutls_x509_crl_t @var{crl}, char * @var{sig}, size_t * @var{sizeof_sig})
868 @var{crl}: should contain a gnutls_x509_crl_t structure
869
870 @var{sig}: a pointer where the signature part will be copied (may be null).
871
872 @var{sizeof_sig}: initially holds the size of @code{sig}
873
874 This function will extract the signature field of a CRL.
875
876 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
877 negative error value. and a negative value on error.
878 @end deftypefun
879
880 @subheading gnutls_x509_crl_get_this_update
881 @anchor{gnutls_x509_crl_get_this_update}
882 @deftypefun {time_t} {gnutls_x509_crl_get_this_update} (gnutls_x509_crl_t @var{crl})
883 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
884
885 This function will return the time this CRL was issued.
886
887 @strong{Returns:} when the CRL was issued, or (time_t)-1 on error.
888 @end deftypefun
889
890 @subheading gnutls_x509_crl_get_version
891 @anchor{gnutls_x509_crl_get_version}
892 @deftypefun {int} {gnutls_x509_crl_get_version} (gnutls_x509_crl_t @var{crl})
893 @var{crl}: should contain a @code{gnutls_x509_crl_t} structure
894
895 This function will return the version of the specified CRL.
896
897 @strong{Returns:} The version number, or a negative value on error.
898 @end deftypefun
899
900 @subheading gnutls_x509_crl_import
901 @anchor{gnutls_x509_crl_import}
902 @deftypefun {int} {gnutls_x509_crl_import} (gnutls_x509_crl_t @var{crl}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
903 @var{crl}: The structure to store the parsed CRL.
904
905 @var{data}: The DER or PEM encoded CRL.
906
907 @var{format}: One of DER or PEM
908
909 This function will convert the given DER or PEM encoded CRL
910 to the native @code{gnutls_x509_crl_t} format. The output will be stored in 'crl'.
911
912 If the CRL is PEM encoded it should have a header of "X509 CRL".
913
914 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
915 negative error value.
916 @end deftypefun
917
918 @subheading gnutls_x509_crl_init
919 @anchor{gnutls_x509_crl_init}
920 @deftypefun {int} {gnutls_x509_crl_init} (gnutls_x509_crl_t * @var{crl})
921 @var{crl}: The structure to be initialized
922
923 This function will initialize a CRL structure. CRL stands for
924 Certificate Revocation List. A revocation list usually contains
925 lists of certificate serial numbers that have been revoked by an
926 Authority. The revocation lists are always signed with the
927 authority's private key.
928
929 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
930 negative error value.
931 @end deftypefun
932
933 @subheading gnutls_x509_crl_print
934 @anchor{gnutls_x509_crl_print}
935 @deftypefun {int} {gnutls_x509_crl_print} (gnutls_x509_crl_t @var{crl}, gnutls_certificate_print_formats_t @var{format}, gnutls_datum_t * @var{out})
936 @var{crl}: The structure to be printed
937
938 @var{format}: Indicate the format to use
939
940 @var{out}: Newly allocated datum with zero terminated string.
941
942 This function will pretty print a X.509 certificate revocation
943 list, suitable for display to a human.
944
945 The output @code{out} needs to be deallocate using @code{gnutls_free()}.
946
947 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
948 negative error value.
949 @end deftypefun
950
951 @subheading gnutls_x509_crl_privkey_sign
952 @anchor{gnutls_x509_crl_privkey_sign}
953 @deftypefun {int} {gnutls_x509_crl_privkey_sign} (gnutls_x509_crl_t @var{crl}, gnutls_x509_crt_t @var{issuer}, gnutls_privkey_t @var{issuer_key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
954 @var{crl}: should contain a gnutls_x509_crl_t structure
955
956 @var{issuer}: is the certificate of the certificate issuer
957
958 @var{issuer_key}: holds the issuer's private key
959
960 @var{dig}: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
961
962 @var{flags}: must be 0
963
964 This function will sign the CRL with the issuer's private key, and
965 will copy the issuer's information into the CRL.
966
967 This must be the last step in a certificate CRL since all
968 the previously set parameters are now signed.
969
970 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
971 negative error value.
972 @end deftypefun
973
974 @subheading gnutls_x509_crl_set_authority_key_id
975 @anchor{gnutls_x509_crl_set_authority_key_id}
976 @deftypefun {int} {gnutls_x509_crl_set_authority_key_id} (gnutls_x509_crl_t @var{crl}, const void * @var{id}, size_t @var{id_size})
977 @var{crl}: a CRL of type @code{gnutls_x509_crl_t}
978
979 @var{id}: The key ID
980
981 @var{id_size}: Holds the size of the serial field.
982
983 This function will set the CRL's authority key ID extension.  Only
984 the keyIdentifier field can be set with this function.
985
986 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
987 negative error value.
988
989 @strong{Since:} 2.8.0
990 @end deftypefun
991
992 @subheading gnutls_x509_crl_set_crt_serial
993 @anchor{gnutls_x509_crl_set_crt_serial}
994 @deftypefun {int} {gnutls_x509_crl_set_crt_serial} (gnutls_x509_crl_t @var{crl}, const void * @var{serial}, size_t @var{serial_size}, time_t @var{revocation_time})
995 @var{crl}: should contain a gnutls_x509_crl_t structure
996
997 @var{serial}: The revoked certificate's serial number
998
999 @var{serial_size}: Holds the size of the serial field.
1000
1001 @var{revocation_time}: The time this certificate was revoked
1002
1003 This function will set a revoked certificate's serial number to the CRL.
1004
1005 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1006 negative error value.
1007 @end deftypefun
1008
1009 @subheading gnutls_x509_crl_set_crt
1010 @anchor{gnutls_x509_crl_set_crt}
1011 @deftypefun {int} {gnutls_x509_crl_set_crt} (gnutls_x509_crl_t @var{crl}, gnutls_x509_crt_t @var{crt}, time_t @var{revocation_time})
1012 @var{crl}: should contain a gnutls_x509_crl_t structure
1013
1014 @var{crt}: a certificate of type @code{gnutls_x509_crt_t} with the revoked certificate
1015
1016 @var{revocation_time}: The time this certificate was revoked
1017
1018 This function will set a revoked certificate's serial number to the CRL.
1019
1020 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1021 negative error value.
1022 @end deftypefun
1023
1024 @subheading gnutls_x509_crl_set_next_update
1025 @anchor{gnutls_x509_crl_set_next_update}
1026 @deftypefun {int} {gnutls_x509_crl_set_next_update} (gnutls_x509_crl_t @var{crl}, time_t @var{exp_time})
1027 @var{crl}: should contain a gnutls_x509_crl_t structure
1028
1029 @var{exp_time}: The actual time
1030
1031 This function will set the time this CRL will be updated.
1032
1033 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1034 negative error value.
1035 @end deftypefun
1036
1037 @subheading gnutls_x509_crl_set_number
1038 @anchor{gnutls_x509_crl_set_number}
1039 @deftypefun {int} {gnutls_x509_crl_set_number} (gnutls_x509_crl_t @var{crl}, const void * @var{nr}, size_t @var{nr_size})
1040 @var{crl}: a CRL of type @code{gnutls_x509_crl_t}
1041
1042 @var{nr}: The CRL number
1043
1044 @var{nr_size}: Holds the size of the nr field.
1045
1046 This function will set the CRL's number extension.
1047
1048 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1049 negative error value.
1050
1051 @strong{Since:} 2.8.0
1052 @end deftypefun
1053
1054 @subheading gnutls_x509_crl_set_this_update
1055 @anchor{gnutls_x509_crl_set_this_update}
1056 @deftypefun {int} {gnutls_x509_crl_set_this_update} (gnutls_x509_crl_t @var{crl}, time_t @var{act_time})
1057 @var{crl}: should contain a gnutls_x509_crl_t structure
1058
1059 @var{act_time}: The actual time
1060
1061 This function will set the time this CRL was issued.
1062
1063 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1064 negative error value.
1065 @end deftypefun
1066
1067 @subheading gnutls_x509_crl_set_version
1068 @anchor{gnutls_x509_crl_set_version}
1069 @deftypefun {int} {gnutls_x509_crl_set_version} (gnutls_x509_crl_t @var{crl}, unsigned int @var{version})
1070 @var{crl}: should contain a gnutls_x509_crl_t structure
1071
1072 @var{version}: holds the version number. For CRLv1 crls must be 1.
1073
1074 This function will set the version of the CRL. This
1075 must be one for CRL version 1, and so on. The CRLs generated
1076 by gnutls should have a version number of 2.
1077
1078 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1079 negative error value.
1080 @end deftypefun
1081
1082 @subheading gnutls_x509_crl_sign2
1083 @anchor{gnutls_x509_crl_sign2}
1084 @deftypefun {int} {gnutls_x509_crl_sign2} (gnutls_x509_crl_t @var{crl}, gnutls_x509_crt_t @var{issuer}, gnutls_x509_privkey_t @var{issuer_key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
1085 @var{crl}: should contain a gnutls_x509_crl_t structure
1086
1087 @var{issuer}: is the certificate of the certificate issuer
1088
1089 @var{issuer_key}: holds the issuer's private key
1090
1091 @var{dig}: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
1092
1093 @var{flags}: must be 0
1094
1095 This function will sign the CRL with the issuer's private key, and
1096 will copy the issuer's information into the CRL.
1097
1098 This must be the last step in a certificate CRL since all
1099 the previously set parameters are now signed.
1100
1101 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1102 negative error value.
1103
1104 @strong{Deprecated:} Use @code{gnutls_x509_crl_privkey_sign()} instead.
1105 @end deftypefun
1106
1107 @subheading gnutls_x509_crl_sign
1108 @anchor{gnutls_x509_crl_sign}
1109 @deftypefun {int} {gnutls_x509_crl_sign} (gnutls_x509_crl_t @var{crl}, gnutls_x509_crt_t @var{issuer}, gnutls_x509_privkey_t @var{issuer_key})
1110 @var{crl}: should contain a gnutls_x509_crl_t structure
1111
1112 @var{issuer}: is the certificate of the certificate issuer
1113
1114 @var{issuer_key}: holds the issuer's private key
1115
1116 This function is the same a @code{gnutls_x509_crl_sign2()} with no flags, and
1117 SHA1 as the hash algorithm.
1118
1119 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1120 negative error value.
1121
1122 @strong{Deprecated:} Use @code{gnutls_x509_crl_privkey_sign()}.
1123 @end deftypefun
1124
1125 @subheading gnutls_x509_crl_verify
1126 @anchor{gnutls_x509_crl_verify}
1127 @deftypefun {int} {gnutls_x509_crl_verify} (gnutls_x509_crl_t @var{crl}, const gnutls_x509_crt_t * @var{CA_list}, int @var{CA_list_length}, unsigned int @var{flags}, unsigned int * @var{verify})
1128 @var{crl}: is the crl to be verified
1129
1130 @var{CA_list}: is a certificate list that is considered to be trusted one
1131
1132 @var{CA_list_length}: holds the number of CA certificates in CA_list
1133
1134 @var{flags}: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
1135
1136 @var{verify}: will hold the crl verification output.
1137
1138 This function will try to verify the given crl and return its status.
1139 See @code{gnutls_x509_crt_list_verify()} for a detailed description of
1140 return values.
1141
1142 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1143 negative error value.
1144 @end deftypefun
1145
1146 @subheading gnutls_x509_crq_deinit
1147 @anchor{gnutls_x509_crq_deinit}
1148 @deftypefun {void} {gnutls_x509_crq_deinit} (gnutls_x509_crq_t @var{crq})
1149 @var{crq}: The structure to be initialized
1150
1151 This function will deinitialize a PKCS@code{10} certificate request
1152 structure.
1153 @end deftypefun
1154
1155 @subheading gnutls_x509_crq_export
1156 @anchor{gnutls_x509_crq_export}
1157 @deftypefun {int} {gnutls_x509_crq_export} (gnutls_x509_crq_t @var{crq}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
1158 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1159
1160 @var{format}: the format of output params. One of PEM or DER.
1161
1162 @var{output_data}: will contain a certificate request PEM or DER encoded
1163
1164 @var{output_data_size}: holds the size of output_data (and will be
1165 replaced by the actual size of parameters)
1166
1167 This function will export the certificate request to a PEM or DER
1168 encoded PKCS10 structure.
1169
1170 If the buffer provided is not long enough to hold the output, then
1171 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will be returned and
1172 *@code{output_data_size} will be updated.
1173
1174 If the structure is PEM encoded, it will have a header of "BEGIN
1175 NEW CERTIFICATE REQUEST".
1176
1177 @strong{Return value:} In case of failure a negative value will be
1178 returned, and 0 on success.
1179 @end deftypefun
1180
1181 @subheading gnutls_x509_crq_get_attribute_by_oid
1182 @anchor{gnutls_x509_crq_get_attribute_by_oid}
1183 @deftypefun {int} {gnutls_x509_crq_get_attribute_by_oid} (gnutls_x509_crq_t @var{crq}, const char * @var{oid}, int @var{indx}, void * @var{buf}, size_t * @var{sizeof_buf})
1184 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1185
1186 @var{oid}: holds an Object Identified in zero-terminated string
1187
1188 @var{indx}: In case multiple same OIDs exist in the attribute list, this
1189 specifies which to send, use zero to get the first one
1190
1191 @var{buf}: a pointer to a structure to hold the attribute data (may be @code{NULL})
1192
1193 @var{sizeof_buf}: initially holds the size of @code{buf}
1194
1195 This function will return the attribute in the certificate request
1196 specified by the given Object ID.  The attribute will be DER
1197 encoded.
1198
1199 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1200 negative error value.
1201 @end deftypefun
1202
1203 @subheading gnutls_x509_crq_get_attribute_data
1204 @anchor{gnutls_x509_crq_get_attribute_data}
1205 @deftypefun {int} {gnutls_x509_crq_get_attribute_data} (gnutls_x509_crq_t @var{crq}, int @var{indx}, void * @var{data}, size_t * @var{sizeof_data})
1206 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1207
1208 @var{indx}: Specifies which attribute OID to send. Use zero to get the first one.
1209
1210 @var{data}: a pointer to a structure to hold the data (may be null)
1211
1212 @var{sizeof_data}: initially holds the size of @code{oid}
1213
1214 This function will return the requested attribute data in the
1215 certificate request.  The attribute data will be stored as a string in the
1216 provided buffer.
1217
1218 Use @code{gnutls_x509_crq_get_attribute_info()} to extract the OID.
1219 Use @code{gnutls_x509_crq_get_attribute_by_oid()} instead,
1220 if you want to get data indexed by the attribute OID rather than
1221 sequence.
1222
1223 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1224 negative value in case of an error.  If your have reached the
1225 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
1226 will be returned.
1227
1228 @strong{Since:} 2.8.0
1229 @end deftypefun
1230
1231 @subheading gnutls_x509_crq_get_attribute_info
1232 @anchor{gnutls_x509_crq_get_attribute_info}
1233 @deftypefun {int} {gnutls_x509_crq_get_attribute_info} (gnutls_x509_crq_t @var{crq}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
1234 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1235
1236 @var{indx}: Specifies which attribute OID to send. Use zero to get the first one.
1237
1238 @var{oid}: a pointer to a structure to hold the OID
1239
1240 @var{sizeof_oid}: initially holds the maximum size of @code{oid}, on return
1241 holds actual size of @code{oid}.
1242
1243 This function will return the requested attribute OID in the
1244 certificate, and the critical flag for it.  The attribute OID will
1245 be stored as a string in the provided buffer.  Use
1246 @code{gnutls_x509_crq_get_attribute_data()} to extract the data.
1247
1248 If the buffer provided is not long enough to hold the output, then
1249 *@code{sizeof_oid} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will be
1250 returned.
1251
1252 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1253 negative value in case of an error.  If your have reached the
1254 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
1255 will be returned.
1256
1257 @strong{Since:} 2.8.0
1258 @end deftypefun
1259
1260 @subheading gnutls_x509_crq_get_basic_constraints
1261 @anchor{gnutls_x509_crq_get_basic_constraints}
1262 @deftypefun {int} {gnutls_x509_crq_get_basic_constraints} (gnutls_x509_crq_t @var{crq}, unsigned int * @var{critical}, int * @var{ca}, int * @var{pathlen})
1263 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1264
1265 @var{critical}: will be non zero if the extension is marked as critical
1266
1267 @var{ca}: pointer to output integer indicating CA status, may be NULL,
1268 value is 1 if the certificate CA flag is set, 0 otherwise.
1269
1270 @var{pathlen}: pointer to output integer indicating path length (may be
1271 NULL), non-negative values indicate a present pathLenConstraint
1272 field and the actual value, -1 indicate that the field is absent.
1273
1274 This function will read the certificate's basic constraints, and
1275 return the certificates CA status.  It reads the basicConstraints
1276 X.509 extension (2.5.29.19).
1277
1278 @strong{Return value:} If the certificate is a CA a positive value will be
1279 returned, or zero if the certificate does not have CA flag set.
1280 A negative value may be returned in case of errors.  If the
1281 certificate does not contain the basicConstraints extension
1282 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be returned.
1283
1284 @strong{Since:} 2.8.0
1285 @end deftypefun
1286
1287 @subheading gnutls_x509_crq_get_challenge_password
1288 @anchor{gnutls_x509_crq_get_challenge_password}
1289 @deftypefun {int} {gnutls_x509_crq_get_challenge_password} (gnutls_x509_crq_t @var{crq}, char * @var{pass}, size_t * @var{sizeof_pass})
1290 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1291
1292 @var{pass}: will hold a zero-terminated password string
1293
1294 @var{sizeof_pass}: Initially holds the size of @code{pass}.
1295
1296 This function will return the challenge password in the request.
1297 The challenge password is intended to be used for requesting a
1298 revocation of the certificate.
1299
1300 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1301 negative error value.
1302 @end deftypefun
1303
1304 @subheading gnutls_x509_crq_get_dn_by_oid
1305 @anchor{gnutls_x509_crq_get_dn_by_oid}
1306 @deftypefun {int} {gnutls_x509_crq_get_dn_by_oid} (gnutls_x509_crq_t @var{crq}, const char * @var{oid}, int @var{indx}, unsigned int @var{raw_flag}, void * @var{buf}, size_t * @var{sizeof_buf})
1307 @var{crq}: should contain a gnutls_x509_crq_t structure
1308
1309 @var{oid}: holds an Object Identified in null terminated string
1310
1311 @var{indx}: In case multiple same OIDs exist in the RDN, this specifies
1312 which to send. Use zero to get the first one.
1313
1314 @var{raw_flag}: If non zero returns the raw DER data of the DN part.
1315
1316 @var{buf}: a pointer to a structure to hold the name (may be @code{NULL})
1317
1318 @var{sizeof_buf}: initially holds the size of @code{buf}
1319
1320 This function will extract the part of the name of the Certificate
1321 request subject, specified by the given OID. The output will be
1322 encoded as described in RFC2253. The output string will be ASCII
1323 or UTF-8 encoded, depending on the certificate data.
1324
1325 Some helper macros with popular OIDs can be found in gnutls/x509.h
1326 If raw flag is zero, this function will only return known OIDs as
1327 text. Other OIDs will be DER encoded, as described in RFC2253 --
1328 in hex format with a '\#' prefix.  You can check about known OIDs
1329 using @code{gnutls_x509_dn_oid_known()}.
1330
1331 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
1332 not long enough, and in that case the *@code{sizeof_buf} will be
1333 updated with the required size.  On success 0 is returned.
1334 @end deftypefun
1335
1336 @subheading gnutls_x509_crq_get_dn_oid
1337 @anchor{gnutls_x509_crq_get_dn_oid}
1338 @deftypefun {int} {gnutls_x509_crq_get_dn_oid} (gnutls_x509_crq_t @var{crq}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
1339 @var{crq}: should contain a gnutls_x509_crq_t structure
1340
1341 @var{indx}: Specifies which DN OID to send. Use zero to get the first one.
1342
1343 @var{oid}: a pointer to a structure to hold the name (may be @code{NULL})
1344
1345 @var{sizeof_oid}: initially holds the size of @code{oid}
1346
1347 This function will extract the requested OID of the name of the
1348 certificate request subject, specified by the given index.
1349
1350 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
1351 not long enough, and in that case the *@code{sizeof_oid} will be
1352 updated with the required size.  On success 0 is returned.
1353 @end deftypefun
1354
1355 @subheading gnutls_x509_crq_get_dn
1356 @anchor{gnutls_x509_crq_get_dn}
1357 @deftypefun {int} {gnutls_x509_crq_get_dn} (gnutls_x509_crq_t @var{crq}, char * @var{buf}, size_t * @var{sizeof_buf})
1358 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1359
1360 @var{buf}: a pointer to a structure to hold the name (may be @code{NULL})
1361
1362 @var{sizeof_buf}: initially holds the size of @code{buf}
1363
1364 This function will copy the name of the Certificate request subject
1365 to the provided buffer.  The name will be in the form
1366 "C=xxxx,O=yyyy,CN=zzzz" as described in RFC 2253. The output string
1367 @code{buf} will be ASCII or UTF-8 encoded, depending on the certificate
1368 data.
1369
1370 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is not
1371 long enough, and in that case the *@code{sizeof_buf} will be updated with
1372 the required size.  On success 0 is returned.
1373 @end deftypefun
1374
1375 @subheading gnutls_x509_crq_get_extension_by_oid
1376 @anchor{gnutls_x509_crq_get_extension_by_oid}
1377 @deftypefun {int} {gnutls_x509_crq_get_extension_by_oid} (gnutls_x509_crq_t @var{crq}, const char * @var{oid}, int @var{indx}, void * @var{buf}, size_t * @var{sizeof_buf}, unsigned int * @var{critical})
1378 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1379
1380 @var{oid}: holds an Object Identified in null terminated string
1381
1382 @var{indx}: In case multiple same OIDs exist in the extensions, this
1383 specifies which to send. Use zero to get the first one.
1384
1385 @var{buf}: a pointer to a structure to hold the name (may be null)
1386
1387 @var{sizeof_buf}: initially holds the size of @code{buf}
1388
1389 @var{critical}: will be non zero if the extension is marked as critical
1390
1391 This function will return the extension specified by the OID in
1392 the certificate.  The extensions will be returned as binary data
1393 DER encoded, in the provided buffer.
1394
1395 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1396 negative value in case of an error.  If the certificate does not
1397 contain the specified extension
1398 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be returned.
1399
1400 @strong{Since:} 2.8.0
1401 @end deftypefun
1402
1403 @subheading gnutls_x509_crq_get_extension_data
1404 @anchor{gnutls_x509_crq_get_extension_data}
1405 @deftypefun {int} {gnutls_x509_crq_get_extension_data} (gnutls_x509_crq_t @var{crq}, int @var{indx}, void * @var{data}, size_t * @var{sizeof_data})
1406 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1407
1408 @var{indx}: Specifies which extension OID to send. Use zero to get the first one.
1409
1410 @var{data}: a pointer to a structure to hold the data (may be null)
1411
1412 @var{sizeof_data}: initially holds the size of @code{oid}
1413
1414 This function will return the requested extension data in the
1415 certificate.  The extension data will be stored as a string in the
1416 provided buffer.
1417
1418 Use @code{gnutls_x509_crq_get_extension_info()} to extract the OID and
1419 critical flag.  Use @code{gnutls_x509_crq_get_extension_by_oid()} instead,
1420 if you want to get data indexed by the extension OID rather than
1421 sequence.
1422
1423 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1424 negative value in case of an error.  If your have reached the
1425 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
1426 will be returned.
1427
1428 @strong{Since:} 2.8.0
1429 @end deftypefun
1430
1431 @subheading gnutls_x509_crq_get_extension_info
1432 @anchor{gnutls_x509_crq_get_extension_info}
1433 @deftypefun {int} {gnutls_x509_crq_get_extension_info} (gnutls_x509_crq_t @var{crq}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid}, int * @var{critical})
1434 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1435
1436 @var{indx}: Specifies which extension OID to send. Use zero to get the first one.
1437
1438 @var{oid}: a pointer to a structure to hold the OID
1439
1440 @var{sizeof_oid}: initially holds the maximum size of @code{oid}, on return
1441 holds actual size of @code{oid}.
1442
1443 @var{critical}: output variable with critical flag, may be NULL.
1444
1445 This function will return the requested extension OID in the
1446 certificate, and the critical flag for it.  The extension OID will
1447 be stored as a string in the provided buffer.  Use
1448 @code{gnutls_x509_crq_get_extension_data()} to extract the data.
1449
1450 If the buffer provided is not long enough to hold the output, then
1451 *@code{sizeof_oid} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will be
1452 returned.
1453
1454 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1455 negative value in case of an error.  If your have reached the
1456 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
1457 will be returned.
1458
1459 @strong{Since:} 2.8.0
1460 @end deftypefun
1461
1462 @subheading gnutls_x509_crq_get_key_id
1463 @anchor{gnutls_x509_crq_get_key_id}
1464 @deftypefun {int} {gnutls_x509_crq_get_key_id} (gnutls_x509_crq_t @var{crq}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size})
1465 @var{crq}: a certificate of type @code{gnutls_x509_crq_t}
1466
1467 @var{flags}: should be 0 for now
1468
1469 @var{output_data}: will contain the key ID
1470
1471 @var{output_data_size}: holds the size of output_data (and will be
1472 replaced by the actual size of parameters)
1473
1474 This function will return a unique ID the depends on the public key
1475 parameters.  This ID can be used in checking whether a certificate
1476 corresponds to the given private key.
1477
1478 If the buffer provided is not long enough to hold the output, then
1479 *@code{output_data_size} is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
1480 be returned.  The output will normally be a SHA-1 hash output,
1481 which is 20 bytes.
1482
1483 @strong{Return value:} In case of failure a negative value will be
1484 returned, and 0 on success.
1485
1486 @strong{Since:} 2.8.0
1487 @end deftypefun
1488
1489 @subheading gnutls_x509_crq_get_key_purpose_oid
1490 @anchor{gnutls_x509_crq_get_key_purpose_oid}
1491 @deftypefun {int} {gnutls_x509_crq_get_key_purpose_oid} (gnutls_x509_crq_t @var{crq}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid}, unsigned int * @var{critical})
1492 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1493
1494 @var{indx}: This specifies which OID to return, use zero to get the first one
1495
1496 @var{oid}: a pointer to a buffer to hold the OID (may be @code{NULL})
1497
1498 @var{sizeof_oid}: initially holds the size of @code{oid}
1499
1500 @var{critical}: output variable with critical flag, may be @code{NULL}.
1501
1502 This function will extract the key purpose OIDs of the Certificate
1503 specified by the given index.  These are stored in the Extended Key
1504 Usage extension (2.5.29.37).  See the GNUTLS_KP_* definitions for
1505 human readable names.
1506
1507 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
1508 not long enough, and in that case the *@code{sizeof_oid} will be
1509 updated with the required size.  On success 0 is returned.
1510
1511 @strong{Since:} 2.8.0
1512 @end deftypefun
1513
1514 @subheading gnutls_x509_crq_get_key_rsa_raw
1515 @anchor{gnutls_x509_crq_get_key_rsa_raw}
1516 @deftypefun {int} {gnutls_x509_crq_get_key_rsa_raw} (gnutls_x509_crq_t @var{crq}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e})
1517 @var{crq}: Holds the certificate
1518
1519 @var{m}: will hold the modulus
1520
1521 @var{e}: will hold the public exponent
1522
1523 This function will export the RSA public key's parameters found in
1524 the given structure.  The new parameters will be allocated using
1525 @code{gnutls_malloc()} and will be stored in the appropriate datum.
1526
1527 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1528 negative error value.
1529
1530 @strong{Since:} 2.8.0
1531 @end deftypefun
1532
1533 @subheading gnutls_x509_crq_get_key_usage
1534 @anchor{gnutls_x509_crq_get_key_usage}
1535 @deftypefun {int} {gnutls_x509_crq_get_key_usage} (gnutls_x509_crq_t @var{crq}, unsigned int * @var{key_usage}, unsigned int * @var{critical})
1536 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1537
1538 @var{key_usage}: where the key usage bits will be stored
1539
1540 @var{critical}: will be non zero if the extension is marked as critical
1541
1542 This function will return certificate's key usage, by reading the
1543 keyUsage X.509 extension (2.5.29.15).  The key usage value will
1544
1545 @strong{ORed values of the:} @code{GNUTLS_KEY_DIGITAL_SIGNATURE},
1546 @code{GNUTLS_KEY_NON_REPUDIATION}, @code{GNUTLS_KEY_KEY_ENCIPHERMENT},
1547 @code{GNUTLS_KEY_DATA_ENCIPHERMENT}, @code{GNUTLS_KEY_KEY_AGREEMENT},
1548 @code{GNUTLS_KEY_KEY_CERT_SIGN}, @code{GNUTLS_KEY_CRL_SIGN},
1549 @code{GNUTLS_KEY_ENCIPHER_ONLY}, @code{GNUTLS_KEY_DECIPHER_ONLY}.
1550
1551 @strong{Returns:} the certificate key usage, or a negative value in case of
1552 parsing error.  If the certificate does not contain the keyUsage
1553 extension @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be
1554 returned.
1555
1556 @strong{Since:} 2.8.0
1557 @end deftypefun
1558
1559 @subheading gnutls_x509_crq_get_pk_algorithm
1560 @anchor{gnutls_x509_crq_get_pk_algorithm}
1561 @deftypefun {int} {gnutls_x509_crq_get_pk_algorithm} (gnutls_x509_crq_t @var{crq}, unsigned int * @var{bits})
1562 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1563
1564 @var{bits}: if bits is non-@code{NULL} it will hold the size of the parameters' in bits
1565
1566 This function will return the public key algorithm of a PKCS@code{10}
1567 certificate request.
1568
1569 If bits is non-@code{NULL}, it should have enough size to hold the
1570 parameters size in bits.  For RSA the bits returned is the modulus.
1571 For DSA the bits returned are of the public exponent.
1572
1573 @strong{Returns:} a member of the @code{gnutls_pk_algorithm_t} enumeration on
1574 success, or a negative value on error.
1575 @end deftypefun
1576
1577 @subheading gnutls_x509_crq_get_subject_alt_name
1578 @anchor{gnutls_x509_crq_get_subject_alt_name}
1579 @deftypefun {int} {gnutls_x509_crq_get_subject_alt_name} (gnutls_x509_crq_t @var{crq}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{ret_type}, unsigned int * @var{critical})
1580 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1581
1582 @var{seq}: specifies the sequence number of the alt name, 0 for the
1583 first one, 1 for the second etc.
1584
1585 @var{ret}: is the place where the alternative name will be copied to
1586
1587 @var{ret_size}: holds the size of ret.
1588
1589 @var{ret_type}: holds the @code{gnutls_x509_subject_alt_name_t} name type
1590
1591 @var{critical}: will be non zero if the extension is marked as critical
1592 (may be null)
1593
1594 This function will return the alternative names, contained in the
1595 given certificate.  It is the same as
1596 @code{gnutls_x509_crq_get_subject_alt_name()} except for the fact that it
1597 will return the type of the alternative name in @code{ret_type} even if
1598 the function fails for some reason (i.e.  the buffer provided is
1599 not enough).
1600
1601 @strong{Returns:} the alternative subject name type on success, one of the
1602 enumerated @code{gnutls_x509_subject_alt_name_t}.  It will return
1603 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if @code{ret_size} is not large enough to
1604 hold the value.  In that case @code{ret_size} will be updated with the
1605 required size.  If the certificate request does not have an
1606 Alternative name with the specified sequence number then
1607 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
1608
1609 @strong{Since:} 2.8.0
1610 @end deftypefun
1611
1612 @subheading gnutls_x509_crq_get_subject_alt_othername_oid
1613 @anchor{gnutls_x509_crq_get_subject_alt_othername_oid}
1614 @deftypefun {int} {gnutls_x509_crq_get_subject_alt_othername_oid} (gnutls_x509_crq_t @var{crq}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size})
1615 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1616
1617 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
1618
1619 @var{ret}: is the place where the otherName OID will be copied to
1620
1621 @var{ret_size}: holds the size of ret.
1622
1623 This function will extract the type OID of an otherName Subject
1624 Alternative Name, contained in the given certificate, and return
1625 the type as an enumerated element.
1626
1627 This function is only useful if
1628 @code{gnutls_x509_crq_get_subject_alt_name()} returned
1629 @code{GNUTLS_SAN_OTHERNAME}.
1630
1631 @strong{Returns:} the alternative subject name type on success, one of the
1632 enumerated gnutls_x509_subject_alt_name_t.  For supported OIDs,
1633 it will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types,
1634 e.g. @code{GNUTLS_SAN_OTHERNAME_XMPP}, and @code{GNUTLS_SAN_OTHERNAME} for
1635 unknown OIDs.  It will return @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if
1636 @code{ret_size} is not large enough to hold the value.  In that case
1637 @code{ret_size} will be updated with the required size.  If the
1638 certificate does not have an Alternative name with the specified
1639 sequence number and with the otherName type then
1640 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
1641
1642 @strong{Since:} 2.8.0
1643 @end deftypefun
1644
1645 @subheading gnutls_x509_crq_get_version
1646 @anchor{gnutls_x509_crq_get_version}
1647 @deftypefun {int} {gnutls_x509_crq_get_version} (gnutls_x509_crq_t @var{crq})
1648 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1649
1650 This function will return the version of the specified Certificate
1651 request.
1652
1653 @strong{Returns:} version of certificate request, or a negative value on
1654 error.
1655 @end deftypefun
1656
1657 @subheading gnutls_x509_crq_import
1658 @anchor{gnutls_x509_crq_import}
1659 @deftypefun {int} {gnutls_x509_crq_import} (gnutls_x509_crq_t @var{crq}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
1660 @var{crq}: The structure to store the parsed certificate request.
1661
1662 @var{data}: The DER or PEM encoded certificate.
1663
1664 @var{format}: One of DER or PEM
1665
1666 This function will convert the given DER or PEM encoded certificate
1667 request to a @code{gnutls_x509_crq_t} structure.  The output will be
1668 stored in @code{crq}.
1669
1670 If the Certificate is PEM encoded it should have a header of "NEW
1671 CERTIFICATE REQUEST".
1672
1673 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1674 negative error value.
1675 @end deftypefun
1676
1677 @subheading gnutls_x509_crq_init
1678 @anchor{gnutls_x509_crq_init}
1679 @deftypefun {int} {gnutls_x509_crq_init} (gnutls_x509_crq_t * @var{crq})
1680 @var{crq}: The structure to be initialized
1681
1682 This function will initialize a PKCS@code{10} certificate request
1683 structure.
1684
1685 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1686 negative error value.
1687 @end deftypefun
1688
1689 @subheading gnutls_x509_crq_print
1690 @anchor{gnutls_x509_crq_print}
1691 @deftypefun {int} {gnutls_x509_crq_print} (gnutls_x509_crq_t @var{crq}, gnutls_certificate_print_formats_t @var{format}, gnutls_datum_t * @var{out})
1692 @var{crq}: The structure to be printed
1693
1694 @var{format}: Indicate the format to use
1695
1696 @var{out}: Newly allocated datum with zero terminated string.
1697
1698 This function will pretty print a certificate request, suitable for
1699 display to a human.
1700
1701 The output @code{out} needs to be deallocate using @code{gnutls_free()}.
1702
1703 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1704 negative error value.
1705
1706 @strong{Since:} 2.8.0
1707 @end deftypefun
1708
1709 @subheading gnutls_x509_crq_privkey_sign
1710 @anchor{gnutls_x509_crq_privkey_sign}
1711 @deftypefun {int} {gnutls_x509_crq_privkey_sign} (gnutls_x509_crq_t @var{crq}, gnutls_privkey_t @var{key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
1712 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1713
1714 @var{key}: holds a private key
1715
1716 @var{dig}: The message digest to use, i.e., @code{GNUTLS_DIG_SHA1}
1717
1718 @var{flags}: must be 0
1719
1720 This function will sign the certificate request with a private key.
1721 This must be the same key as the one used in
1722 @code{gnutls_x509_crt_set_key()} since a certificate request is self
1723 signed.
1724
1725 This must be the last step in a certificate request generation
1726 since all the previously set parameters are now signed.
1727
1728 @strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
1729 @code{GNUTLS_E_ASN1_VALUE_NOT_FOUND} is returned if you didn't set all
1730 information in the certificate request (e.g., the version using
1731 @code{gnutls_x509_crq_set_version()}).
1732 @end deftypefun
1733
1734 @subheading gnutls_x509_crq_set_attribute_by_oid
1735 @anchor{gnutls_x509_crq_set_attribute_by_oid}
1736 @deftypefun {int} {gnutls_x509_crq_set_attribute_by_oid} (gnutls_x509_crq_t @var{crq}, const char * @var{oid}, void * @var{buf}, size_t @var{sizeof_buf})
1737 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1738
1739 @var{oid}: holds an Object Identified in zero-terminated string
1740
1741 @var{buf}: a pointer to a structure that holds the attribute data
1742
1743 @var{sizeof_buf}: holds the size of @code{buf}
1744
1745 This function will set the attribute in the certificate request
1746 specified by the given Object ID.  The attribute must be be DER
1747 encoded.
1748
1749 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1750 negative error value.
1751 @end deftypefun
1752
1753 @subheading gnutls_x509_crq_set_basic_constraints
1754 @anchor{gnutls_x509_crq_set_basic_constraints}
1755 @deftypefun {int} {gnutls_x509_crq_set_basic_constraints} (gnutls_x509_crq_t @var{crq}, unsigned int @var{ca}, int @var{pathLenConstraint})
1756 @var{crq}: a certificate request of type @code{gnutls_x509_crq_t}
1757
1758 @var{ca}: true(1) or false(0) depending on the Certificate authority status.
1759
1760 @var{pathLenConstraint}: non-negative values indicate maximum length of path,
1761 and negative values indicate that the pathLenConstraints field should
1762 not be present.
1763
1764 This function will set the basicConstraints certificate extension.
1765
1766 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1767 negative error value.
1768
1769 @strong{Since:} 2.8.0
1770 @end deftypefun
1771
1772 @subheading gnutls_x509_crq_set_challenge_password
1773 @anchor{gnutls_x509_crq_set_challenge_password}
1774 @deftypefun {int} {gnutls_x509_crq_set_challenge_password} (gnutls_x509_crq_t @var{crq}, const char * @var{pass})
1775 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1776
1777 @var{pass}: holds a zero-terminated password
1778
1779 This function will set a challenge password to be used when
1780 revoking the request.
1781
1782 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1783 negative error value.
1784 @end deftypefun
1785
1786 @subheading gnutls_x509_crq_set_dn_by_oid
1787 @anchor{gnutls_x509_crq_set_dn_by_oid}
1788 @deftypefun {int} {gnutls_x509_crq_set_dn_by_oid} (gnutls_x509_crq_t @var{crq}, const char * @var{oid}, unsigned int @var{raw_flag}, const void * @var{data}, unsigned int @var{sizeof_data})
1789 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1790
1791 @var{oid}: holds an Object Identifier in a zero-terminated string
1792
1793 @var{raw_flag}: must be 0, or 1 if the data are DER encoded
1794
1795 @var{data}: a pointer to the input data
1796
1797 @var{sizeof_data}: holds the size of @code{data}
1798
1799 This function will set the part of the name of the Certificate
1800 request subject, specified by the given OID.  The input string
1801 should be ASCII or UTF-8 encoded.
1802
1803 Some helper macros with popular OIDs can be found in gnutls/x509.h
1804 With this function you can only set the known OIDs.  You can test
1805 for known OIDs using @code{gnutls_x509_dn_oid_known()}.  For OIDs that are
1806 not known (by gnutls) you should properly DER encode your data, and
1807 call this function with raw_flag set.
1808
1809 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1810 negative error value.
1811 @end deftypefun
1812
1813 @subheading gnutls_x509_crq_set_key_purpose_oid
1814 @anchor{gnutls_x509_crq_set_key_purpose_oid}
1815 @deftypefun {int} {gnutls_x509_crq_set_key_purpose_oid} (gnutls_x509_crq_t @var{crq}, const void * @var{oid}, unsigned int @var{critical})
1816 @var{crq}: a certificate of type @code{gnutls_x509_crq_t}
1817
1818 @var{oid}: a pointer to a zero-terminated string that holds the OID
1819
1820 @var{critical}: Whether this extension will be critical or not
1821
1822 This function will set the key purpose OIDs of the Certificate.
1823 These are stored in the Extended Key Usage extension (2.5.29.37)
1824 See the GNUTLS_KP_* definitions for human readable names.
1825
1826 Subsequent calls to this function will append OIDs to the OID list.
1827
1828 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1829 negative error value.
1830
1831 @strong{Since:} 2.8.0
1832 @end deftypefun
1833
1834 @subheading gnutls_x509_crq_set_key_rsa_raw
1835 @anchor{gnutls_x509_crq_set_key_rsa_raw}
1836 @deftypefun {int} {gnutls_x509_crq_set_key_rsa_raw} (gnutls_x509_crq_t @var{crq}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e})
1837 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1838
1839 @var{m}: holds the modulus
1840
1841 @var{e}: holds the public exponent
1842
1843 This function will set the public parameters from the given private
1844 key to the request. Only RSA keys are currently supported.
1845
1846 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1847 negative error value.
1848
1849 @strong{Since:} 2.6.0
1850 @end deftypefun
1851
1852 @subheading gnutls_x509_crq_set_key_usage
1853 @anchor{gnutls_x509_crq_set_key_usage}
1854 @deftypefun {int} {gnutls_x509_crq_set_key_usage} (gnutls_x509_crq_t @var{crq}, unsigned int @var{usage})
1855 @var{crq}: a certificate request of type @code{gnutls_x509_crq_t}
1856
1857 @var{usage}: an ORed sequence of the GNUTLS_KEY_* elements.
1858
1859 This function will set the keyUsage certificate extension.
1860
1861 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1862 negative error value.
1863
1864 @strong{Since:} 2.8.0
1865 @end deftypefun
1866
1867 @subheading gnutls_x509_crq_set_key
1868 @anchor{gnutls_x509_crq_set_key}
1869 @deftypefun {int} {gnutls_x509_crq_set_key} (gnutls_x509_crq_t @var{crq}, gnutls_x509_privkey_t @var{key})
1870 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1871
1872 @var{key}: holds a private key
1873
1874 This function will set the public parameters from the given private
1875 key to the request.  Only RSA keys are currently supported.
1876
1877 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1878 negative error value.
1879 @end deftypefun
1880
1881 @subheading gnutls_x509_crq_set_subject_alt_name
1882 @anchor{gnutls_x509_crq_set_subject_alt_name}
1883 @deftypefun {int} {gnutls_x509_crq_set_subject_alt_name} (gnutls_x509_crq_t @var{crq}, gnutls_x509_subject_alt_name_t @var{nt}, const void * @var{data}, unsigned int @var{data_size}, unsigned int @var{flags})
1884 @var{crq}: a certificate request of type @code{gnutls_x509_crq_t}
1885
1886 @var{nt}: is one of the @code{gnutls_x509_subject_alt_name_t} enumerations
1887
1888 @var{data}: The data to be set
1889
1890 @var{data_size}: The size of data to be set
1891
1892 @var{flags}: @code{GNUTLS_FSAN_SET} to clear previous data or
1893 @code{GNUTLS_FSAN_APPEND} to append.
1894
1895 This function will set the subject alternative name certificate
1896 extension.  It can set the following types:
1897
1898 &GNUTLS_SAN_DNSNAME: as a text string
1899
1900 &GNUTLS_SAN_RFC822NAME: as a text string
1901
1902 &GNUTLS_SAN_URI: as a text string
1903
1904 &GNUTLS_SAN_IPADDRESS: as a binary IP address (4 or 16 bytes)
1905
1906 Other values can be set as binary values with the proper DER encoding.
1907
1908 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1909 negative error value.
1910
1911 @strong{Since:} 2.8.0
1912 @end deftypefun
1913
1914 @subheading gnutls_x509_crq_set_version
1915 @anchor{gnutls_x509_crq_set_version}
1916 @deftypefun {int} {gnutls_x509_crq_set_version} (gnutls_x509_crq_t @var{crq}, unsigned int @var{version})
1917 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1918
1919 @var{version}: holds the version number, for v1 Requests must be 1
1920
1921 This function will set the version of the certificate request.  For
1922 version 1 requests this must be one.
1923
1924 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1925 negative error value.
1926 @end deftypefun
1927
1928 @subheading gnutls_x509_crq_sign2
1929 @anchor{gnutls_x509_crq_sign2}
1930 @deftypefun {int} {gnutls_x509_crq_sign2} (gnutls_x509_crq_t @var{crq}, gnutls_x509_privkey_t @var{key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
1931 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1932
1933 @var{key}: holds a private key
1934
1935 @var{dig}: The message digest to use, i.e., @code{GNUTLS_DIG_SHA1}
1936
1937 @var{flags}: must be 0
1938
1939 This function will sign the certificate request with a private key.
1940 This must be the same key as the one used in
1941 @code{gnutls_x509_crt_set_key()} since a certificate request is self
1942 signed.
1943
1944 This must be the last step in a certificate request generation
1945 since all the previously set parameters are now signed.
1946
1947 @strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
1948 @code{GNUTLS_E_ASN1_VALUE_NOT_FOUND} is returned if you didn't set all
1949 information in the certificate request (e.g., the version using
1950 @code{gnutls_x509_crq_set_version()}).
1951
1952 @strong{Deprecated:} Use @code{gnutls_x509_crq_privkey_sign()} instead.
1953 @end deftypefun
1954
1955 @subheading gnutls_x509_crq_sign
1956 @anchor{gnutls_x509_crq_sign}
1957 @deftypefun {int} {gnutls_x509_crq_sign} (gnutls_x509_crq_t @var{crq}, gnutls_x509_privkey_t @var{key})
1958 @var{crq}: should contain a @code{gnutls_x509_crq_t} structure
1959
1960 @var{key}: holds a private key
1961
1962 This function is the same a @code{gnutls_x509_crq_sign2()} with no flags,
1963 and SHA1 as the hash algorithm.
1964
1965 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
1966 negative error value.
1967
1968 @strong{Deprecated:} Use @code{gnutls_x509_crq_privkey_sign()} instead.
1969 @end deftypefun
1970
1971 @subheading gnutls_x509_crq_verify
1972 @anchor{gnutls_x509_crq_verify}
1973 @deftypefun {int} {gnutls_x509_crq_verify} (gnutls_x509_crq_t @var{crq}, unsigned int @var{flags})
1974 @var{crq}: is the crq to be verified
1975
1976 @var{flags}: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
1977
1978 This function will verify self signature in the certificate
1979 request and return its status.
1980
1981 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}
1982 if verification failed, otherwise a negative error value.
1983 @end deftypefun
1984
1985 @subheading gnutls_x509_crt_check_hostname
1986 @anchor{gnutls_x509_crt_check_hostname}
1987 @deftypefun {int} {gnutls_x509_crt_check_hostname} (gnutls_x509_crt_t @var{cert}, const char * @var{hostname})
1988 @var{cert}: should contain an gnutls_x509_crt_t structure
1989
1990 @var{hostname}: A null terminated string that contains a DNS name
1991
1992 This function will check if the given certificate's subject matches
1993 the given hostname.  This is a basic implementation of the matching
1994 described in RFC2818 (HTTPS), which takes into account wildcards,
1995 and the DNSName/IPAddress subject alternative name PKIX extension.
1996
1997 @strong{Returns:} non zero for a successful match, and zero on failure.
1998 @end deftypefun
1999
2000 @subheading gnutls_x509_crt_check_issuer
2001 @anchor{gnutls_x509_crt_check_issuer}
2002 @deftypefun {int} {gnutls_x509_crt_check_issuer} (gnutls_x509_crt_t @var{cert}, gnutls_x509_crt_t @var{issuer})
2003 @var{cert}: is the certificate to be checked
2004
2005 @var{issuer}: is the certificate of a possible issuer
2006
2007 This function will check if the given certificate was issued by the
2008 given issuer. It checks the DN fields and the authority
2009 key identifier and subject key identifier fields match.
2010
2011 @strong{Returns:} It will return true (1) if the given certificate is issued
2012 by the given issuer, and false (0) if not.  A negative value is
2013 returned in case of an error.
2014 @end deftypefun
2015
2016 @subheading gnutls_x509_crt_check_revocation
2017 @anchor{gnutls_x509_crt_check_revocation}
2018 @deftypefun {int} {gnutls_x509_crt_check_revocation} (gnutls_x509_crt_t @var{cert}, const gnutls_x509_crl_t * @var{crl_list}, int @var{crl_list_length})
2019 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2020
2021 @var{crl_list}: should contain a list of gnutls_x509_crl_t structures
2022
2023 @var{crl_list_length}: the length of the crl_list
2024
2025 This function will return check if the given certificate is
2026 revoked.  It is assumed that the CRLs have been verified before.
2027
2028 @strong{Returns:} 0 if the certificate is NOT revoked, and 1 if it is.  A
2029 negative value is returned on error.
2030 @end deftypefun
2031
2032 @subheading gnutls_x509_crt_cpy_crl_dist_points
2033 @anchor{gnutls_x509_crt_cpy_crl_dist_points}
2034 @deftypefun {int} {gnutls_x509_crt_cpy_crl_dist_points} (gnutls_x509_crt_t @var{dst}, gnutls_x509_crt_t @var{src})
2035 @var{dst}: a certificate of type @code{gnutls_x509_crt_t}
2036
2037 @var{src}: the certificate where the dist points will be copied from
2038
2039 This function will copy the CRL distribution points certificate
2040 extension, from the source to the destination certificate.
2041 This may be useful to copy from a CA certificate to issued ones.
2042
2043 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2044 negative error value.
2045 @end deftypefun
2046
2047 @subheading gnutls_x509_crt_deinit
2048 @anchor{gnutls_x509_crt_deinit}
2049 @deftypefun {void} {gnutls_x509_crt_deinit} (gnutls_x509_crt_t @var{cert})
2050 @var{cert}: The structure to be deinitialized
2051
2052 This function will deinitialize a certificate structure.
2053 @end deftypefun
2054
2055 @subheading gnutls_x509_crt_export
2056 @anchor{gnutls_x509_crt_export}
2057 @deftypefun {int} {gnutls_x509_crt_export} (gnutls_x509_crt_t @var{cert}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
2058 @var{cert}: Holds the certificate
2059
2060 @var{format}: the format of output params. One of PEM or DER.
2061
2062 @var{output_data}: will contain a certificate PEM or DER encoded
2063
2064 @var{output_data_size}: holds the size of output_data (and will be
2065 replaced by the actual size of parameters)
2066
2067 This function will export the certificate to DER or PEM format.
2068
2069 If the buffer provided is not long enough to hold the output, then
2070 *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
2071 be returned.
2072
2073 If the structure is PEM encoded, it will have a header
2074 of "BEGIN CERTIFICATE".
2075
2076 @strong{Return value:} In case of failure a negative value will be
2077 returned, and 0 on success.
2078 @end deftypefun
2079
2080 @subheading gnutls_x509_crt_get_activation_time
2081 @anchor{gnutls_x509_crt_get_activation_time}
2082 @deftypefun {time_t} {gnutls_x509_crt_get_activation_time} (gnutls_x509_crt_t @var{cert})
2083 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2084
2085 This function will return the time this Certificate was or will be
2086 activated.
2087
2088 @strong{Returns:} activation time, or (time_t)-1 on error.
2089 @end deftypefun
2090
2091 @subheading gnutls_x509_crt_get_authority_key_id
2092 @anchor{gnutls_x509_crt_get_authority_key_id}
2093 @deftypefun {int} {gnutls_x509_crt_get_authority_key_id} (gnutls_x509_crt_t @var{cert}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{critical})
2094 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2095
2096 @var{ret}: The place where the identifier will be copied
2097
2098 @var{ret_size}: Holds the size of the result field.
2099
2100 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2101
2102 This function will return the X.509v3 certificate authority's key
2103 identifier.  This is obtained by the X.509 Authority Key
2104 identifier extension field (2.5.29.35). Note that this function
2105 only returns the keyIdentifier field of the extension.
2106
2107 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2108 negative error value.
2109 @end deftypefun
2110
2111 @subheading gnutls_x509_crt_get_basic_constraints
2112 @anchor{gnutls_x509_crt_get_basic_constraints}
2113 @deftypefun {int} {gnutls_x509_crt_get_basic_constraints} (gnutls_x509_crt_t @var{cert}, unsigned int * @var{critical}, int * @var{ca}, int * @var{pathlen})
2114 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2115
2116 @var{critical}: will be non zero if the extension is marked as critical
2117
2118 @var{ca}: pointer to output integer indicating CA status, may be NULL,
2119 value is 1 if the certificate CA flag is set, 0 otherwise.
2120
2121 @var{pathlen}: pointer to output integer indicating path length (may be
2122 NULL), non-negative values indicate a present pathLenConstraint
2123 field and the actual value, -1 indicate that the field is absent.
2124
2125 This function will read the certificate's basic constraints, and
2126 return the certificates CA status.  It reads the basicConstraints
2127 X.509 extension (2.5.29.19).
2128
2129 @strong{Return value:} If the certificate is a CA a positive value will be
2130 returned, or zero if the certificate does not have CA flag set.  A
2131 negative value may be returned in case of errors.  If the
2132 certificate does not contain the basicConstraints extension
2133 GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
2134 @end deftypefun
2135
2136 @subheading gnutls_x509_crt_get_ca_status
2137 @anchor{gnutls_x509_crt_get_ca_status}
2138 @deftypefun {int} {gnutls_x509_crt_get_ca_status} (gnutls_x509_crt_t @var{cert}, unsigned int * @var{critical})
2139 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2140
2141 @var{critical}: will be non zero if the extension is marked as critical
2142
2143 This function will return certificates CA status, by reading the
2144 basicConstraints X.509 extension (2.5.29.19). If the certificate is
2145 a CA a positive value will be returned, or zero if the certificate
2146 does not have CA flag set.
2147
2148 Use @code{gnutls_x509_crt_get_basic_constraints()} if you want to read the
2149 pathLenConstraint field too.
2150
2151 @strong{Returns:} A negative value may be returned in case of parsing error.
2152 If the certificate does not contain the basicConstraints extension
2153 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be returned.
2154 @end deftypefun
2155
2156 @subheading gnutls_x509_crt_get_crl_dist_points
2157 @anchor{gnutls_x509_crt_get_crl_dist_points}
2158 @deftypefun {int} {gnutls_x509_crt_get_crl_dist_points} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{reason_flags}, unsigned int * @var{critical})
2159 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2160
2161 @var{seq}: specifies the sequence number of the distribution point (0 for the first one, 1 for the second etc.)
2162
2163 @var{ret}: is the place where the distribution point will be copied to
2164
2165 @var{ret_size}: holds the size of ret.
2166
2167 @var{reason_flags}: Revocation reasons flags.
2168
2169 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2170
2171 This function retrieves the CRL distribution points (2.5.29.31),
2172 contained in the given certificate in the X509v3 Certificate
2173 Extensions.
2174
2175 @code{reason_flags} should be an ORed sequence of
2176 @code{GNUTLS_CRL_REASON_UNUSED}, @code{GNUTLS_CRL_REASON_KEY_COMPROMISE},
2177 @code{GNUTLS_CRL_REASON_CA_COMPROMISE},
2178 @code{GNUTLS_CRL_REASON_AFFILIATION_CHANGED},
2179 @code{GNUTLS_CRL_REASON_SUPERSEEDED},
2180 @code{GNUTLS_CRL_REASON_CESSATION_OF_OPERATION},
2181 @code{GNUTLS_CRL_REASON_CERTIFICATE_HOLD},
2182 @code{GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN},
2183 @code{GNUTLS_CRL_REASON_AA_COMPROMISE}, or zero for all possible reasons.
2184
2185 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} and updates &@code{ret_size} if
2186 &@code{ret_size} is not enough to hold the distribution point, or the
2187 type of the distribution point if everything was ok. The type is
2188 one of the enumerated @code{gnutls_x509_subject_alt_name_t}.  If the
2189 certificate does not have an Alternative name with the specified
2190 sequence number then @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is
2191 returned.
2192 @end deftypefun
2193
2194 @subheading gnutls_x509_crt_get_dn_by_oid
2195 @anchor{gnutls_x509_crt_get_dn_by_oid}
2196 @deftypefun {int} {gnutls_x509_crt_get_dn_by_oid} (gnutls_x509_crt_t @var{cert}, const char * @var{oid}, int @var{indx}, unsigned int @var{raw_flag}, void * @var{buf}, size_t * @var{sizeof_buf})
2197 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2198
2199 @var{oid}: holds an Object Identified in null terminated string
2200
2201 @var{indx}: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
2202
2203 @var{raw_flag}: If non zero returns the raw DER data of the DN part.
2204
2205 @var{buf}: a pointer where the DN part will be copied (may be null).
2206
2207 @var{sizeof_buf}: initially holds the size of @code{buf}
2208
2209 This function will extract the part of the name of the Certificate
2210 subject specified by the given OID. The output, if the raw flag is
2211 not used, will be encoded as described in RFC2253. Thus a string
2212 that is ASCII or UTF-8 encoded, depending on the certificate data.
2213
2214 Some helper macros with popular OIDs can be found in gnutls/x509.h
2215 If raw flag is zero, this function will only return known OIDs as
2216 text. Other OIDs will be DER encoded, as described in RFC2253 --
2217 in hex format with a '\#' prefix.  You can check about known OIDs
2218 using @code{gnutls_x509_dn_oid_known()}.
2219
2220 If @code{buf} is null then only the size will be filled.
2221
2222 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
2223 not long enough, and in that case the *sizeof_buf will be updated
2224 with the required size.  On success 0 is returned.
2225 @end deftypefun
2226
2227 @subheading gnutls_x509_crt_get_dn_oid
2228 @anchor{gnutls_x509_crt_get_dn_oid}
2229 @deftypefun {int} {gnutls_x509_crt_get_dn_oid} (gnutls_x509_crt_t @var{cert}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
2230 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2231
2232 @var{indx}: This specifies which OID to return. Use zero to get the first one.
2233
2234 @var{oid}: a pointer to a buffer to hold the OID (may be null)
2235
2236 @var{sizeof_oid}: initially holds the size of @code{oid}
2237
2238 This function will extract the OIDs of the name of the Certificate
2239 subject specified by the given index.
2240
2241 If oid is null then only the size will be filled.
2242
2243 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
2244 not long enough, and in that case the *sizeof_oid will be updated
2245 with the required size.  On success 0 is returned.
2246 @end deftypefun
2247
2248 @subheading gnutls_x509_crt_get_dn
2249 @anchor{gnutls_x509_crt_get_dn}
2250 @deftypefun {int} {gnutls_x509_crt_get_dn} (gnutls_x509_crt_t @var{cert}, char * @var{buf}, size_t * @var{sizeof_buf})
2251 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2252
2253 @var{buf}: a pointer to a structure to hold the name (may be null)
2254
2255 @var{sizeof_buf}: initially holds the size of @code{buf}
2256
2257 This function will copy the name of the Certificate in the provided
2258 buffer. The name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as
2259 described in RFC2253. The output string will be ASCII or UTF-8
2260 encoded, depending on the certificate data.
2261
2262 If @code{buf} is null then only the size will be filled.
2263
2264 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is not
2265 long enough, and in that case the *sizeof_buf will be updated
2266 with the required size.  On success 0 is returned.
2267 @end deftypefun
2268
2269 @subheading gnutls_x509_crt_get_expiration_time
2270 @anchor{gnutls_x509_crt_get_expiration_time}
2271 @deftypefun {time_t} {gnutls_x509_crt_get_expiration_time} (gnutls_x509_crt_t @var{cert})
2272 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2273
2274 This function will return the time this Certificate was or will be
2275 expired.
2276
2277 @strong{Returns:} expiration time, or (time_t)-1 on error.
2278 @end deftypefun
2279
2280 @subheading gnutls_x509_crt_get_extension_by_oid
2281 @anchor{gnutls_x509_crt_get_extension_by_oid}
2282 @deftypefun {int} {gnutls_x509_crt_get_extension_by_oid} (gnutls_x509_crt_t @var{cert}, const char * @var{oid}, int @var{indx}, void * @var{buf}, size_t * @var{sizeof_buf}, unsigned int * @var{critical})
2283 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2284
2285 @var{oid}: holds an Object Identified in null terminated string
2286
2287 @var{indx}: In case multiple same OIDs exist in the extensions, this specifies which to send. Use zero to get the first one.
2288
2289 @var{buf}: a pointer to a structure to hold the name (may be null)
2290
2291 @var{sizeof_buf}: initially holds the size of @code{buf}
2292
2293 @var{critical}: will be non zero if the extension is marked as critical
2294
2295 This function will return the extension specified by the OID in the
2296 certificate.  The extensions will be returned as binary data DER
2297 encoded, in the provided buffer.
2298
2299 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
2300 otherwise an error code is returned. If the certificate does not
2301 contain the specified extension
2302 GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned.
2303 @end deftypefun
2304
2305 @subheading gnutls_x509_crt_get_extension_data
2306 @anchor{gnutls_x509_crt_get_extension_data}
2307 @deftypefun {int} {gnutls_x509_crt_get_extension_data} (gnutls_x509_crt_t @var{cert}, int @var{indx}, void * @var{data}, size_t * @var{sizeof_data})
2308 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2309
2310 @var{indx}: Specifies which extension OID to send. Use zero to get the first one.
2311
2312 @var{data}: a pointer to a structure to hold the data (may be null)
2313
2314 @var{sizeof_data}: initially holds the size of @code{oid}
2315
2316 This function will return the requested extension data in the
2317 certificate.  The extension data will be stored as a string in the
2318 provided buffer.
2319
2320 Use @code{gnutls_x509_crt_get_extension_info()} to extract the OID and
2321 critical flag.  Use @code{gnutls_x509_crt_get_extension_by_oid()} instead,
2322 if you want to get data indexed by the extension OID rather than
2323 sequence.
2324
2325 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
2326 otherwise an error code is returned.  If you have reached the
2327 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
2328 will be returned.
2329 @end deftypefun
2330
2331 @subheading gnutls_x509_crt_get_extension_info
2332 @anchor{gnutls_x509_crt_get_extension_info}
2333 @deftypefun {int} {gnutls_x509_crt_get_extension_info} (gnutls_x509_crt_t @var{cert}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid}, int * @var{critical})
2334 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2335
2336 @var{indx}: Specifies which extension OID to send. Use zero to get the first one.
2337
2338 @var{oid}: a pointer to a structure to hold the OID
2339
2340 @var{sizeof_oid}: initially holds the maximum size of @code{oid}, on return
2341 holds actual size of @code{oid}.
2342
2343 @var{critical}: output variable with critical flag, may be NULL.
2344
2345 This function will return the requested extension OID in the
2346 certificate, and the critical flag for it.  The extension OID will
2347 be stored as a string in the provided buffer.  Use
2348 @code{gnutls_x509_crt_get_extension_data()} to extract the data.
2349
2350 If the buffer provided is not long enough to hold the output, then
2351 *@code{sizeof_oid} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will be
2352 returned.
2353
2354 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
2355 otherwise an error code is returned.  If you have reached the
2356 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
2357 will be returned.
2358 @end deftypefun
2359
2360 @subheading gnutls_x509_crt_get_extension_oid
2361 @anchor{gnutls_x509_crt_get_extension_oid}
2362 @deftypefun {int} {gnutls_x509_crt_get_extension_oid} (gnutls_x509_crt_t @var{cert}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
2363 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2364
2365 @var{indx}: Specifies which extension OID to send. Use zero to get the first one.
2366
2367 @var{oid}: a pointer to a structure to hold the OID (may be null)
2368
2369 @var{sizeof_oid}: initially holds the size of @code{oid}
2370
2371 This function will return the requested extension OID in the certificate.
2372 The extension OID will be stored as a string in the provided buffer.
2373
2374 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
2375 otherwise an error code is returned.  If you have reached the
2376 last extension available @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
2377 will be returned.
2378 @end deftypefun
2379
2380 @subheading gnutls_x509_crt_get_fingerprint
2381 @anchor{gnutls_x509_crt_get_fingerprint}
2382 @deftypefun {int} {gnutls_x509_crt_get_fingerprint} (gnutls_x509_crt_t @var{cert}, gnutls_digest_algorithm_t @var{algo}, void * @var{buf}, size_t * @var{sizeof_buf})
2383 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2384
2385 @var{algo}: is a digest algorithm
2386
2387 @var{buf}: a pointer to a structure to hold the fingerprint (may be null)
2388
2389 @var{sizeof_buf}: initially holds the size of @code{buf}
2390
2391 This function will calculate and copy the certificate's fingerprint
2392 in the provided buffer.
2393
2394 If the buffer is null then only the size will be filled.
2395
2396 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
2397 not long enough, and in that case the *sizeof_buf will be updated
2398 with the required size.  On success 0 is returned.
2399 @end deftypefun
2400
2401 @subheading gnutls_x509_crt_get_issuer_alt_name2
2402 @anchor{gnutls_x509_crt_get_issuer_alt_name2}
2403 @deftypefun {int} {gnutls_x509_crt_get_issuer_alt_name2} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{ret_type}, unsigned int * @var{critical})
2404 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2405
2406 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
2407
2408 @var{ret}: is the place where the alternative name will be copied to
2409
2410 @var{ret_size}: holds the size of ret.
2411
2412 @var{ret_type}: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
2413
2414 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2415
2416 This function will return the alternative names, contained in the
2417 given certificate. It is the same as
2418 @code{gnutls_x509_crt_get_issuer_alt_name()} except for the fact that it
2419 will return the type of the alternative name in @code{ret_type} even if
2420 the function fails for some reason (i.e.  the buffer provided is
2421 not enough).
2422
2423 @strong{Returns:} the alternative issuer name type on success, one of the
2424 enumerated @code{gnutls_x509_subject_alt_name_t}.  It will return
2425 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if @code{ret_size} is not large enough
2426 to hold the value.  In that case @code{ret_size} will be updated with
2427 the required size.  If the certificate does not have an
2428 Alternative name with the specified sequence number then
2429 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
2430
2431 @strong{Since:} 2.10.0
2432 @end deftypefun
2433
2434 @subheading gnutls_x509_crt_get_issuer_alt_name
2435 @anchor{gnutls_x509_crt_get_issuer_alt_name}
2436 @deftypefun {int} {gnutls_x509_crt_get_issuer_alt_name} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{critical})
2437 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2438
2439 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
2440
2441 @var{ret}: is the place where the alternative name will be copied to
2442
2443 @var{ret_size}: holds the size of ret.
2444
2445 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2446
2447 This function retrieves the Issuer Alternative Name (2.5.29.18),
2448 contained in the given certificate in the X509v3 Certificate
2449 Extensions.
2450
2451 When the SAN type is otherName, it will extract the data in the
2452 otherName's value field, and @code{GNUTLS_SAN_OTHERNAME} is returned.
2453 You may use @code{gnutls_x509_crt_get_subject_alt_othername_oid()} to get
2454 the corresponding OID and the "virtual" SAN types (e.g.,
2455 @code{GNUTLS_SAN_OTHERNAME_XMPP}).
2456
2457 If an otherName OID is known, the data will be decoded.  Otherwise
2458 the returned data will be DER encoded, and you will have to decode
2459 it yourself.  Currently, only the RFC 3920 id-on-xmppAddr Issuer
2460 AltName is recognized.
2461
2462 @strong{Returns:} the alternative issuer name type on success, one of the
2463 enumerated @code{gnutls_x509_subject_alt_name_t}.  It will return
2464 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if @code{ret_size} is not large enough
2465 to hold the value.  In that case @code{ret_size} will be updated with
2466 the required size.  If the certificate does not have an
2467 Alternative name with the specified sequence number then
2468 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
2469
2470 @strong{Since:} 2.10.0
2471 @end deftypefun
2472
2473 @subheading gnutls_x509_crt_get_issuer_alt_othername_oid
2474 @anchor{gnutls_x509_crt_get_issuer_alt_othername_oid}
2475 @deftypefun {int} {gnutls_x509_crt_get_issuer_alt_othername_oid} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size})
2476 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2477
2478 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
2479
2480 @var{ret}: is the place where the otherName OID will be copied to
2481
2482 @var{ret_size}: holds the size of ret.
2483
2484 This function will extract the type OID of an otherName Subject
2485 Alternative Name, contained in the given certificate, and return
2486 the type as an enumerated element.
2487
2488 This function is only useful if
2489 @code{gnutls_x509_crt_get_issuer_alt_name()} returned
2490 @code{GNUTLS_SAN_OTHERNAME}.
2491
2492 @strong{Returns:} the alternative issuer name type on success, one of the
2493 enumerated gnutls_x509_subject_alt_name_t.  For supported OIDs, it
2494 will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types,
2495 e.g. @code{GNUTLS_SAN_OTHERNAME_XMPP}, and @code{GNUTLS_SAN_OTHERNAME} for
2496 unknown OIDs.  It will return @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if
2497 @code{ret_size} is not large enough to hold the value.  In that case
2498 @code{ret_size} will be updated with the required size.  If the
2499 certificate does not have an Alternative name with the specified
2500 sequence number and with the otherName type then
2501 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
2502
2503 @strong{Since:} 2.10.0
2504 @end deftypefun
2505
2506 @subheading gnutls_x509_crt_get_issuer_dn_by_oid
2507 @anchor{gnutls_x509_crt_get_issuer_dn_by_oid}
2508 @deftypefun {int} {gnutls_x509_crt_get_issuer_dn_by_oid} (gnutls_x509_crt_t @var{cert}, const char * @var{oid}, int @var{indx}, unsigned int @var{raw_flag}, void * @var{buf}, size_t * @var{sizeof_buf})
2509 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2510
2511 @var{oid}: holds an Object Identified in null terminated string
2512
2513 @var{indx}: In case multiple same OIDs exist in the RDN, this specifies which to send. Use zero to get the first one.
2514
2515 @var{raw_flag}: If non zero returns the raw DER data of the DN part.
2516
2517 @var{buf}: a pointer to a structure to hold the name (may be null)
2518
2519 @var{sizeof_buf}: initially holds the size of @code{buf}
2520
2521 This function will extract the part of the name of the Certificate
2522 issuer specified by the given OID. The output, if the raw flag is not
2523 used, will be encoded as described in RFC2253. Thus a string that is
2524 ASCII or UTF-8 encoded, depending on the certificate data.
2525
2526 Some helper macros with popular OIDs can be found in gnutls/x509.h
2527 If raw flag is zero, this function will only return known OIDs as
2528 text. Other OIDs will be DER encoded, as described in RFC2253 --
2529 in hex format with a '\#' prefix.  You can check about known OIDs
2530 using @code{gnutls_x509_dn_oid_known()}.
2531
2532 If @code{buf} is null then only the size will be filled.
2533
2534 @strong{Returns:} GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
2535 long enough, and in that case the *sizeof_buf will be updated
2536 with the required size.  On success 0 is returned.
2537 @end deftypefun
2538
2539 @subheading gnutls_x509_crt_get_issuer_dn_oid
2540 @anchor{gnutls_x509_crt_get_issuer_dn_oid}
2541 @deftypefun {int} {gnutls_x509_crt_get_issuer_dn_oid} (gnutls_x509_crt_t @var{cert}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid})
2542 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2543
2544 @var{indx}: This specifies which OID to return. Use zero to get the first one.
2545
2546 @var{oid}: a pointer to a buffer to hold the OID (may be null)
2547
2548 @var{sizeof_oid}: initially holds the size of @code{oid}
2549
2550 This function will extract the OIDs of the name of the Certificate
2551 issuer specified by the given index.
2552
2553 If @code{oid} is null then only the size will be filled.
2554
2555 @strong{Returns:} GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
2556 long enough, and in that case the *sizeof_oid will be updated
2557 with the required size.  On success 0 is returned.
2558 @end deftypefun
2559
2560 @subheading gnutls_x509_crt_get_issuer_dn
2561 @anchor{gnutls_x509_crt_get_issuer_dn}
2562 @deftypefun {int} {gnutls_x509_crt_get_issuer_dn} (gnutls_x509_crt_t @var{cert}, char * @var{buf}, size_t * @var{sizeof_buf})
2563 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2564
2565 @var{buf}: a pointer to a structure to hold the name (may be null)
2566
2567 @var{sizeof_buf}: initially holds the size of @code{buf}
2568
2569 This function will copy the name of the Certificate issuer in the
2570 provided buffer. The name will be in the form
2571 "C=xxxx,O=yyyy,CN=zzzz" as described in RFC2253. The output string
2572 will be ASCII or UTF-8 encoded, depending on the certificate data.
2573
2574 If @code{buf} is null then only the size will be filled.
2575
2576 @strong{Returns:} GNUTLS_E_SHORT_MEMORY_BUFFER if the provided buffer is not
2577 long enough, and in that case the *sizeof_buf will be updated with
2578 the required size.  On success 0 is returned.
2579 @end deftypefun
2580
2581 @subheading gnutls_x509_crt_get_issuer_unique_id
2582 @anchor{gnutls_x509_crt_get_issuer_unique_id}
2583 @deftypefun {int} {gnutls_x509_crt_get_issuer_unique_id} (gnutls_x509_crt_t @var{crt}, char * @var{buf}, size_t * @var{sizeof_buf})
2584 @var{crt}: Holds the certificate
2585
2586 @var{buf}: user allocated memory buffer, will hold the unique id
2587
2588 @var{sizeof_buf}: size of user allocated memory buffer (on input), will hold
2589 actual size of the unique ID on return.
2590
2591 This function will extract the issuerUniqueID value (if present) for
2592 the given certificate.
2593
2594 If the user allocated memory buffer is not large enough to hold the
2595 full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be
2596 returned, and sizeof_buf will be set to the actual length.
2597
2598 @strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
2599 @end deftypefun
2600
2601 @subheading gnutls_x509_crt_get_issuer
2602 @anchor{gnutls_x509_crt_get_issuer}
2603 @deftypefun {int} {gnutls_x509_crt_get_issuer} (gnutls_x509_crt_t @var{cert}, gnutls_x509_dn_t * @var{dn})
2604 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2605
2606 @var{dn}: output variable with pointer to opaque DN
2607
2608 Return the Certificate's Issuer DN as an opaque data type.  You may
2609 use @code{gnutls_x509_dn_get_rdn_ava()} to decode the DN.
2610
2611 Note that @code{dn} should be treated as constant. Because points 
2612 into the @code{cert} object, you may not deallocate @code{cert} 
2613 and continue to access @code{dn}.
2614
2615 @strong{Returns:} Returns 0 on success, or an error code.
2616 @end deftypefun
2617
2618 @subheading gnutls_x509_crt_get_key_id
2619 @anchor{gnutls_x509_crt_get_key_id}
2620 @deftypefun {int} {gnutls_x509_crt_get_key_id} (gnutls_x509_crt_t @var{crt}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size})
2621 @var{crt}: Holds the certificate
2622
2623 @var{flags}: should be 0 for now
2624
2625 @var{output_data}: will contain the key ID
2626
2627 @var{output_data_size}: holds the size of output_data (and will be
2628 replaced by the actual size of parameters)
2629
2630 This function will return a unique ID the depends on the public
2631 key parameters. This ID can be used in checking whether a
2632 certificate corresponds to the given private key.
2633
2634 If the buffer provided is not long enough to hold the output, then
2635 *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
2636 be returned.  The output will normally be a SHA-1 hash output,
2637 which is 20 bytes.
2638
2639 @strong{Return value:} In case of failure a negative value will be
2640 returned, and 0 on success.
2641 @end deftypefun
2642
2643 @subheading gnutls_x509_crt_get_key_purpose_oid
2644 @anchor{gnutls_x509_crt_get_key_purpose_oid}
2645 @deftypefun {int} {gnutls_x509_crt_get_key_purpose_oid} (gnutls_x509_crt_t @var{cert}, int @var{indx}, void * @var{oid}, size_t * @var{sizeof_oid}, unsigned int * @var{critical})
2646 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2647
2648 @var{indx}: This specifies which OID to return. Use zero to get the first one.
2649
2650 @var{oid}: a pointer to a buffer to hold the OID (may be null)
2651
2652 @var{sizeof_oid}: initially holds the size of @code{oid}
2653
2654 @var{critical}: output flag to indicate criticality of extension
2655
2656 This function will extract the key purpose OIDs of the Certificate
2657 specified by the given index.  These are stored in the Extended Key
2658 Usage extension (2.5.29.37) See the GNUTLS_KP_* definitions for
2659 human readable names.
2660
2661 If @code{oid} is null then only the size will be filled.
2662
2663 @strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the provided buffer is
2664 not long enough, and in that case the *sizeof_oid will be updated
2665 with the required size.  On success 0 is returned.
2666 @end deftypefun
2667
2668 @subheading gnutls_x509_crt_get_key_usage
2669 @anchor{gnutls_x509_crt_get_key_usage}
2670 @deftypefun {int} {gnutls_x509_crt_get_key_usage} (gnutls_x509_crt_t @var{cert}, unsigned int * @var{key_usage}, unsigned int * @var{critical})
2671 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2672
2673 @var{key_usage}: where the key usage bits will be stored
2674
2675 @var{critical}: will be non zero if the extension is marked as critical
2676
2677 This function will return certificate's key usage, by reading the
2678 keyUsage X.509 extension (2.5.29.15). The key usage value will ORed
2679 values of the: @code{GNUTLS_KEY_DIGITAL_SIGNATURE},
2680 @code{GNUTLS_KEY_NON_REPUDIATION}, @code{GNUTLS_KEY_KEY_ENCIPHERMENT},
2681 @code{GNUTLS_KEY_DATA_ENCIPHERMENT}, @code{GNUTLS_KEY_KEY_AGREEMENT},
2682 @code{GNUTLS_KEY_KEY_CERT_SIGN}, @code{GNUTLS_KEY_CRL_SIGN},
2683 @code{GNUTLS_KEY_ENCIPHER_ONLY}, @code{GNUTLS_KEY_DECIPHER_ONLY}.
2684
2685 @strong{Returns:} the certificate key usage, or a negative value in case of
2686 parsing error.  If the certificate does not contain the keyUsage
2687 extension @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} will be
2688 returned.
2689 @end deftypefun
2690
2691 @subheading gnutls_x509_crt_get_pk_algorithm
2692 @anchor{gnutls_x509_crt_get_pk_algorithm}
2693 @deftypefun {int} {gnutls_x509_crt_get_pk_algorithm} (gnutls_x509_crt_t @var{cert}, unsigned int * @var{bits})
2694 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2695
2696 @var{bits}: if bits is non null it will hold the size of the parameters' in bits
2697
2698 This function will return the public key algorithm of an X.509
2699 certificate.
2700
2701 If bits is non null, it should have enough size to hold the parameters
2702 size in bits. For RSA the bits returned is the modulus.
2703 For DSA the bits returned are of the public
2704 exponent.
2705
2706 @strong{Returns:} a member of the @code{gnutls_pk_algorithm_t} enumeration on
2707 success, or a negative value on error.
2708 @end deftypefun
2709
2710 @subheading gnutls_x509_crt_get_pk_dsa_raw
2711 @anchor{gnutls_x509_crt_get_pk_dsa_raw}
2712 @deftypefun {int} {gnutls_x509_crt_get_pk_dsa_raw} (gnutls_x509_crt_t @var{crt}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y})
2713 @var{crt}: Holds the certificate
2714
2715 @var{p}: will hold the p
2716
2717 @var{q}: will hold the q
2718
2719 @var{g}: will hold the g
2720
2721 @var{y}: will hold the y
2722
2723 This function will export the DSA public key's parameters found in
2724 the given certificate.  The new parameters will be allocated using
2725 @code{gnutls_malloc()} and will be stored in the appropriate datum.
2726
2727 @strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
2728 @end deftypefun
2729
2730 @subheading gnutls_x509_crt_get_pk_rsa_raw
2731 @anchor{gnutls_x509_crt_get_pk_rsa_raw}
2732 @deftypefun {int} {gnutls_x509_crt_get_pk_rsa_raw} (gnutls_x509_crt_t @var{crt}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e})
2733 @var{crt}: Holds the certificate
2734
2735 @var{m}: will hold the modulus
2736
2737 @var{e}: will hold the public exponent
2738
2739 This function will export the RSA public key's parameters found in
2740 the given structure.  The new parameters will be allocated using
2741 @code{gnutls_malloc()} and will be stored in the appropriate datum.
2742
2743 @strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
2744 @end deftypefun
2745
2746 @subheading gnutls_x509_crt_get_preferred_hash_algorithm
2747 @anchor{gnutls_x509_crt_get_preferred_hash_algorithm}
2748 @deftypefun {int} {gnutls_x509_crt_get_preferred_hash_algorithm} (gnutls_x509_crt_t @var{crt}, gnutls_digest_algorithm_t *                                               @var{hash}, unsigned int * @var{mand})
2749 @var{crt}: Holds the certificate
2750
2751 @var{hash}: The result of the call with the hash algorithm used for signature
2752
2753 @var{mand}: If non zero it means that the algorithm MUST use this hash. May be NULL.
2754
2755 This function will read the certifcate and return the appropriate digest
2756 algorithm to use for signing with this certificate. Some certificates (i.e.
2757 DSA might not be able to sign without the preferred algorithm).
2758
2759 @strong{Deprecated:} Please use @code{gnutls_pubkey_get_preferred_hash_algorithm()}.
2760
2761 @strong{Returns:} the 0 if the hash algorithm is found. A negative value is
2762 returned on error.
2763
2764 @strong{Since:} 2.11.0
2765 @end deftypefun
2766
2767 @subheading gnutls_x509_crt_get_proxy
2768 @anchor{gnutls_x509_crt_get_proxy}
2769 @deftypefun {int} {gnutls_x509_crt_get_proxy} (gnutls_x509_crt_t @var{cert}, unsigned int * @var{critical}, int * @var{pathlen}, char ** @var{policyLanguage}, char ** @var{policy}, size_t * @var{sizeof_policy})
2770 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2771
2772 @var{critical}: will be non zero if the extension is marked as critical
2773
2774 @var{pathlen}: pointer to output integer indicating path length (may be
2775 NULL), non-negative values indicate a present pCPathLenConstraint
2776 field and the actual value, -1 indicate that the field is absent.
2777
2778 @var{policyLanguage}: output variable with OID of policy language
2779
2780 @var{policy}: output variable with policy data
2781
2782 @var{sizeof_policy}: output variable size of policy data
2783
2784 This function will get information from a proxy certificate.  It
2785 reads the ProxyCertInfo X.509 extension (1.3.6.1.5.5.7.1.14).
2786
2787 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
2788 otherwise an error code is returned.
2789 @end deftypefun
2790
2791 @subheading gnutls_x509_crt_get_raw_dn
2792 @anchor{gnutls_x509_crt_get_raw_dn}
2793 @deftypefun {int} {gnutls_x509_crt_get_raw_dn} (gnutls_x509_crt_t @var{cert}, gnutls_datum_t * @var{start})
2794 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2795
2796 @var{start}: will hold the starting point of the DN
2797
2798 This function will return a pointer to the DER encoded DN structure and
2799 the length.
2800
2801 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2802 negative error value. or a negative value on error.
2803 @end deftypefun
2804
2805 @subheading gnutls_x509_crt_get_raw_issuer_dn
2806 @anchor{gnutls_x509_crt_get_raw_issuer_dn}
2807 @deftypefun {int} {gnutls_x509_crt_get_raw_issuer_dn} (gnutls_x509_crt_t @var{cert}, gnutls_datum_t * @var{start})
2808 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2809
2810 @var{start}: will hold the starting point of the DN
2811
2812 This function will return a pointer to the DER encoded DN structure
2813 and the length.
2814
2815 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2816 negative error value.or a negative value on error.
2817 @end deftypefun
2818
2819 @subheading gnutls_x509_crt_get_serial
2820 @anchor{gnutls_x509_crt_get_serial}
2821 @deftypefun {int} {gnutls_x509_crt_get_serial} (gnutls_x509_crt_t @var{cert}, void * @var{result}, size_t * @var{result_size})
2822 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2823
2824 @var{result}: The place where the serial number will be copied
2825
2826 @var{result_size}: Holds the size of the result field.
2827
2828 This function will return the X.509 certificate's serial number.
2829 This is obtained by the X509 Certificate serialNumber field. Serial
2830 is not always a 32 or 64bit number. Some CAs use large serial
2831 numbers, thus it may be wise to handle it as something opaque.
2832
2833 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2834 negative error value.
2835 @end deftypefun
2836
2837 @subheading gnutls_x509_crt_get_signature_algorithm
2838 @anchor{gnutls_x509_crt_get_signature_algorithm}
2839 @deftypefun {int} {gnutls_x509_crt_get_signature_algorithm} (gnutls_x509_crt_t @var{cert})
2840 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2841
2842 This function will return a value of the @code{gnutls_sign_algorithm_t}
2843 enumeration that is the signature algorithm that has been used to
2844 sign this certificate.
2845
2846 @strong{Returns:} a @code{gnutls_sign_algorithm_t} value, or a negative value on
2847 error.
2848 @end deftypefun
2849
2850 @subheading gnutls_x509_crt_get_signature
2851 @anchor{gnutls_x509_crt_get_signature}
2852 @deftypefun {int} {gnutls_x509_crt_get_signature} (gnutls_x509_crt_t @var{cert}, char * @var{sig}, size_t * @var{sizeof_sig})
2853 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2854
2855 @var{sig}: a pointer where the signature part will be copied (may be null).
2856
2857 @var{sizeof_sig}: initially holds the size of @code{sig}
2858
2859 This function will extract the signature field of a certificate.
2860
2861 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2862 negative error value. and a negative value on error.
2863 @end deftypefun
2864
2865 @subheading gnutls_x509_crt_get_subject_alt_name2
2866 @anchor{gnutls_x509_crt_get_subject_alt_name2}
2867 @deftypefun {int} {gnutls_x509_crt_get_subject_alt_name2} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{ret_type}, unsigned int * @var{critical})
2868 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2869
2870 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
2871
2872 @var{ret}: is the place where the alternative name will be copied to
2873
2874 @var{ret_size}: holds the size of ret.
2875
2876 @var{ret_type}: holds the type of the alternative name (one of gnutls_x509_subject_alt_name_t).
2877
2878 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2879
2880 This function will return the alternative names, contained in the
2881 given certificate. It is the same as
2882 @code{gnutls_x509_crt_get_subject_alt_name()} except for the fact that it
2883 will return the type of the alternative name in @code{ret_type} even if
2884 the function fails for some reason (i.e.  the buffer provided is
2885 not enough).
2886
2887 @strong{Returns:} the alternative subject name type on success, one of the
2888 enumerated @code{gnutls_x509_subject_alt_name_t}.  It will return
2889 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if @code{ret_size} is not large enough
2890 to hold the value.  In that case @code{ret_size} will be updated with
2891 the required size.  If the certificate does not have an
2892 Alternative name with the specified sequence number then
2893 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
2894 @end deftypefun
2895
2896 @subheading gnutls_x509_crt_get_subject_alt_name
2897 @anchor{gnutls_x509_crt_get_subject_alt_name}
2898 @deftypefun {int} {gnutls_x509_crt_get_subject_alt_name} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{critical})
2899 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2900
2901 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
2902
2903 @var{ret}: is the place where the alternative name will be copied to
2904
2905 @var{ret_size}: holds the size of ret.
2906
2907 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2908
2909 This function retrieves the Alternative Name (2.5.29.17), contained
2910 in the given certificate in the X509v3 Certificate Extensions.
2911
2912 When the SAN type is otherName, it will extract the data in the
2913 otherName's value field, and @code{GNUTLS_SAN_OTHERNAME} is returned.
2914 You may use @code{gnutls_x509_crt_get_subject_alt_othername_oid()} to get
2915 the corresponding OID and the "virtual" SAN types (e.g.,
2916 @code{GNUTLS_SAN_OTHERNAME_XMPP}).
2917
2918 If an otherName OID is known, the data will be decoded.  Otherwise
2919 the returned data will be DER encoded, and you will have to decode
2920 it yourself.  Currently, only the RFC 3920 id-on-xmppAddr SAN is
2921 recognized.
2922
2923 @strong{Returns:} the alternative subject name type on success, one of the
2924 enumerated @code{gnutls_x509_subject_alt_name_t}.  It will return
2925 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if @code{ret_size} is not large enough to
2926 hold the value.  In that case @code{ret_size} will be updated with the
2927 required size.  If the certificate does not have an Alternative
2928 name with the specified sequence number then
2929 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
2930 @end deftypefun
2931
2932 @subheading gnutls_x509_crt_get_subject_alt_othername_oid
2933 @anchor{gnutls_x509_crt_get_subject_alt_othername_oid}
2934 @deftypefun {int} {gnutls_x509_crt_get_subject_alt_othername_oid} (gnutls_x509_crt_t @var{cert}, unsigned int @var{seq}, void * @var{ret}, size_t * @var{ret_size})
2935 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2936
2937 @var{seq}: specifies the sequence number of the alt name (0 for the first one, 1 for the second etc.)
2938
2939 @var{ret}: is the place where the otherName OID will be copied to
2940
2941 @var{ret_size}: holds the size of ret.
2942
2943 This function will extract the type OID of an otherName Subject
2944 Alternative Name, contained in the given certificate, and return
2945 the type as an enumerated element.
2946
2947 This function is only useful if
2948 @code{gnutls_x509_crt_get_subject_alt_name()} returned
2949 @code{GNUTLS_SAN_OTHERNAME}.
2950
2951 @strong{Returns:} the alternative subject name type on success, one of the
2952 enumerated gnutls_x509_subject_alt_name_t.  For supported OIDs, it
2953 will return one of the virtual (GNUTLS_SAN_OTHERNAME_*) types,
2954 e.g. @code{GNUTLS_SAN_OTHERNAME_XMPP}, and @code{GNUTLS_SAN_OTHERNAME} for
2955 unknown OIDs.  It will return @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if
2956 @code{ret_size} is not large enough to hold the value.  In that case
2957 @code{ret_size} will be updated with the required size.  If the
2958 certificate does not have an Alternative name with the specified
2959 sequence number and with the otherName type then
2960 @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE} is returned.
2961 @end deftypefun
2962
2963 @subheading gnutls_x509_crt_get_subject_key_id
2964 @anchor{gnutls_x509_crt_get_subject_key_id}
2965 @deftypefun {int} {gnutls_x509_crt_get_subject_key_id} (gnutls_x509_crt_t @var{cert}, void * @var{ret}, size_t * @var{ret_size}, unsigned int * @var{critical})
2966 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
2967
2968 @var{ret}: The place where the identifier will be copied
2969
2970 @var{ret_size}: Holds the size of the result field.
2971
2972 @var{critical}: will be non zero if the extension is marked as critical (may be null)
2973
2974 This function will return the X.509v3 certificate's subject key
2975 identifier.  This is obtained by the X.509 Subject Key identifier
2976 extension field (2.5.29.14).
2977
2978 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
2979 negative error value.
2980 @end deftypefun
2981
2982 @subheading gnutls_x509_crt_get_subject_unique_id
2983 @anchor{gnutls_x509_crt_get_subject_unique_id}
2984 @deftypefun {int} {gnutls_x509_crt_get_subject_unique_id} (gnutls_x509_crt_t @var{crt}, char * @var{buf}, size_t * @var{sizeof_buf})
2985 @var{crt}: Holds the certificate
2986
2987 @var{buf}: user allocated memory buffer, will hold the unique id
2988
2989 @var{sizeof_buf}: size of user allocated memory buffer (on input), will hold
2990 actual size of the unique ID on return.
2991
2992 This function will extract the subjectUniqueID value (if present) for
2993 the given certificate.
2994
2995 If the user allocated memory buffer is not large enough to hold the
2996 full subjectUniqueID, then a GNUTLS_E_SHORT_MEMORY_BUFFER error will be
2997 returned, and sizeof_buf will be set to the actual length.
2998
2999 @strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
3000 @end deftypefun
3001
3002 @subheading gnutls_x509_crt_get_subject
3003 @anchor{gnutls_x509_crt_get_subject}
3004 @deftypefun {int} {gnutls_x509_crt_get_subject} (gnutls_x509_crt_t @var{cert}, gnutls_x509_dn_t * @var{dn})
3005 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
3006
3007 @var{dn}: output variable with pointer to opaque DN.
3008
3009 Return the Certificate's Subject DN as an opaque data type.  You
3010 may use @code{gnutls_x509_dn_get_rdn_ava()} to decode the DN. 
3011
3012 Note that @code{dn} should be treated as constant. Because points 
3013 into the @code{cert} object, you may not deallocate @code{cert} 
3014 and continue to access @code{dn}.
3015
3016 @strong{Returns:} Returns 0 on success, or an error code.
3017 @end deftypefun
3018
3019 @subheading gnutls_x509_crt_get_verify_algorithm
3020 @anchor{gnutls_x509_crt_get_verify_algorithm}
3021 @deftypefun {int} {gnutls_x509_crt_get_verify_algorithm} (gnutls_x509_crt_t @var{crt}, const gnutls_datum_t * @var{signature}, gnutls_digest_algorithm_t * @var{hash})
3022 @var{crt}: Holds the certificate
3023
3024 @var{signature}: contains the signature
3025
3026 @var{hash}: The result of the call with the hash algorithm used for signature
3027
3028 This function will read the certifcate and the signed data to
3029 determine the hash algorithm used to generate the signature.
3030
3031 @strong{Deprecated:} Use @code{gnutls_pubkey_get_verify_algorithm()} instead.
3032
3033 @strong{Returns:} the 0 if the hash algorithm is found. A negative value is
3034 returned on error.
3035
3036 @strong{Since:} 2.8.0
3037 @end deftypefun
3038
3039 @subheading gnutls_x509_crt_get_version
3040 @anchor{gnutls_x509_crt_get_version}
3041 @deftypefun {int} {gnutls_x509_crt_get_version} (gnutls_x509_crt_t @var{cert})
3042 @var{cert}: should contain a @code{gnutls_x509_crt_t} structure
3043
3044 This function will return the version of the specified Certificate.
3045
3046 @strong{Returns:} version of certificate, or a negative value on error.
3047 @end deftypefun
3048
3049 @subheading gnutls_x509_crt_import
3050 @anchor{gnutls_x509_crt_import}
3051 @deftypefun {int} {gnutls_x509_crt_import} (gnutls_x509_crt_t @var{cert}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
3052 @var{cert}: The structure to store the parsed certificate.
3053
3054 @var{data}: The DER or PEM encoded certificate.
3055
3056 @var{format}: One of DER or PEM
3057
3058 This function will convert the given DER or PEM encoded Certificate
3059 to the native gnutls_x509_crt_t format. The output will be stored
3060 in @code{cert}.
3061
3062 If the Certificate is PEM encoded it should have a header of "X509
3063 CERTIFICATE", or "CERTIFICATE".
3064
3065 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3066 negative error value.
3067 @end deftypefun
3068
3069 @subheading gnutls_x509_crt_init
3070 @anchor{gnutls_x509_crt_init}
3071 @deftypefun {int} {gnutls_x509_crt_init} (gnutls_x509_crt_t * @var{cert})
3072 @var{cert}: The structure to be initialized
3073
3074 This function will initialize an X.509 certificate structure.
3075
3076 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3077 negative error value.
3078 @end deftypefun
3079
3080 @subheading gnutls_x509_crt_list_import
3081 @anchor{gnutls_x509_crt_list_import}
3082 @deftypefun {int} {gnutls_x509_crt_list_import} (gnutls_x509_crt_t * @var{certs}, unsigned int * @var{cert_max}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
3083 @var{certs}: The structures to store the parsed certificate. Must not be initialized.
3084
3085 @var{cert_max}: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
3086
3087 @var{data}: The PEM encoded certificate.
3088
3089 @var{format}: One of DER or PEM.
3090
3091 @var{flags}: must be zero or an OR'd sequence of gnutls_certificate_import_flags.
3092
3093 This function will convert the given PEM encoded certificate list
3094 to the native gnutls_x509_crt_t format. The output will be stored
3095 in @code{certs}.  They will be automatically initialized.
3096
3097 The flag @code{GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED} will cause
3098 import to fail if the certificates in the provided buffer are more
3099 than the available structures. The @code{GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED}
3100 flag will cause the function to fail if the provided list is not
3101 sorted from subject to issuer.
3102
3103 If the Certificate is PEM encoded it should have a header of "X509
3104 CERTIFICATE", or "CERTIFICATE".
3105
3106 @strong{Returns:} the number of certificates read or a negative error value.
3107 @end deftypefun
3108
3109 @subheading gnutls_x509_crt_list_verify
3110 @anchor{gnutls_x509_crt_list_verify}
3111 @deftypefun {int} {gnutls_x509_crt_list_verify} (const gnutls_x509_crt_t * @var{cert_list}, int @var{cert_list_length}, const gnutls_x509_crt_t * @var{CA_list}, int @var{CA_list_length}, const gnutls_x509_crl_t * @var{CRL_list}, int @var{CRL_list_length}, unsigned int @var{flags}, unsigned int * @var{verify})
3112 @var{cert_list}: is the certificate list to be verified
3113
3114 @var{cert_list_length}: holds the number of certificate in cert_list
3115
3116 @var{CA_list}: is the CA list which will be used in verification
3117
3118 @var{CA_list_length}: holds the number of CA certificate in CA_list
3119
3120 @var{CRL_list}: holds a list of CRLs.
3121
3122 @var{CRL_list_length}: the length of CRL list.
3123
3124 @var{flags}: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
3125
3126 @var{verify}: will hold the certificate verification output.
3127
3128 This function will try to verify the given certificate list and
3129 return its status.  If no flags are specified (0), this function
3130 will use the basicConstraints (2.5.29.19) PKIX extension. This
3131 means that only a certificate authority is allowed to sign a
3132 certificate.
3133
3134 You must also check the peer's name in order to check if the verified
3135 certificate belongs to the actual peer.
3136
3137 The certificate verification output will be put in @code{verify} and will
3138 be one or more of the gnutls_certificate_status_t enumerated
3139 elements bitwise or'd.  For a more detailed verification status use
3140 @code{gnutls_x509_crt_verify()} per list element.
3141
3142 @strong{GNUTLS_CERT_INVALID:} the certificate chain is not valid.
3143
3144 @strong{GNUTLS_CERT_REVOKED:} a certificate in the chain has been revoked.
3145
3146 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3147 negative error value.
3148 @end deftypefun
3149
3150 @subheading gnutls_x509_crt_print
3151 @anchor{gnutls_x509_crt_print}
3152 @deftypefun {int} {gnutls_x509_crt_print} (gnutls_x509_crt_t @var{cert}, gnutls_certificate_print_formats_t @var{format}, gnutls_datum_t * @var{out})
3153 @var{cert}: The structure to be printed
3154
3155 @var{format}: Indicate the format to use
3156
3157 @var{out}: Newly allocated datum with zero terminated string.
3158
3159 This function will pretty print a X.509 certificate, suitable for
3160 display to a human.
3161
3162 If the format is @code{GNUTLS_CRT_PRINT_FULL} then all fields of the
3163 certificate will be output, on multiple lines.  The
3164 @code{GNUTLS_CRT_PRINT_ONELINE} format will generate one line with some
3165 selected fields, which is useful for logging purposes.
3166
3167 The output @code{out} needs to be deallocate using @code{gnutls_free()}.
3168
3169 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3170 negative error value.
3171 @end deftypefun
3172
3173 @subheading gnutls_x509_crt_privkey_sign
3174 @anchor{gnutls_x509_crt_privkey_sign}
3175 @deftypefun {int} {gnutls_x509_crt_privkey_sign} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crt_t @var{issuer}, gnutls_privkey_t @var{issuer_key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
3176 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3177
3178 @var{issuer}: is the certificate of the certificate issuer
3179
3180 @var{issuer_key}: holds the issuer's private key
3181
3182 @var{dig}: The message digest to use, @code{GNUTLS_DIG_SHA1} is a safe choice
3183
3184 @var{flags}: must be 0
3185
3186 This function will sign the certificate with the issuer's private key, and
3187 will copy the issuer's information into the certificate.
3188
3189 This must be the last step in a certificate generation since all
3190 the previously set parameters are now signed.
3191
3192 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3193 negative error value.
3194 @end deftypefun
3195
3196 @subheading gnutls_x509_crt_set_activation_time
3197 @anchor{gnutls_x509_crt_set_activation_time}
3198 @deftypefun {int} {gnutls_x509_crt_set_activation_time} (gnutls_x509_crt_t @var{cert}, time_t @var{act_time})
3199 @var{cert}: a certificate of type @code{gnutls_x509_crt_t}
3200
3201 @var{act_time}: The actual time
3202
3203 This function will set the time this Certificate was or will be
3204 activated.
3205
3206 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3207 negative error value.
3208 @end deftypefun
3209
3210 @subheading gnutls_x509_crt_set_authority_key_id
3211 @anchor{gnutls_x509_crt_set_authority_key_id}
3212 @deftypefun {int} {gnutls_x509_crt_set_authority_key_id} (gnutls_x509_crt_t @var{cert}, const void * @var{id}, size_t @var{id_size})
3213 @var{cert}: a certificate of type @code{gnutls_x509_crt_t}
3214
3215 @var{id}: The key ID
3216
3217 @var{id_size}: Holds the size of the serial field.
3218
3219 This function will set the X.509 certificate's authority key ID extension.
3220 Only the keyIdentifier field can be set with this function.
3221
3222 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3223 negative error value.
3224 @end deftypefun
3225
3226 @subheading gnutls_x509_crt_set_basic_constraints
3227 @anchor{gnutls_x509_crt_set_basic_constraints}
3228 @deftypefun {int} {gnutls_x509_crt_set_basic_constraints} (gnutls_x509_crt_t @var{crt}, unsigned int @var{ca}, int @var{pathLenConstraint})
3229 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3230
3231 @var{ca}: true(1) or false(0). Depending on the Certificate authority status.
3232
3233 @var{pathLenConstraint}: non-negative values indicate maximum length of path,
3234 and negative values indicate that the pathLenConstraints field should
3235 not be present.
3236
3237 This function will set the basicConstraints certificate extension.
3238
3239 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3240 negative error value.
3241 @end deftypefun
3242
3243 @subheading gnutls_x509_crt_set_ca_status
3244 @anchor{gnutls_x509_crt_set_ca_status}
3245 @deftypefun {int} {gnutls_x509_crt_set_ca_status} (gnutls_x509_crt_t @var{crt}, unsigned int @var{ca})
3246 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3247
3248 @var{ca}: true(1) or false(0). Depending on the Certificate authority status.
3249
3250 This function will set the basicConstraints certificate extension.
3251 Use @code{gnutls_x509_crt_set_basic_constraints()} if you want to control
3252 the pathLenConstraint field too.
3253
3254 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3255 negative error value.
3256 @end deftypefun
3257
3258 @subheading gnutls_x509_crt_set_crl_dist_points2
3259 @anchor{gnutls_x509_crt_set_crl_dist_points2}
3260 @deftypefun {int} {gnutls_x509_crt_set_crl_dist_points2} (gnutls_x509_crt_t @var{crt}, gnutls_x509_subject_alt_name_t @var{type}, const void * @var{data}, unsigned int @var{data_size}, unsigned int @var{reason_flags})
3261 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3262
3263 @var{type}: is one of the gnutls_x509_subject_alt_name_t enumerations
3264
3265 @var{data}: The data to be set
3266
3267 @var{data_size}: The data size
3268
3269 @var{reason_flags}: revocation reasons
3270
3271 This function will set the CRL distribution points certificate extension.
3272
3273 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3274 negative error value.
3275
3276 @strong{Since:} 2.6.0
3277 @end deftypefun
3278
3279 @subheading gnutls_x509_crt_set_crl_dist_points
3280 @anchor{gnutls_x509_crt_set_crl_dist_points}
3281 @deftypefun {int} {gnutls_x509_crt_set_crl_dist_points} (gnutls_x509_crt_t @var{crt}, gnutls_x509_subject_alt_name_t @var{type}, const void * @var{data_string}, unsigned int @var{reason_flags})
3282 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3283
3284 @var{type}: is one of the gnutls_x509_subject_alt_name_t enumerations
3285
3286 @var{data_string}: The data to be set
3287
3288 @var{reason_flags}: revocation reasons
3289
3290 This function will set the CRL distribution points certificate extension.
3291
3292 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3293 negative error value.
3294 @end deftypefun
3295
3296 @subheading gnutls_x509_crt_set_crq_extensions
3297 @anchor{gnutls_x509_crt_set_crq_extensions}
3298 @deftypefun {int} {gnutls_x509_crt_set_crq_extensions} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crq_t @var{crq})
3299 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3300
3301 @var{crq}: holds a certificate request
3302
3303 This function will set extensions from the given request to the
3304 certificate.
3305
3306 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3307 negative error value.
3308
3309 @strong{Since:} 2.8.0
3310 @end deftypefun
3311
3312 @subheading gnutls_x509_crt_set_crq
3313 @anchor{gnutls_x509_crt_set_crq}
3314 @deftypefun {int} {gnutls_x509_crt_set_crq} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crq_t @var{crq})
3315 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3316
3317 @var{crq}: holds a certificate request
3318
3319 This function will set the name and public parameters as well as
3320 the extensions from the given certificate request to the certificate. 
3321 Only RSA keys are currently supported.
3322
3323 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3324 negative error value.
3325 @end deftypefun
3326
3327 @subheading gnutls_x509_crt_set_dn_by_oid
3328 @anchor{gnutls_x509_crt_set_dn_by_oid}
3329 @deftypefun {int} {gnutls_x509_crt_set_dn_by_oid} (gnutls_x509_crt_t @var{crt}, const char * @var{oid}, unsigned int @var{raw_flag}, const void * @var{name}, unsigned int @var{sizeof_name})
3330 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3331
3332 @var{oid}: holds an Object Identifier in a null terminated string
3333
3334 @var{raw_flag}: must be 0, or 1 if the data are DER encoded
3335
3336 @var{name}: a pointer to the name
3337
3338 @var{sizeof_name}: holds the size of @code{name}
3339
3340 This function will set the part of the name of the Certificate
3341 subject, specified by the given OID. The input string should be
3342 ASCII or UTF-8 encoded.
3343
3344 Some helper macros with popular OIDs can be found in gnutls/x509.h
3345 With this function you can only set the known OIDs. You can test
3346 for known OIDs using @code{gnutls_x509_dn_oid_known()}. For OIDs that are
3347 not known (by gnutls) you should properly DER encode your data,
3348 and call this function with @code{raw_flag} set.
3349
3350 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3351 negative error value.
3352 @end deftypefun
3353
3354 @subheading gnutls_x509_crt_set_expiration_time
3355 @anchor{gnutls_x509_crt_set_expiration_time}
3356 @deftypefun {int} {gnutls_x509_crt_set_expiration_time} (gnutls_x509_crt_t @var{cert}, time_t @var{exp_time})
3357 @var{cert}: a certificate of type @code{gnutls_x509_crt_t}
3358
3359 @var{exp_time}: The actual time
3360
3361 This function will set the time this Certificate will expire.
3362
3363 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3364 negative error value.
3365 @end deftypefun
3366
3367 @subheading gnutls_x509_crt_set_extension_by_oid
3368 @anchor{gnutls_x509_crt_set_extension_by_oid}
3369 @deftypefun {int} {gnutls_x509_crt_set_extension_by_oid} (gnutls_x509_crt_t @var{crt}, const char * @var{oid}, const void * @var{buf}, size_t @var{sizeof_buf}, unsigned int @var{critical})
3370 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3371
3372 @var{oid}: holds an Object Identified in null terminated string
3373
3374 @var{buf}: a pointer to a DER encoded data
3375
3376 @var{sizeof_buf}: holds the size of @code{buf}
3377
3378 @var{critical}: should be non zero if the extension is to be marked as critical
3379
3380 This function will set an the extension, by the specified OID, in
3381 the certificate.  The extension data should be binary data DER
3382 encoded.
3383
3384 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3385 negative error value.
3386 @end deftypefun
3387
3388 @subheading gnutls_x509_crt_set_issuer_dn_by_oid
3389 @anchor{gnutls_x509_crt_set_issuer_dn_by_oid}
3390 @deftypefun {int} {gnutls_x509_crt_set_issuer_dn_by_oid} (gnutls_x509_crt_t @var{crt}, const char * @var{oid}, unsigned int @var{raw_flag}, const void * @var{name}, unsigned int @var{sizeof_name})
3391 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3392
3393 @var{oid}: holds an Object Identifier in a null terminated string
3394
3395 @var{raw_flag}: must be 0, or 1 if the data are DER encoded
3396
3397 @var{name}: a pointer to the name
3398
3399 @var{sizeof_name}: holds the size of @code{name}
3400
3401 This function will set the part of the name of the Certificate
3402 issuer, specified by the given OID.  The input string should be
3403 ASCII or UTF-8 encoded.
3404
3405 Some helper macros with popular OIDs can be found in gnutls/x509.h
3406 With this function you can only set the known OIDs. You can test
3407 for known OIDs using @code{gnutls_x509_dn_oid_known()}. For OIDs that are
3408 not known (by gnutls) you should properly DER encode your data,
3409 and call this function with @code{raw_flag} set.
3410
3411 Normally you do not need to call this function, since the signing
3412 operation will copy the signer's name as the issuer of the
3413 certificate.
3414
3415 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3416 negative error value.
3417 @end deftypefun
3418
3419 @subheading gnutls_x509_crt_set_key_purpose_oid
3420 @anchor{gnutls_x509_crt_set_key_purpose_oid}
3421 @deftypefun {int} {gnutls_x509_crt_set_key_purpose_oid} (gnutls_x509_crt_t @var{cert}, const void * @var{oid}, unsigned int @var{critical})
3422 @var{cert}: a certificate of type @code{gnutls_x509_crt_t}
3423
3424 @var{oid}: a pointer to a null terminated string that holds the OID
3425
3426 @var{critical}: Whether this extension will be critical or not
3427
3428 This function will set the key purpose OIDs of the Certificate.
3429 These are stored in the Extended Key Usage extension (2.5.29.37)
3430 See the GNUTLS_KP_* definitions for human readable names.
3431
3432 Subsequent calls to this function will append OIDs to the OID list.
3433
3434 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
3435 otherwise an error code is returned.
3436 @end deftypefun
3437
3438 @subheading gnutls_x509_crt_set_key_usage
3439 @anchor{gnutls_x509_crt_set_key_usage}
3440 @deftypefun {int} {gnutls_x509_crt_set_key_usage} (gnutls_x509_crt_t @var{crt}, unsigned int @var{usage})
3441 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3442
3443 @var{usage}: an ORed sequence of the GNUTLS_KEY_* elements.
3444
3445 This function will set the keyUsage certificate extension.
3446
3447 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3448 negative error value.
3449 @end deftypefun
3450
3451 @subheading gnutls_x509_crt_set_key
3452 @anchor{gnutls_x509_crt_set_key}
3453 @deftypefun {int} {gnutls_x509_crt_set_key} (gnutls_x509_crt_t @var{crt}, gnutls_x509_privkey_t @var{key})
3454 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3455
3456 @var{key}: holds a private key
3457
3458 This function will set the public parameters from the given
3459 private key to the certificate. Only RSA keys are currently
3460 supported.
3461
3462 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3463 negative error value.
3464 @end deftypefun
3465
3466 @subheading gnutls_x509_crt_set_proxy_dn
3467 @anchor{gnutls_x509_crt_set_proxy_dn}
3468 @deftypefun {int} {gnutls_x509_crt_set_proxy_dn} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crt_t @var{eecrt}, unsigned int @var{raw_flag}, const void * @var{name}, unsigned int @var{sizeof_name})
3469 @var{crt}: a gnutls_x509_crt_t structure with the new proxy cert
3470
3471 @var{eecrt}: the end entity certificate that will be issuing the proxy
3472
3473 @var{raw_flag}: must be 0, or 1 if the CN is DER encoded
3474
3475 @var{name}: a pointer to the CN name, may be NULL (but MUST then be added later)
3476
3477 @var{sizeof_name}: holds the size of @code{name}
3478
3479 This function will set the subject in @code{crt} to the end entity's
3480 @code{eecrt} subject name, and add a single Common Name component @code{name}
3481 of size @code{sizeof_name}.  This corresponds to the required proxy
3482 certificate naming style.  Note that if @code{name} is @code{NULL}, you MUST
3483 set it later by using @code{gnutls_x509_crt_set_dn_by_oid()} or similar.
3484
3485 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3486 negative error value.
3487 @end deftypefun
3488
3489 @subheading gnutls_x509_crt_set_proxy
3490 @anchor{gnutls_x509_crt_set_proxy}
3491 @deftypefun {int} {gnutls_x509_crt_set_proxy} (gnutls_x509_crt_t @var{crt}, int @var{pathLenConstraint}, const char * @var{policyLanguage}, const char * @var{policy}, size_t @var{sizeof_policy})
3492 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3493
3494 @var{pathLenConstraint}: non-negative values indicate maximum length of path,
3495 and negative values indicate that the pathLenConstraints field should
3496 not be present.
3497
3498 @var{policyLanguage}: OID describing the language of @code{policy}.
3499
3500 @var{policy}: opaque byte array with policy language, can be @code{NULL}
3501
3502 @var{sizeof_policy}: size of @code{policy}.
3503
3504 This function will set the proxyCertInfo extension.
3505
3506 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3507 negative error value.
3508 @end deftypefun
3509
3510 @subheading gnutls_x509_crt_set_serial
3511 @anchor{gnutls_x509_crt_set_serial}
3512 @deftypefun {int} {gnutls_x509_crt_set_serial} (gnutls_x509_crt_t @var{cert}, const void * @var{serial}, size_t @var{serial_size})
3513 @var{cert}: a certificate of type @code{gnutls_x509_crt_t}
3514
3515 @var{serial}: The serial number
3516
3517 @var{serial_size}: Holds the size of the serial field.
3518
3519 This function will set the X.509 certificate's serial number.
3520 Serial is not always a 32 or 64bit number.  Some CAs use large
3521 serial numbers, thus it may be wise to handle it as something
3522 opaque.
3523
3524 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3525 negative error value.
3526 @end deftypefun
3527
3528 @subheading gnutls_x509_crt_set_subject_alt_name
3529 @anchor{gnutls_x509_crt_set_subject_alt_name}
3530 @deftypefun {int} {gnutls_x509_crt_set_subject_alt_name} (gnutls_x509_crt_t @var{crt}, gnutls_x509_subject_alt_name_t @var{type}, const void * @var{data}, unsigned int @var{data_size}, unsigned int @var{flags})
3531 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3532
3533 @var{type}: is one of the gnutls_x509_subject_alt_name_t enumerations
3534
3535 @var{data}: The data to be set
3536
3537 @var{data_size}: The size of data to be set
3538
3539 @var{flags}: GNUTLS_FSAN_SET to clear previous data or GNUTLS_FSAN_APPEND to append. 
3540
3541 This function will set the subject alternative name certificate
3542 extension. It can set the following types:
3543
3544 &GNUTLS_SAN_DNSNAME: as a text string
3545
3546 &GNUTLS_SAN_RFC822NAME: as a text string
3547
3548 &GNUTLS_SAN_URI: as a text string
3549
3550 &GNUTLS_SAN_IPADDRESS: as a binary IP address (4 or 16 bytes)
3551
3552 Other values can be set as binary values with the proper DER encoding.
3553
3554 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3555 negative error value.
3556
3557 @strong{Since:} 2.6.0
3558 @end deftypefun
3559
3560 @subheading gnutls_x509_crt_set_subject_alternative_name
3561 @anchor{gnutls_x509_crt_set_subject_alternative_name}
3562 @deftypefun {int} {gnutls_x509_crt_set_subject_alternative_name} (gnutls_x509_crt_t @var{crt}, gnutls_x509_subject_alt_name_t                                               @var{type}, const char * @var{data_string})
3563 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3564
3565 @var{type}: is one of the gnutls_x509_subject_alt_name_t enumerations
3566
3567 @var{data_string}: The data to be set, a zero terminated string
3568
3569 This function will set the subject alternative name certificate
3570 extension. This function assumes that data can be expressed as a null
3571 terminated string.
3572
3573 The name of the function is unfortunate since it is incosistent with
3574 @code{gnutls_x509_crt_get_subject_alt_name()}.
3575
3576 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3577 negative error value.
3578 @end deftypefun
3579
3580 @subheading gnutls_x509_crt_set_subject_key_id
3581 @anchor{gnutls_x509_crt_set_subject_key_id}
3582 @deftypefun {int} {gnutls_x509_crt_set_subject_key_id} (gnutls_x509_crt_t @var{cert}, const void * @var{id}, size_t @var{id_size})
3583 @var{cert}: a certificate of type @code{gnutls_x509_crt_t}
3584
3585 @var{id}: The key ID
3586
3587 @var{id_size}: Holds the size of the serial field.
3588
3589 This function will set the X.509 certificate's subject key ID
3590 extension.
3591
3592 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3593 negative error value.
3594 @end deftypefun
3595
3596 @subheading gnutls_x509_crt_set_version
3597 @anchor{gnutls_x509_crt_set_version}
3598 @deftypefun {int} {gnutls_x509_crt_set_version} (gnutls_x509_crt_t @var{crt}, unsigned int @var{version})
3599 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3600
3601 @var{version}: holds the version number. For X.509v1 certificates must be 1.
3602
3603 This function will set the version of the certificate.  This must
3604 be one for X.509 version 1, and so on.  Plain certificates without
3605 extensions must have version set to one.
3606
3607 To create well-formed certificates, you must specify version 3 if
3608 you use any certificate extensions.  Extensions are created by
3609 functions such as @code{gnutls_x509_crt_set_subject_alt_name()}
3610 or @code{gnutls_x509_crt_set_key_usage()}.
3611
3612 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3613 negative error value.
3614 @end deftypefun
3615
3616 @subheading gnutls_x509_crt_sign2
3617 @anchor{gnutls_x509_crt_sign2}
3618 @deftypefun {int} {gnutls_x509_crt_sign2} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crt_t @var{issuer}, gnutls_x509_privkey_t @var{issuer_key}, gnutls_digest_algorithm_t @var{dig}, unsigned int @var{flags})
3619 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3620
3621 @var{issuer}: is the certificate of the certificate issuer
3622
3623 @var{issuer_key}: holds the issuer's private key
3624
3625 @var{dig}: The message digest to use, @code{GNUTLS_DIG_SHA1} is a safe choice
3626
3627 @var{flags}: must be 0
3628
3629 This function will sign the certificate with the issuer's private key, and
3630 will copy the issuer's information into the certificate.
3631
3632 This must be the last step in a certificate generation since all
3633 the previously set parameters are now signed.
3634
3635 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3636 negative error value.
3637 @end deftypefun
3638
3639 @subheading gnutls_x509_crt_sign
3640 @anchor{gnutls_x509_crt_sign}
3641 @deftypefun {int} {gnutls_x509_crt_sign} (gnutls_x509_crt_t @var{crt}, gnutls_x509_crt_t @var{issuer}, gnutls_x509_privkey_t @var{issuer_key})
3642 @var{crt}: a certificate of type @code{gnutls_x509_crt_t}
3643
3644 @var{issuer}: is the certificate of the certificate issuer
3645
3646 @var{issuer_key}: holds the issuer's private key
3647
3648 This function is the same a @code{gnutls_x509_crt_sign2()} with no flags,
3649 and SHA1 as the hash algorithm.
3650
3651 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3652 negative error value.
3653 @end deftypefun
3654
3655 @subheading gnutls_x509_crt_verify_data
3656 @anchor{gnutls_x509_crt_verify_data}
3657 @deftypefun {int} {gnutls_x509_crt_verify_data} (gnutls_x509_crt_t @var{crt}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, const gnutls_datum_t * @var{signature})
3658 @var{crt}: Holds the certificate
3659
3660 @var{flags}: should be 0 for now
3661
3662 @var{data}: holds the data to be signed
3663
3664 @var{signature}: contains the signature
3665
3666 This function will verify the given signed data, using the
3667 parameters from the certificate.
3668
3669 Deprecated. Please use @code{gnutls_pubkey_verify_data()}.
3670
3671 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED} 
3672 is returned, and a positive code on success.
3673 @end deftypefun
3674
3675 @subheading gnutls_x509_crt_verify_hash
3676 @anchor{gnutls_x509_crt_verify_hash}
3677 @deftypefun {int} {gnutls_x509_crt_verify_hash} (gnutls_x509_crt_t @var{crt}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash}, const gnutls_datum_t * @var{signature})
3678 @var{crt}: Holds the certificate
3679
3680 @var{flags}: should be 0 for now
3681
3682 @var{hash}: holds the hash digest to be verified
3683
3684 @var{signature}: contains the signature
3685
3686 This function will verify the given signed digest, using the
3687 parameters from the certificate.
3688
3689 Deprecated. Please use @code{gnutls_pubkey_verify_data()}.
3690
3691 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED} 
3692 is returned, and a positive code on success.
3693 @end deftypefun
3694
3695 @subheading gnutls_x509_crt_verify
3696 @anchor{gnutls_x509_crt_verify}
3697 @deftypefun {int} {gnutls_x509_crt_verify} (gnutls_x509_crt_t @var{cert}, const gnutls_x509_crt_t * @var{CA_list}, int @var{CA_list_length}, unsigned int @var{flags}, unsigned int * @var{verify})
3698 @var{cert}: is the certificate to be verified
3699
3700 @var{CA_list}: is one certificate that is considered to be trusted one
3701
3702 @var{CA_list_length}: holds the number of CA certificate in CA_list
3703
3704 @var{flags}: Flags that may be used to change the verification algorithm. Use OR of the gnutls_certificate_verify_flags enumerations.
3705
3706 @var{verify}: will hold the certificate verification output.
3707
3708 This function will try to verify the given certificate and return
3709 its status.
3710
3711 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3712 negative error value.
3713 @end deftypefun
3714
3715 @subheading gnutls_x509_dn_deinit
3716 @anchor{gnutls_x509_dn_deinit}
3717 @deftypefun {void} {gnutls_x509_dn_deinit} (gnutls_x509_dn_t @var{dn})
3718 @var{dn}: a DN opaque object pointer.
3719
3720 This function deallocates the DN object as returned by
3721 @code{gnutls_x509_dn_import()}.
3722
3723 @strong{Since:} 2.4.0
3724 @end deftypefun
3725
3726 @subheading gnutls_x509_dn_export
3727 @anchor{gnutls_x509_dn_export}
3728 @deftypefun {int} {gnutls_x509_dn_export} (gnutls_x509_dn_t @var{dn}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
3729 @var{dn}: Holds the opaque DN object
3730
3731 @var{format}: the format of output params. One of PEM or DER.
3732
3733 @var{output_data}: will contain a DN PEM or DER encoded
3734
3735 @var{output_data_size}: holds the size of output_data (and will be
3736 replaced by the actual size of parameters)
3737
3738 This function will export the DN to DER or PEM format.
3739
3740 If the buffer provided is not long enough to hold the output, then
3741 *@code{output_data_size} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}
3742 will be returned.
3743
3744 If the structure is PEM encoded, it will have a header
3745 of "BEGIN NAME".
3746
3747 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3748 negative error value.
3749 @end deftypefun
3750
3751 @subheading gnutls_x509_dn_get_rdn_ava
3752 @anchor{gnutls_x509_dn_get_rdn_ava}
3753 @deftypefun {int} {gnutls_x509_dn_get_rdn_ava} (gnutls_x509_dn_t @var{dn}, int @var{irdn}, int @var{iava}, gnutls_x509_ava_st * @var{ava})
3754 @var{dn}: input variable with opaque DN pointer
3755
3756 @var{irdn}: index of RDN
3757
3758 @var{iava}: index of AVA.
3759
3760 @var{ava}: Pointer to structure which will hold output information.
3761
3762 Get pointers to data within the DN.
3763
3764 Note that @code{ava} will contain pointers into the @code{dn} structure, so you
3765 should not modify any data or deallocate it.  Note also that the DN
3766 in turn points into the original certificate structure, and thus
3767 you may not deallocate the certificate and continue to access @code{dn}.
3768
3769 @strong{Returns:} Returns 0 on success, or an error code.
3770 @end deftypefun
3771
3772 @subheading gnutls_x509_dn_import
3773 @anchor{gnutls_x509_dn_import}
3774 @deftypefun {int} {gnutls_x509_dn_import} (gnutls_x509_dn_t @var{dn}, const gnutls_datum_t * @var{data})
3775 @var{dn}: the structure that will hold the imported DN
3776
3777 @var{data}: should contain a DER encoded RDN sequence
3778
3779 This function parses an RDN sequence and stores the result to a
3780 @code{gnutls_x509_dn_t} structure. The structure must have been initialized
3781 with @code{gnutls_x509_dn_init()}. You may use @code{gnutls_x509_dn_get_rdn_ava()} to
3782 decode the DN.
3783
3784 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3785 negative error value.
3786
3787 @strong{Since:} 2.4.0
3788 @end deftypefun
3789
3790 @subheading gnutls_x509_dn_init
3791 @anchor{gnutls_x509_dn_init}
3792 @deftypefun {int} {gnutls_x509_dn_init} (gnutls_x509_dn_t * @var{dn})
3793 @var{dn}: the object to be initialized
3794
3795 This function initializes a @code{gnutls_x509_dn_t} structure.
3796
3797 The object returned must be deallocated using
3798 @code{gnutls_x509_dn_deinit()}.
3799
3800 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3801 negative error value.
3802
3803 @strong{Since:} 2.4.0
3804 @end deftypefun
3805 @subheading gnutls_x509_dn_oid_known
3806 @anchor{gnutls_x509_dn_oid_known}
3807 @deftypefun {int} {gnutls_x509_dn_oid_known} (const char * @var{oid})
3808 @var{oid}: holds an Object Identifier in a null terminated string
3809
3810 This function will inform about known DN OIDs. This is useful since
3811 functions like @code{gnutls_x509_crt_set_dn_by_oid()} use the information
3812 on known OIDs to properly encode their input. Object Identifiers
3813 that are not known are not encoded by these functions, and their
3814 input is stored directly into the ASN.1 structure. In that case of
3815 unknown OIDs, you have the responsibility of DER encoding your
3816 data.
3817
3818 @strong{Returns:} 1 on known OIDs and 0 otherwise.
3819 @end deftypefun
3820
3821 @subheading gnutls_x509_privkey_cpy
3822 @anchor{gnutls_x509_privkey_cpy}
3823 @deftypefun {int} {gnutls_x509_privkey_cpy} (gnutls_x509_privkey_t @var{dst}, gnutls_x509_privkey_t @var{src})
3824 @var{dst}: The destination key, which should be initialized.
3825
3826 @var{src}: The source key
3827
3828 This function will copy a private key from source to destination
3829 key. Destination has to be initialized.
3830
3831 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3832 negative error value.
3833 @end deftypefun
3834
3835 @subheading gnutls_x509_privkey_deinit
3836 @anchor{gnutls_x509_privkey_deinit}
3837 @deftypefun {void} {gnutls_x509_privkey_deinit} (gnutls_x509_privkey_t @var{key})
3838 @var{key}: The structure to be deinitialized
3839
3840 This function will deinitialize a private key structure.
3841 @end deftypefun
3842
3843 @subheading gnutls_x509_privkey_export_dsa_raw
3844 @anchor{gnutls_x509_privkey_export_dsa_raw}
3845 @deftypefun {int} {gnutls_x509_privkey_export_dsa_raw} (gnutls_x509_privkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y}, gnutls_datum_t * @var{x})
3846 @var{key}: a structure that holds the DSA parameters
3847
3848 @var{p}: will hold the p
3849
3850 @var{q}: will hold the q
3851
3852 @var{g}: will hold the g
3853
3854 @var{y}: will hold the y
3855
3856 @var{x}: will hold the x
3857
3858 This function will export the DSA private key's parameters found
3859 in the given structure. The new parameters will be allocated using
3860 @code{gnutls_malloc()} and will be stored in the appropriate datum.
3861
3862 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3863 negative error value.
3864 @end deftypefun
3865
3866 @subheading gnutls_x509_privkey_export_pkcs8
3867 @anchor{gnutls_x509_privkey_export_pkcs8}
3868 @deftypefun {int} {gnutls_x509_privkey_export_pkcs8} (gnutls_x509_privkey_t @var{key}, gnutls_x509_crt_fmt_t @var{format}, const char * @var{password}, unsigned int @var{flags}, void * @var{output_data}, size_t * @var{output_data_size})
3869 @var{key}: Holds the key
3870
3871 @var{format}: the format of output params. One of PEM or DER.
3872
3873 @var{password}: the password that will be used to encrypt the key.
3874
3875 @var{flags}: an ORed sequence of gnutls_pkcs_encrypt_flags_t
3876
3877 @var{output_data}: will contain a private key PEM or DER encoded
3878
3879 @var{output_data_size}: holds the size of output_data (and will be
3880 replaced by the actual size of parameters)
3881
3882 This function will export the private key to a PKCS8 structure.
3883 Both RSA and DSA keys can be exported. For DSA keys we use
3884 PKCS @code{11} definitions. If the flags do not specify the encryption
3885 cipher, then the default 3DES (PBES2) will be used.
3886
3887 The @code{password} can be either ASCII or UTF-8 in the default PBES2
3888 encryption schemas, or ASCII for the PKCS12 schemas.
3889
3890 If the buffer provided is not long enough to hold the output, then
3891 *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
3892 be returned.
3893
3894 If the structure is PEM encoded, it will have a header
3895 of "BEGIN ENCRYPTED PRIVATE KEY" or "BEGIN PRIVATE KEY" if
3896 encryption is not used.
3897
3898 @strong{Return value:} In case of failure a negative value will be
3899 returned, and 0 on success.
3900 @end deftypefun
3901
3902 @subheading gnutls_x509_privkey_export_rsa_raw2
3903 @anchor{gnutls_x509_privkey_export_rsa_raw2}
3904 @deftypefun {int} {gnutls_x509_privkey_export_rsa_raw2} (gnutls_x509_privkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e}, gnutls_datum_t * @var{d}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{u}, gnutls_datum_t * @var{e1}, gnutls_datum_t * @var{e2})
3905 @var{key}: a structure that holds the rsa parameters
3906
3907 @var{m}: will hold the modulus
3908
3909 @var{e}: will hold the public exponent
3910
3911 @var{d}: will hold the private exponent
3912
3913 @var{p}: will hold the first prime (p)
3914
3915 @var{q}: will hold the second prime (q)
3916
3917 @var{u}: will hold the coefficient
3918
3919 @var{e1}: will hold e1 = d mod (p-1)
3920
3921 @var{e2}: will hold e2 = d mod (q-1)
3922
3923 This function will export the RSA private key's parameters found
3924 in the given structure. The new parameters will be allocated using
3925 @code{gnutls_malloc()} and will be stored in the appropriate datum.
3926
3927 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3928 negative error value.
3929 @end deftypefun
3930
3931 @subheading gnutls_x509_privkey_export_rsa_raw
3932 @anchor{gnutls_x509_privkey_export_rsa_raw}
3933 @deftypefun {int} {gnutls_x509_privkey_export_rsa_raw} (gnutls_x509_privkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e}, gnutls_datum_t * @var{d}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{u})
3934 @var{key}: a structure that holds the rsa parameters
3935
3936 @var{m}: will hold the modulus
3937
3938 @var{e}: will hold the public exponent
3939
3940 @var{d}: will hold the private exponent
3941
3942 @var{p}: will hold the first prime (p)
3943
3944 @var{q}: will hold the second prime (q)
3945
3946 @var{u}: will hold the coefficient
3947
3948 This function will export the RSA private key's parameters found
3949 in the given structure. The new parameters will be allocated using
3950 @code{gnutls_malloc()} and will be stored in the appropriate datum.
3951
3952 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3953 negative error value.
3954 @end deftypefun
3955
3956 @subheading gnutls_x509_privkey_export
3957 @anchor{gnutls_x509_privkey_export}
3958 @deftypefun {int} {gnutls_x509_privkey_export} (gnutls_x509_privkey_t @var{key}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
3959 @var{key}: Holds the key
3960
3961 @var{format}: the format of output params. One of PEM or DER.
3962
3963 @var{output_data}: will contain a private key PEM or DER encoded
3964
3965 @var{output_data_size}: holds the size of output_data (and will be
3966 replaced by the actual size of parameters)
3967
3968 This function will export the private key to a PKCS1 structure for
3969 RSA keys, or an integer sequence for DSA keys.  The DSA keys are in
3970 the same format with the parameters used by openssl.
3971
3972 If the buffer provided is not long enough to hold the output, then
3973 *@code{output_data_size} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}
3974 will be returned.
3975
3976 If the structure is PEM encoded, it will have a header
3977 of "BEGIN RSA PRIVATE KEY".
3978
3979 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3980 negative error value.
3981 @end deftypefun
3982
3983 @subheading gnutls_x509_privkey_fix
3984 @anchor{gnutls_x509_privkey_fix}
3985 @deftypefun {int} {gnutls_x509_privkey_fix} (gnutls_x509_privkey_t @var{key})
3986 @var{key}: Holds the key
3987
3988 This function will recalculate the secondary parameters in a key.
3989 In RSA keys, this can be the coefficient and exponent1,2.
3990
3991 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
3992 negative error value.
3993 @end deftypefun
3994
3995 @subheading gnutls_x509_privkey_generate
3996 @anchor{gnutls_x509_privkey_generate}
3997 @deftypefun {int} {gnutls_x509_privkey_generate} (gnutls_x509_privkey_t @var{key}, gnutls_pk_algorithm_t @var{algo}, unsigned int @var{bits}, unsigned int @var{flags})
3998 @var{key}: should contain a @code{gnutls_x509_privkey_t} structure
3999
4000 @var{algo}: is one of RSA or DSA.
4001
4002 @var{bits}: the size of the modulus
4003
4004 @var{flags}: unused for now.  Must be 0.
4005
4006 This function will generate a random private key. Note that this
4007 function must be called on an empty private key.
4008
4009 Do not set the number of bits directly, use @code{gnutls_sec_param_to_pk_bits()}.
4010
4011 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4012 negative error value.
4013 @end deftypefun
4014
4015 @subheading gnutls_x509_privkey_get_key_id
4016 @anchor{gnutls_x509_privkey_get_key_id}
4017 @deftypefun {int} {gnutls_x509_privkey_get_key_id} (gnutls_x509_privkey_t @var{key}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size})
4018 @var{key}: Holds the key
4019
4020 @var{flags}: should be 0 for now
4021
4022 @var{output_data}: will contain the key ID
4023
4024 @var{output_data_size}: holds the size of output_data (and will be
4025 replaced by the actual size of parameters)
4026
4027 This function will return a unique ID the depends on the public key
4028 parameters. This ID can be used in checking whether a certificate
4029 corresponds to the given key.
4030
4031 If the buffer provided is not long enough to hold the output, then
4032 *@code{output_data_size} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will
4033 be returned.  The output will normally be a SHA-1 hash output,
4034 which is 20 bytes.
4035
4036 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4037 negative error value.
4038 @end deftypefun
4039
4040 @subheading gnutls_x509_privkey_get_pk_algorithm
4041 @anchor{gnutls_x509_privkey_get_pk_algorithm}
4042 @deftypefun {int} {gnutls_x509_privkey_get_pk_algorithm} (gnutls_x509_privkey_t @var{key})
4043 @var{key}: should contain a @code{gnutls_x509_privkey_t} structure
4044
4045 This function will return the public key algorithm of a private
4046 key.
4047
4048 @strong{Returns:} a member of the @code{gnutls_pk_algorithm_t} enumeration on
4049 success, or a negative value on error.
4050 @end deftypefun
4051
4052 @subheading gnutls_x509_privkey_import_dsa_raw
4053 @anchor{gnutls_x509_privkey_import_dsa_raw}
4054 @deftypefun {int} {gnutls_x509_privkey_import_dsa_raw} (gnutls_x509_privkey_t @var{key}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{g}, const gnutls_datum_t * @var{y}, const gnutls_datum_t * @var{x})
4055 @var{key}: The structure to store the parsed key
4056
4057 @var{p}: holds the p
4058
4059 @var{q}: holds the q
4060
4061 @var{g}: holds the g
4062
4063 @var{y}: holds the y
4064
4065 @var{x}: holds the x
4066
4067 This function will convert the given DSA raw parameters to the
4068 native @code{gnutls_x509_privkey_t} format.  The output will be stored
4069 in @code{key}.
4070
4071 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4072 negative error value.
4073 @end deftypefun
4074
4075 @subheading gnutls_x509_privkey_import_pkcs8
4076 @anchor{gnutls_x509_privkey_import_pkcs8}
4077 @deftypefun {int} {gnutls_x509_privkey_import_pkcs8} (gnutls_x509_privkey_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, const char * @var{password}, unsigned int @var{flags})
4078 @var{key}: The structure to store the parsed key
4079
4080 @var{data}: The DER or PEM encoded key.
4081
4082 @var{format}: One of DER or PEM
4083
4084 @var{password}: the password to decrypt the key (if it is encrypted).
4085
4086 @var{flags}: 0 if encrypted or GNUTLS_PKCS_PLAIN if not encrypted.
4087
4088 This function will convert the given DER or PEM encoded PKCS8 2.0
4089 encrypted key to the native gnutls_x509_privkey_t format. The
4090 output will be stored in @code{key}.  Both RSA and DSA keys can be
4091 imported, and flags can only be used to indicate an unencrypted
4092 key.
4093
4094 The @code{password} can be either ASCII or UTF-8 in the default PBES2
4095 encryption schemas, or ASCII for the PKCS12 schemas.
4096
4097 If the Certificate is PEM encoded it should have a header of
4098 "ENCRYPTED PRIVATE KEY", or "PRIVATE KEY". You only need to
4099 specify the flags if the key is DER encoded, since in that case
4100 the encryption status cannot be auto-detected.
4101
4102 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4103 negative error value.
4104 @end deftypefun
4105
4106 @subheading gnutls_x509_privkey_import_rsa_raw2
4107 @anchor{gnutls_x509_privkey_import_rsa_raw2}
4108 @deftypefun {int} {gnutls_x509_privkey_import_rsa_raw2} (gnutls_x509_privkey_t @var{key}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e}, const gnutls_datum_t * @var{d}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{u}, const gnutls_datum_t * @var{e1}, const gnutls_datum_t * @var{e2})
4109 @var{key}: The structure to store the parsed key
4110
4111 @var{m}: holds the modulus
4112
4113 @var{e}: holds the public exponent
4114
4115 @var{d}: holds the private exponent
4116
4117 @var{p}: holds the first prime (p)
4118
4119 @var{q}: holds the second prime (q)
4120
4121 @var{u}: holds the coefficient
4122
4123 @var{e1}: holds e1 = d mod (p-1)
4124
4125 @var{e2}: holds e2 = d mod (q-1)
4126
4127 This function will convert the given RSA raw parameters to the
4128 native @code{gnutls_x509_privkey_t} format.  The output will be stored in
4129 @code{key}.
4130
4131 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4132 negative error value.
4133 @end deftypefun
4134
4135 @subheading gnutls_x509_privkey_import_rsa_raw
4136 @anchor{gnutls_x509_privkey_import_rsa_raw}
4137 @deftypefun {int} {gnutls_x509_privkey_import_rsa_raw} (gnutls_x509_privkey_t @var{key}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e}, const gnutls_datum_t * @var{d}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{u})
4138 @var{key}: The structure to store the parsed key
4139
4140 @var{m}: holds the modulus
4141
4142 @var{e}: holds the public exponent
4143
4144 @var{d}: holds the private exponent
4145
4146 @var{p}: holds the first prime (p)
4147
4148 @var{q}: holds the second prime (q)
4149
4150 @var{u}: holds the coefficient
4151
4152 This function will convert the given RSA raw parameters to the
4153 native @code{gnutls_x509_privkey_t} format.  The output will be stored in
4154 @code{key}.
4155
4156 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4157 negative error value.
4158 @end deftypefun
4159
4160 @subheading gnutls_x509_privkey_import
4161 @anchor{gnutls_x509_privkey_import}
4162 @deftypefun {int} {gnutls_x509_privkey_import} (gnutls_x509_privkey_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
4163 @var{key}: The structure to store the parsed key
4164
4165 @var{data}: The DER or PEM encoded certificate.
4166
4167 @var{format}: One of DER or PEM
4168
4169 This function will convert the given DER or PEM encoded key to the
4170 native @code{gnutls_x509_privkey_t} format. The output will be stored in
4171 @code{key} .
4172
4173 If the key is PEM encoded it should have a header of "RSA PRIVATE
4174 KEY", or "DSA PRIVATE KEY".
4175
4176 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4177 negative error value.
4178 @end deftypefun
4179
4180 @subheading gnutls_x509_privkey_init
4181 @anchor{gnutls_x509_privkey_init}
4182 @deftypefun {int} {gnutls_x509_privkey_init} (gnutls_x509_privkey_t * @var{key})
4183 @var{key}: The structure to be initialized
4184
4185 This function will initialize an private key structure.
4186
4187 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4188 negative error value.
4189 @end deftypefun
4190
4191 @subheading gnutls_x509_privkey_sec_param
4192 @anchor{gnutls_x509_privkey_sec_param}
4193 @deftypefun {gnutls_sec_param_t} {gnutls_x509_privkey_sec_param} (gnutls_x509_privkey_t @var{key})
4194 @var{key}: a key structure
4195
4196 This function will return the security parameter appropriate with
4197 this private key.
4198
4199 @strong{Returns:} On success, a valid security parameter is returned otherwise
4200 @code{GNUTLS_SEC_PARAM_UNKNOWN} is returned.
4201 @end deftypefun
4202
4203 @subheading gnutls_x509_privkey_sign_data
4204 @anchor{gnutls_x509_privkey_sign_data}
4205 @deftypefun {int} {gnutls_x509_privkey_sign_data} (gnutls_x509_privkey_t @var{key}, gnutls_digest_algorithm_t @var{digest}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, void * @var{signature}, size_t * @var{signature_size})
4206 @var{key}: Holds the key
4207
4208 @var{digest}: should be MD5 or SHA1
4209
4210 @var{flags}: should be 0 for now
4211
4212 @var{data}: holds the data to be signed
4213
4214 @var{signature}: will contain the signature
4215
4216 @var{signature_size}: holds the size of signature (and will be replaced
4217 by the new size)
4218
4219 This function will sign the given data using a signature algorithm
4220 supported by the private key. Signature algorithms are always used
4221 together with a hash functions.  Different hash functions may be
4222 used for the RSA algorithm, but only SHA-1 for the DSA keys.
4223
4224 If the buffer provided is not long enough to hold the output, then
4225 *@code{signature_size} is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER} will
4226 be returned.
4227
4228 Use @code{gnutls_x509_crt_get_preferred_hash_algorithm()} to determine
4229 the hash algorithm.
4230
4231 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4232 negative error value.
4233
4234 @strong{Deprecated:} Use @code{gnutls_privkey_sign_data()}.
4235 @end deftypefun
4236
4237 @subheading gnutls_x509_privkey_sign_hash
4238 @anchor{gnutls_x509_privkey_sign_hash}
4239 @deftypefun {int} {gnutls_x509_privkey_sign_hash} (gnutls_x509_privkey_t @var{key}, const gnutls_datum_t * @var{hash}, gnutls_datum_t * @var{signature})
4240 @var{key}: Holds the key
4241
4242 @var{hash}: holds the data to be signed
4243
4244 @var{signature}: will contain newly allocated signature
4245
4246 This function will sign the given hash using the private key. Do not
4247 use this function directly unless you know what it is. Typical signing
4248 requires the data to be hashed and stored in special formats 
4249 (e.g. BER Digest-Info for RSA).
4250
4251 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
4252 negative error value.
4253
4254 @strong{Deprecated in:} 2.12.0
4255 @end deftypefun
4256
4257 @subheading gnutls_x509_privkey_verify_data
4258 @anchor{gnutls_x509_privkey_verify_data}
4259 @deftypefun {int} {gnutls_x509_privkey_verify_data} (gnutls_x509_privkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, const gnutls_datum_t * @var{signature})
4260 @var{key}: Holds the key
4261
4262 @var{flags}: should be 0 for now
4263
4264 @var{data}: holds the data to be signed
4265
4266 @var{signature}: contains the signature
4267
4268 This function will verify the given signed data, using the
4269 parameters in the private key.
4270
4271 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED} 
4272 is returned, and a positive code on success.
4273
4274 @strong{Deprecated:} Use @code{gnutls_pubkey_verify_data()}.
4275 @end deftypefun
4276
4277 @subheading gnutls_x509_rdn_get_by_oid
4278 @anchor{gnutls_x509_rdn_get_by_oid}
4279 @deftypefun {int} {gnutls_x509_rdn_get_by_oid} (const gnutls_datum_t * @var{idn}, const char * @var{oid}, int @var{indx}, unsigned int @var{raw_flag}, void * @var{buf}, size_t * @var{sizeof_buf})
4280 @var{idn}: should contain a DER encoded RDN sequence
4281
4282 @var{oid}: an Object Identifier
4283
4284 @var{indx}: In case multiple same OIDs exist in the RDN indicates which
4285 to send. Use 0 for the first one.
4286
4287 @var{raw_flag}: If non zero then the raw DER data are returned.
4288
4289 @var{buf}: a pointer to a structure to hold the peer's name
4290
4291 @var{sizeof_buf}: holds the size of @code{buf}
4292
4293 This function will return the name of the given Object identifier,
4294 of the RDN sequence.  The name will be encoded using the rules
4295 from RFC2253.
4296
4297 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, or
4298 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} is returned and *@code{sizeof_buf} is
4299 updated if the provided buffer is not long enough, otherwise a
4300 negative error value.
4301 @end deftypefun
4302
4303 @subheading gnutls_x509_rdn_get_oid
4304 @anchor{gnutls_x509_rdn_get_oid}
4305 @deftypefun {int} {gnutls_x509_rdn_get_oid} (const gnutls_datum_t * @var{idn}, int @var{indx}, void * @var{buf}, size_t * @var{sizeof_buf})
4306 @var{idn}: should contain a DER encoded RDN sequence
4307
4308 @var{indx}: Indicates which OID to return. Use 0 for the first one.
4309
4310 @var{buf}: a pointer to a structure to hold the peer's name OID
4311
4312 @var{sizeof_buf}: holds the size of @code{buf}
4313
4314 This function will return the specified Object identifier, of the
4315 RDN sequence.
4316
4317 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, or
4318 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} is returned and *@code{sizeof_buf} is
4319 updated if the provided buffer is not long enough, otherwise a
4320 negative error value.
4321
4322 @strong{Since:} 2.4.0
4323 @end deftypefun
4324
4325 @subheading gnutls_x509_rdn_get
4326 @anchor{gnutls_x509_rdn_get}
4327 @deftypefun {int} {gnutls_x509_rdn_get} (const gnutls_datum_t * @var{idn}, char * @var{buf}, size_t * @var{sizeof_buf})
4328 @var{idn}: should contain a DER encoded RDN sequence
4329
4330 @var{buf}: a pointer to a structure to hold the peer's name
4331
4332 @var{sizeof_buf}: holds the size of @code{buf}
4333
4334 This function will return the name of the given RDN sequence.  The
4335 name will be in the form "C=xxxx,O=yyyy,CN=zzzz" as described in
4336 RFC2253.
4337
4338 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, or
4339 @code{GNUTLS_E_SHORT_MEMORY_BUFFER} is returned and *@code{sizeof_buf} is
4340 updated if the provided buffer is not long enough, otherwise a
4341 negative error value.
4342 @end deftypefun