Imported Upstream version 3.0.30
[platform/upstream/gnutls.git] / doc / abstract-api.texi
1
2 @subheading gnutls_certificate_set_key
3 @anchor{gnutls_certificate_set_key}
4 @deftypefun {int} {gnutls_certificate_set_key} (gnutls_certificate_credentials_t @var{res}, const char** @var{names}, int @var{names_size}, gnutls_pcert_st * @var{pcert_list}, int @var{pcert_list_size}, gnutls_privkey_t @var{key})
5 @var{res}: is a @code{gnutls_certificate_credentials_t}  structure.
6
7 @var{names}: is an array of DNS name of the certificate (NULL if none)
8
9 @var{names_size}: holds the size of the names list
10
11 @var{pcert_list}: contains a certificate list (path) for the specified private key
12
13 @var{pcert_list_size}: holds the size of the certificate list
14
15 @var{key}: is a gnutls_x509_privkey_t key
16
17 This function sets a certificate/private key pair in the
18 gnutls_certificate_credentials_t structure.  This function may be
19 called more than once, in case multiple keys/certificates exist for
20 the server.  For clients that wants to send more than its own end
21 entity certificate (e.g., also an intermediate CA cert) then put
22 the certificate chain in  @code{pcert_list} . The  @code{pcert_list} and  @code{key} will
23 become part of the credentials structure and must not
24 be deallocated. They will be automatically deallocated when
25  @code{res} is deinitialized.
26
27 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  (0) on success, or a negative error code.
28
29 @strong{Since:} 3.0
30 @end deftypefun
31
32 @subheading gnutls_certificate_set_retrieve_function2
33 @anchor{gnutls_certificate_set_retrieve_function2}
34 @deftypefun {void} {gnutls_certificate_set_retrieve_function2} (gnutls_certificate_credentials_t @var{cred}, gnutls_certificate_retrieve_function2 * @var{func})
35 @var{cred}: is a @code{gnutls_certificate_credentials_t}  structure.
36
37 @var{func}: is the callback function
38
39 This function sets a callback to be called in order to retrieve the
40 certificate to be used in the handshake.
41
42 The callback's function prototype is:
43 int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
44 const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_pcert_st** pcert,
45 unsigned int *pcert_length, gnutls_privkey_t * pkey);
46
47  @code{req_ca_cert} is only used in X.509 certificates.
48 Contains a list with the CA names that the server considers trusted.
49 Normally we should send a certificate that is signed
50 by one of these CAs. These names are DER encoded. To get a more
51 meaningful value use the function @code{gnutls_x509_rdn_get()} .
52
53  @code{pk_algos} contains a list with server's acceptable signature algorithms.
54 The certificate returned should support the server's given algorithms.
55
56  @code{pcert} should contain a single certificate and public or a list of them.
57
58  @code{pcert_length} is the size of the previous list.
59
60  @code{pkey} is the private key.
61
62 If the callback function is provided then gnutls will call it, in the
63 handshake, after the certificate request message has been received.
64
65 In server side pk_algos and req_ca_dn are NULL.
66
67 The callback function should set the certificate list to be sent,
68 and return 0 on success. If no certificate was selected then the
69 number of certificates should be set to zero. The value (-1)
70 indicates error and the handshake will be terminated.
71
72 @strong{Since:} 3.0
73 @end deftypefun
74
75 @subheading gnutls_pcert_deinit
76 @anchor{gnutls_pcert_deinit}
77 @deftypefun {void} {gnutls_pcert_deinit} (gnutls_pcert_st * @var{pcert})
78 @var{pcert}: The structure to be deinitialized
79
80 This function will deinitialize a pcert structure.
81
82 @strong{Since:} 3.0
83 @end deftypefun
84
85 @subheading gnutls_pcert_import_openpgp
86 @anchor{gnutls_pcert_import_openpgp}
87 @deftypefun {int} {gnutls_pcert_import_openpgp} (gnutls_pcert_st* @var{pcert}, gnutls_openpgp_crt_t @var{crt}, unsigned int @var{flags})
88 @var{pcert}: The pcert structure
89
90 @var{crt}: The raw certificate to be imported
91
92 @var{flags}: zero for now
93
94 This convenience function will import the given certificate to a
95 @code{gnutls_pcert_st}  structure. The structure must be deinitialized
96 afterwards using @code{gnutls_pcert_deinit()} ;
97
98 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
99 negative error value.
100
101 @strong{Since:} 3.0
102 @end deftypefun
103
104 @subheading gnutls_pcert_import_openpgp_raw
105 @anchor{gnutls_pcert_import_openpgp_raw}
106 @deftypefun {int} {gnutls_pcert_import_openpgp_raw} (gnutls_pcert_st * @var{pcert}, const gnutls_datum_t* @var{cert}, gnutls_openpgp_crt_fmt_t @var{format}, gnutls_openpgp_keyid_t @var{keyid}, unsigned int @var{flags})
107 @var{pcert}: The pcert structure
108
109 @var{cert}: The raw certificate to be imported
110
111 @var{format}: The format of the certificate
112
113 @var{keyid}: The key ID to use (NULL for the master key)
114
115 @var{flags}: zero for now
116
117 This convenience function will import the given certificate to a
118 @code{gnutls_pcert_st}  structure. The structure must be deinitialized
119 afterwards using @code{gnutls_pcert_deinit()} ;
120
121 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
122 negative error value.
123
124 @strong{Since:} 3.0
125 @end deftypefun
126
127 @subheading gnutls_pcert_import_x509
128 @anchor{gnutls_pcert_import_x509}
129 @deftypefun {int} {gnutls_pcert_import_x509} (gnutls_pcert_st* @var{pcert}, gnutls_x509_crt_t @var{crt}, unsigned int @var{flags})
130 @var{pcert}: The pcert structure
131
132 @var{crt}: The raw certificate to be imported
133
134 @var{flags}: zero for now
135
136 This convenience function will import the given certificate to a
137 @code{gnutls_pcert_st}  structure. The structure must be deinitialized
138 afterwards using @code{gnutls_pcert_deinit()} ;
139
140 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
141 negative error value.
142
143 @strong{Since:} 3.0
144 @end deftypefun
145
146 @subheading gnutls_pcert_import_x509_raw
147 @anchor{gnutls_pcert_import_x509_raw}
148 @deftypefun {int} {gnutls_pcert_import_x509_raw} (gnutls_pcert_st * @var{pcert}, const gnutls_datum_t* @var{cert}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
149 @var{pcert}: The pcert structure
150
151 @var{cert}: The raw certificate to be imported
152
153 @var{format}: The format of the certificate
154
155 @var{flags}: zero for now
156
157 This convenience function will import the given certificate to a
158 @code{gnutls_pcert_st}  structure. The structure must be deinitialized
159 afterwards using @code{gnutls_pcert_deinit()} ;
160
161 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
162 negative error value.
163
164 @strong{Since:} 3.0
165 @end deftypefun
166
167 @subheading gnutls_pcert_list_import_x509_raw
168 @anchor{gnutls_pcert_list_import_x509_raw}
169 @deftypefun {int} {gnutls_pcert_list_import_x509_raw} (gnutls_pcert_st * @var{pcerts}, unsigned int * @var{pcert_max}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format}, unsigned int @var{flags})
170 @var{pcerts}: The structures to store the parsed certificate. Must not be initialized.
171
172 @var{pcert_max}: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
173
174 @var{data}: The certificates.
175
176 @var{format}: One of DER or PEM.
177
178 @var{flags}: must be (0) or an OR'd sequence of gnutls_certificate_import_flags.
179
180 This function will convert the given PEM encoded certificate list
181 to the native gnutls_x509_crt_t format. The output will be stored
182 in  @code{certs} .  They will be automatically initialized.
183
184 If the Certificate is PEM encoded it should have a header of "X509
185 CERTIFICATE", or "CERTIFICATE".
186
187 @strong{Returns:} the number of certificates read or a negative error value.
188
189 @strong{Since:} 3.0
190 @end deftypefun
191
192 @subheading gnutls_privkey_decrypt_data
193 @anchor{gnutls_privkey_decrypt_data}
194 @deftypefun {int} {gnutls_privkey_decrypt_data} (gnutls_privkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{ciphertext}, gnutls_datum_t * @var{plaintext})
195 @var{key}: Holds the key
196
197 @var{flags}: zero for now
198
199 @var{ciphertext}: holds the data to be decrypted
200
201 @var{plaintext}: will contain the decrypted data, allocated with @code{gnutls_malloc()} 
202
203 This function will decrypt the given data using the algorithm
204 supported by the private key.
205
206 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
207 negative error value.
208
209 @strong{Since:} 2.12.0
210 @end deftypefun
211
212 @subheading gnutls_privkey_deinit
213 @anchor{gnutls_privkey_deinit}
214 @deftypefun {void} {gnutls_privkey_deinit} (gnutls_privkey_t @var{key})
215 @var{key}: The structure to be deinitialized
216
217 This function will deinitialize a private key structure.
218
219 @strong{Since:} 2.12.0
220 @end deftypefun
221
222 @subheading gnutls_privkey_get_pk_algorithm
223 @anchor{gnutls_privkey_get_pk_algorithm}
224 @deftypefun {int} {gnutls_privkey_get_pk_algorithm} (gnutls_privkey_t @var{key}, unsigned int * @var{bits})
225 @var{key}: should contain a @code{gnutls_privkey_t}  structure
226
227 @var{bits}: If set will return the number of bits of the parameters (may be NULL)
228
229 This function will return the public key algorithm of a private
230 key and if possible will return a number of bits that indicates
231 the security parameter of the key.
232
233 @strong{Returns:} a member of the @code{gnutls_pk_algorithm_t}  enumeration on
234 success, or a negative error code on error.
235
236 @strong{Since:} 2.12.0
237 @end deftypefun
238
239 @subheading gnutls_privkey_get_type
240 @anchor{gnutls_privkey_get_type}
241 @deftypefun {gnutls_privkey_type_t} {gnutls_privkey_get_type} (gnutls_privkey_t @var{key})
242 @var{key}: should contain a @code{gnutls_privkey_t}  structure
243
244 This function will return the type of the private key. This is
245 actually the type of the subsystem used to set this private key.
246
247 @strong{Returns:} a member of the @code{gnutls_privkey_type_t}  enumeration on
248 success, or a negative error code on error.
249
250 @strong{Since:} 2.12.0
251 @end deftypefun
252
253 @subheading gnutls_privkey_import_ext
254 @anchor{gnutls_privkey_import_ext}
255 @deftypefun {int} {gnutls_privkey_import_ext} (gnutls_privkey_t @var{pkey}, gnutls_pk_algorithm_t @var{pk}, void* @var{userdata}, gnutls_privkey_sign_func @var{sign_func}, gnutls_privkey_decrypt_func @var{decrypt_func}, unsigned int @var{flags})
256 @var{pkey}: The private key
257
258 @var{pk}: The public key algorithm
259
260 @var{userdata}: private data to be provided to the callbacks
261
262 @var{sign_func}: callback for signature operations
263
264 @var{decrypt_func}: callback for decryption operations
265
266 @var{flags}: Flags for the import
267
268 This function will associate the given callbacks with the
269 @code{gnutls_privkey_t}  structure. At least one of the two callbacks
270 must be non-null.
271
272 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
273 negative error value.
274
275 @strong{Since:} 3.0
276 @end deftypefun
277
278 @subheading gnutls_privkey_import_openpgp
279 @anchor{gnutls_privkey_import_openpgp}
280 @deftypefun {int} {gnutls_privkey_import_openpgp} (gnutls_privkey_t @var{pkey}, gnutls_openpgp_privkey_t @var{key}, unsigned int @var{flags})
281 @var{pkey}: The private key
282
283 @var{key}: The private key to be imported
284
285 @var{flags}: Flags for the import
286
287 This function will import the given private key to the abstract
288 @code{gnutls_privkey_t}  structure.
289
290 The @code{gnutls_openpgp_privkey_t}  object must not be deallocated
291 during the lifetime of this structure. The subkey set as
292 preferred will be used, or the master key otherwise.
293
294  @code{flags} might be zero or one of @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} 
295 and @code{GNUTLS_PRIVKEY_IMPORT_COPY} .
296
297 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
298 negative error value.
299
300 @strong{Since:} 2.12.0
301 @end deftypefun
302
303 @subheading gnutls_privkey_import_pkcs11
304 @anchor{gnutls_privkey_import_pkcs11}
305 @deftypefun {int} {gnutls_privkey_import_pkcs11} (gnutls_privkey_t @var{pkey}, gnutls_pkcs11_privkey_t @var{key}, unsigned int @var{flags})
306 @var{pkey}: The private key
307
308 @var{key}: The private key to be imported
309
310 @var{flags}: Flags for the import
311
312 This function will import the given private key to the abstract
313 @code{gnutls_privkey_t}  structure.
314
315 The @code{gnutls_pkcs11_privkey_t}  object must not be deallocated
316 during the lifetime of this structure.
317
318  @code{flags} might be zero or one of @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} 
319 and @code{GNUTLS_PRIVKEY_IMPORT_COPY} .
320
321 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
322 negative error value.
323
324 @strong{Since:} 2.12.0
325 @end deftypefun
326
327 @subheading gnutls_privkey_import_x509
328 @anchor{gnutls_privkey_import_x509}
329 @deftypefun {int} {gnutls_privkey_import_x509} (gnutls_privkey_t @var{pkey}, gnutls_x509_privkey_t @var{key}, unsigned int @var{flags})
330 @var{pkey}: The private key
331
332 @var{key}: The private key to be imported
333
334 @var{flags}: Flags for the import
335
336 This function will import the given private key to the abstract
337 @code{gnutls_privkey_t}  structure.
338
339 The @code{gnutls_x509_privkey_t}  object must not be deallocated
340 during the lifetime of this structure.
341
342  @code{flags} might be zero or one of @code{GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE} 
343 and @code{GNUTLS_PRIVKEY_IMPORT_COPY} .
344
345 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
346 negative error value.
347
348 @strong{Since:} 2.12.0
349 @end deftypefun
350
351 @subheading gnutls_privkey_init
352 @anchor{gnutls_privkey_init}
353 @deftypefun {int} {gnutls_privkey_init} (gnutls_privkey_t * @var{key})
354 @var{key}: The structure to be initialized
355
356 This function will initialize an private key structure.
357
358 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
359 negative error value.
360
361 @strong{Since:} 2.12.0
362 @end deftypefun
363
364 @subheading gnutls_privkey_sign_data
365 @anchor{gnutls_privkey_sign_data}
366 @deftypefun {int} {gnutls_privkey_sign_data} (gnutls_privkey_t @var{signer}, gnutls_digest_algorithm_t @var{hash}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, gnutls_datum_t * @var{signature})
367 @var{signer}: Holds the key
368
369 @var{hash}: should be a digest algorithm
370
371 @var{flags}: should be 0 for now
372
373 @var{data}: holds the data to be signed
374
375 @var{signature}: will contain the signature allocate with @code{gnutls_malloc()} 
376
377 This function will sign the given data using a signature algorithm
378 supported by the private key. Signature algorithms are always used
379 together with a hash functions.  Different hash functions may be
380 used for the RSA algorithm, but only the SHA family for the DSA keys.
381
382 Use @code{gnutls_pubkey_get_preferred_hash_algorithm()}  to determine
383 the hash algorithm.
384
385 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
386 negative error value.
387
388 @strong{Since:} 2.12.0
389 @end deftypefun
390
391 @subheading gnutls_privkey_sign_hash
392 @anchor{gnutls_privkey_sign_hash}
393 @deftypefun {int} {gnutls_privkey_sign_hash} (gnutls_privkey_t @var{signer}, gnutls_digest_algorithm_t @var{hash_algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash_data}, gnutls_datum_t * @var{signature})
394 @var{signer}: Holds the signer's key
395
396 @var{hash_algo}: The hash algorithm used
397
398 @var{flags}: zero for now
399
400 @var{hash_data}: holds the data to be signed
401
402 @var{signature}: will contain newly allocated signature
403
404 This function will sign the given hashed data using a signature algorithm
405 supported by the private key. Signature algorithms are always used
406 together with a hash functions.  Different hash functions may be
407 used for the RSA algorithm, but only SHA-XXX for the DSA keys.
408
409 Use @code{gnutls_pubkey_get_preferred_hash_algorithm()}  to determine
410 the hash algorithm.
411
412 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
413 negative error value.
414
415 @strong{Since:} 2.12.0
416 @end deftypefun
417
418 @subheading gnutls_pubkey_deinit
419 @anchor{gnutls_pubkey_deinit}
420 @deftypefun {void} {gnutls_pubkey_deinit} (gnutls_pubkey_t @var{key})
421 @var{key}: The structure to be deinitialized
422
423 This function will deinitialize a public key structure.
424
425 @strong{Since:} 2.12.0
426 @end deftypefun
427
428 @subheading gnutls_pubkey_encrypt_data
429 @anchor{gnutls_pubkey_encrypt_data}
430 @deftypefun {int} {gnutls_pubkey_encrypt_data} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{plaintext}, gnutls_datum_t * @var{ciphertext})
431 @var{key}: Holds the public key
432
433 @var{flags}: should be 0 for now
434
435 @var{plaintext}: The data to be encrypted
436
437 @var{ciphertext}: contains the encrypted data
438
439 This function will encrypt the given data, using the public
440 key.
441
442 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
443 negative error value.
444
445 @strong{Since:} 3.0
446 @end deftypefun
447
448 @subheading gnutls_pubkey_export
449 @anchor{gnutls_pubkey_export}
450 @deftypefun {int} {gnutls_pubkey_export} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
451 @var{key}: Holds the certificate
452
453 @var{format}: the format of output params. One of PEM or DER.
454
455 @var{output_data}: will contain a certificate PEM or DER encoded
456
457 @var{output_data_size}: holds the size of output_data (and will be
458 replaced by the actual size of parameters)
459
460 This function will export the public key to DER or PEM format.
461 The contents of the exported data is the SubjectPublicKeyInfo
462 X.509 structure.
463
464 If the buffer provided is not long enough to hold the output, then
465 *output_data_size is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}  will
466 be returned.
467
468 If the structure is PEM encoded, it will have a header
469 of "BEGIN CERTIFICATE".
470
471 @strong{Returns:} In case of failure a negative error code will be
472 returned, and 0 on success.
473
474 @strong{Since:} 2.12.0
475 @end deftypefun
476
477 @subheading gnutls_pubkey_get_key_id
478 @anchor{gnutls_pubkey_get_key_id}
479 @deftypefun {int} {gnutls_pubkey_get_key_id} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size})
480 @var{key}: Holds the public key
481
482 @var{flags}: should be 0 for now
483
484 @var{output_data}: will contain the key ID
485
486 @var{output_data_size}: holds the size of output_data (and will be
487 replaced by the actual size of parameters)
488
489 This function will return a unique ID the depends on the public
490 key parameters. This ID can be used in checking whether a
491 certificate corresponds to the given public key.
492
493 If the buffer provided is not long enough to hold the output, then
494 *output_data_size is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}  will
495 be returned.  The output will normally be a SHA-1 hash output,
496 which is 20 bytes.
497
498 @strong{Returns:} In case of failure a negative error code will be
499 returned, and 0 on success.
500
501 @strong{Since:} 2.12.0
502 @end deftypefun
503
504 @subheading gnutls_pubkey_get_key_usage
505 @anchor{gnutls_pubkey_get_key_usage}
506 @deftypefun {int} {gnutls_pubkey_get_key_usage} (gnutls_pubkey_t @var{key}, unsigned int * @var{usage})
507 @var{key}: should contain a @code{gnutls_pubkey_t}  structure
508
509 @var{usage}: If set will return the number of bits of the parameters (may be NULL)
510
511 This function will return the key usage of the public key.
512
513 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
514 negative error value.
515
516 @strong{Since:} 2.12.0
517 @end deftypefun
518
519 @subheading gnutls_pubkey_get_openpgp_key_id
520 @anchor{gnutls_pubkey_get_openpgp_key_id}
521 @deftypefun {int} {gnutls_pubkey_get_openpgp_key_id} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size}, unsigned int * @var{subkey})
522 @var{key}: Holds the public key
523
524 @var{flags}: should be 0 or @code{GNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT} 
525
526 @var{output_data}: will contain the key ID
527
528 @var{output_data_size}: holds the size of output_data (and will be
529 replaced by the actual size of parameters)
530
531 @var{subkey}: Will be non zero if the key ID corresponds to a subkey
532
533 This function returns the OpenPGP key ID of the corresponding key.
534 The key is a unique ID that depends on the public
535 key parameters. 
536
537 If the flag @code{GNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT}  is specified
538 this function returns the fingerprint of the master key.
539
540 If the buffer provided is not long enough to hold the output, then
541 *output_data_size is updated and @code{GNUTLS_E_SHORT_MEMORY_BUFFER}  will
542 be returned.  The output is @code{GNUTLS_OPENPGP_KEYID_SIZE}  bytes long.
543
544 @strong{Returns:} In case of failure a negative error code will be
545 returned, and 0 on success.
546
547 @strong{Since:} 3.0
548 @end deftypefun
549
550 @subheading gnutls_pubkey_get_pk_algorithm
551 @anchor{gnutls_pubkey_get_pk_algorithm}
552 @deftypefun {int} {gnutls_pubkey_get_pk_algorithm} (gnutls_pubkey_t @var{key}, unsigned int * @var{bits})
553 @var{key}: should contain a @code{gnutls_pubkey_t}  structure
554
555 @var{bits}: If set will return the number of bits of the parameters (may be NULL)
556
557 This function will return the public key algorithm of a public
558 key and if possible will return a number of bits that indicates
559 the security parameter of the key.
560
561 @strong{Returns:} a member of the @code{gnutls_pk_algorithm_t}  enumeration on
562 success, or a negative error code on error.
563
564 @strong{Since:} 2.12.0
565 @end deftypefun
566
567 @subheading gnutls_pubkey_get_pk_dsa_raw
568 @anchor{gnutls_pubkey_get_pk_dsa_raw}
569 @deftypefun {int} {gnutls_pubkey_get_pk_dsa_raw} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y})
570 @var{key}: Holds the public key
571
572 @var{p}: will hold the p
573
574 @var{q}: will hold the q
575
576 @var{g}: will hold the g
577
578 @var{y}: will hold the y
579
580 This function will export the DSA public key's parameters found in
581 the given certificate.  The new parameters will be allocated using
582 @code{gnutls_malloc()}  and will be stored in the appropriate datum.
583
584 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
585
586 @strong{Since:} 2.12.0
587 @end deftypefun
588
589 @subheading gnutls_pubkey_get_pk_ecc_raw
590 @anchor{gnutls_pubkey_get_pk_ecc_raw}
591 @deftypefun {int} {gnutls_pubkey_get_pk_ecc_raw} (gnutls_pubkey_t @var{key}, gnutls_ecc_curve_t * @var{curve}, gnutls_datum_t * @var{x}, gnutls_datum_t * @var{y})
592 @var{key}: Holds the public key
593
594 @var{curve}: will hold the curve
595
596 @var{x}: will hold x
597
598 @var{y}: will hold y
599
600 This function will export the ECC public key's parameters found in
601 the given certificate.  The new parameters will be allocated using
602 @code{gnutls_malloc()}  and will be stored in the appropriate datum.
603
604 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
605
606 @strong{Since:} 3.0
607 @end deftypefun
608
609 @subheading gnutls_pubkey_get_pk_ecc_x962
610 @anchor{gnutls_pubkey_get_pk_ecc_x962}
611 @deftypefun {int} {gnutls_pubkey_get_pk_ecc_x962} (gnutls_pubkey_t @var{key}, gnutls_datum_t* @var{parameters}, gnutls_datum_t * @var{ecpoint})
612 @var{key}: Holds the public key
613
614 @var{parameters}: DER encoding of an ANSI X9.62 parameters
615
616 @var{ecpoint}: DER encoding of ANSI X9.62 ECPoint
617
618 This function will export the ECC public key's parameters found in
619 the given certificate.  The new parameters will be allocated using
620 @code{gnutls_malloc()}  and will be stored in the appropriate datum.
621
622 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
623
624 @strong{Since:} 3.0
625 @end deftypefun
626
627 @subheading gnutls_pubkey_get_pk_rsa_raw
628 @anchor{gnutls_pubkey_get_pk_rsa_raw}
629 @deftypefun {int} {gnutls_pubkey_get_pk_rsa_raw} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e})
630 @var{key}: Holds the certificate
631
632 @var{m}: will hold the modulus
633
634 @var{e}: will hold the public exponent
635
636 This function will export the RSA public key's parameters found in
637 the given structure.  The new parameters will be allocated using
638 @code{gnutls_malloc()}  and will be stored in the appropriate datum.
639
640 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
641
642 @strong{Since:} 2.12.0
643 @end deftypefun
644
645 @subheading gnutls_pubkey_get_preferred_hash_algorithm
646 @anchor{gnutls_pubkey_get_preferred_hash_algorithm}
647 @deftypefun {int} {gnutls_pubkey_get_preferred_hash_algorithm} (gnutls_pubkey_t @var{key}, gnutls_digest_algorithm_t *                                             @var{hash}, unsigned int * @var{mand})
648 @var{key}: Holds the certificate
649
650 @var{hash}: The result of the call with the hash algorithm used for signature
651
652 @var{mand}: If non zero it means that the algorithm MUST use this hash. May be NULL.
653
654 This function will read the certifcate and return the appropriate digest
655 algorithm to use for signing with this certificate. Some certificates (i.e.
656 DSA might not be able to sign without the preferred algorithm).
657
658 @strong{Returns:} the 0 if the hash algorithm is found. A negative error code is
659 returned on error.
660
661 @strong{Since:} 2.12.0
662 @end deftypefun
663
664 @subheading gnutls_pubkey_get_verify_algorithm
665 @anchor{gnutls_pubkey_get_verify_algorithm}
666 @deftypefun {int} {gnutls_pubkey_get_verify_algorithm} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{signature}, gnutls_digest_algorithm_t * @var{hash})
667 @var{key}: Holds the certificate
668
669 @var{signature}: contains the signature
670
671 @var{hash}: The result of the call with the hash algorithm used for signature
672
673 This function will read the certifcate and the signed data to
674 determine the hash algorithm used to generate the signature.
675
676 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
677 negative error value.
678
679 @strong{Since:} 2.12.0
680 @end deftypefun
681
682 @subheading gnutls_pubkey_import
683 @anchor{gnutls_pubkey_import}
684 @deftypefun {int} {gnutls_pubkey_import} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
685 @var{key}: The structure to store the parsed public key. 
686
687 @var{data}: The DER or PEM encoded certificate. 
688
689 @var{format}: One of DER or PEM 
690
691 This function will import the provided public key in
692 a SubjectPublicKeyInfo X.509 structure to a native
693 @code{gnutls_pubkey_t}  structure. The output will be stored 
694 in  @code{key} . If the public key is PEM encoded it should have a header 
695 of "PUBLIC KEY". 
696
697 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
698 negative error value.
699
700 @strong{Since:} 2.12.0
701 @end deftypefun
702
703 @subheading gnutls_pubkey_import_dsa_raw
704 @anchor{gnutls_pubkey_import_dsa_raw}
705 @deftypefun {int} {gnutls_pubkey_import_dsa_raw} (gnutls_pubkey_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})
706 @var{key}: The structure to store the parsed key
707
708 @var{p}: holds the p
709
710 @var{q}: holds the q
711
712 @var{g}: holds the g
713
714 @var{y}: holds the y
715
716 This function will convert the given DSA raw parameters to the
717 native @code{gnutls_pubkey_t}  format.  The output will be stored
718 in  @code{key} .
719
720 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
721 negative error value.
722
723 @strong{Since:} 2.12.0
724 @end deftypefun
725
726 @subheading gnutls_pubkey_import_ecc_raw
727 @anchor{gnutls_pubkey_import_ecc_raw}
728 @deftypefun {int} {gnutls_pubkey_import_ecc_raw} (gnutls_pubkey_t @var{key}, gnutls_ecc_curve_t @var{curve}, const gnutls_datum_t * @var{x}, const gnutls_datum_t * @var{y})
729 @var{key}: The structure to store the parsed key
730
731 @var{curve}: holds the curve
732
733 @var{x}: holds the x
734
735 @var{y}: holds the y
736
737 This function will convert the given elliptic curve parameters to a
738 @code{gnutls_pubkey_t} .  The output will be stored in  @code{key} .
739
740 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
741 negative error value.
742
743 @strong{Since:} 3.0
744 @end deftypefun
745
746 @subheading gnutls_pubkey_import_ecc_x962
747 @anchor{gnutls_pubkey_import_ecc_x962}
748 @deftypefun {int} {gnutls_pubkey_import_ecc_x962} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{parameters}, const gnutls_datum_t * @var{ecpoint})
749 @var{key}: The structure to store the parsed key
750
751 @var{parameters}: DER encoding of an ANSI X9.62 parameters
752
753 @var{ecpoint}: DER encoding of ANSI X9.62 ECPoint
754
755 This function will convert the given elliptic curve parameters to a
756 @code{gnutls_pubkey_t} .  The output will be stored in  @code{key} .
757
758 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
759 negative error value.
760
761 @strong{Since:} 3.0
762 @end deftypefun
763
764 @subheading gnutls_pubkey_import_openpgp
765 @anchor{gnutls_pubkey_import_openpgp}
766 @deftypefun {int} {gnutls_pubkey_import_openpgp} (gnutls_pubkey_t @var{key}, gnutls_openpgp_crt_t @var{crt}, unsigned int @var{flags})
767 @var{key}: The public key
768
769 @var{crt}: The certificate to be imported
770
771 @var{flags}: should be zero
772
773 Imports a public key from an openpgp key. This function will import
774 the given public key to the abstract @code{gnutls_pubkey_t} 
775 structure. The subkey set as preferred will be imported or the
776 master key otherwise.
777
778 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
779 negative error value.
780
781 @strong{Since:} 2.12.0
782 @end deftypefun
783
784 @subheading gnutls_pubkey_import_pkcs11
785 @anchor{gnutls_pubkey_import_pkcs11}
786 @deftypefun {int} {gnutls_pubkey_import_pkcs11} (gnutls_pubkey_t @var{key}, gnutls_pkcs11_obj_t @var{obj}, unsigned int @var{flags})
787 @var{key}: The public key
788
789 @var{obj}: The parameters to be imported
790
791 @var{flags}: should be zero
792
793 Imports a public key from a pkcs11 key. This function will import
794 the given public key to the abstract @code{gnutls_pubkey_t}  structure.
795
796 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
797 negative error value.
798
799 @strong{Since:} 2.12.0
800 @end deftypefun
801
802 @subheading gnutls_pubkey_import_pkcs11_url
803 @anchor{gnutls_pubkey_import_pkcs11_url}
804 @deftypefun {int} {gnutls_pubkey_import_pkcs11_url} (gnutls_pubkey_t @var{key}, const char * @var{url}, unsigned int @var{flags})
805 @var{key}: A key of type @code{gnutls_pubkey_t} 
806
807 @var{url}: A PKCS 11 url
808
809 @var{flags}: One of GNUTLS_PKCS11_OBJ_* flags
810
811 This function will import a PKCS 11 certificate to a @code{gnutls_pubkey_t} 
812 structure.
813
814 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
815 negative error value.
816
817 @strong{Since:} 2.12.0
818 @end deftypefun
819
820 @subheading gnutls_pubkey_import_privkey
821 @anchor{gnutls_pubkey_import_privkey}
822 @deftypefun {int} {gnutls_pubkey_import_privkey} (gnutls_pubkey_t @var{key}, gnutls_privkey_t @var{pkey}, unsigned int @var{usage}, unsigned int @var{flags})
823 @var{key}: The public key
824
825 @var{pkey}: The private key
826
827 @var{usage}: GNUTLS_KEY_* key usage flags.
828
829 @var{flags}: should be zero
830
831 Imports the public key from a private.  This function will import
832 the given public key to the abstract @code{gnutls_pubkey_t}  structure.
833
834 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
835 negative error value.
836
837 @strong{Since:} 2.12.0
838 @end deftypefun
839
840 @subheading gnutls_pubkey_import_rsa_raw
841 @anchor{gnutls_pubkey_import_rsa_raw}
842 @deftypefun {int} {gnutls_pubkey_import_rsa_raw} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e})
843 @var{key}: Is a structure will hold the parameters
844
845 @var{m}: holds the modulus
846
847 @var{e}: holds the public exponent
848
849 This function will replace the parameters in the given structure.
850 The new parameters should be stored in the appropriate
851 gnutls_datum.
852
853 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, or an negative error code.
854
855 @strong{Since:} 2.12.0
856 @end deftypefun
857
858 @subheading gnutls_pubkey_import_x509
859 @anchor{gnutls_pubkey_import_x509}
860 @deftypefun {int} {gnutls_pubkey_import_x509} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_t @var{crt}, unsigned int @var{flags})
861 @var{key}: The public key
862
863 @var{crt}: The certificate to be imported
864
865 @var{flags}: should be zero
866
867 This function will import the given public key to the abstract
868 @code{gnutls_pubkey_t}  structure.
869
870 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
871 negative error value.
872
873 @strong{Since:} 2.12.0
874 @end deftypefun
875
876 @subheading gnutls_pubkey_init
877 @anchor{gnutls_pubkey_init}
878 @deftypefun {int} {gnutls_pubkey_init} (gnutls_pubkey_t * @var{key})
879 @var{key}: The structure to be initialized
880
881 This function will initialize an public key structure.
882
883 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
884 negative error value.
885
886 @strong{Since:} 2.12.0
887 @end deftypefun
888
889 @subheading gnutls_pubkey_set_key_usage
890 @anchor{gnutls_pubkey_set_key_usage}
891 @deftypefun {int} {gnutls_pubkey_set_key_usage} (gnutls_pubkey_t @var{key}, unsigned int @var{usage})
892 @var{key}: a certificate of type @code{gnutls_x509_crt_t} 
893
894 @var{usage}: an ORed sequence of the GNUTLS_KEY_* elements.
895
896 This function will set the key usage flags of the public key. This
897 is only useful if the key is to be exported to a certificate or
898 certificate request.
899
900 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
901 negative error value.
902
903 @strong{Since:} 2.12.0
904 @end deftypefun
905
906 @subheading gnutls_pubkey_verify_data
907 @anchor{gnutls_pubkey_verify_data}
908 @deftypefun {int} {gnutls_pubkey_verify_data} (gnutls_pubkey_t @var{pubkey}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, const gnutls_datum_t * @var{signature})
909 @var{pubkey}: Holds the public key
910
911 @var{flags}: should be 0 for now
912
913 @var{data}: holds the signed data
914
915 @var{signature}: contains the signature
916
917 This function will verify the given signed data, using the
918 parameters from the certificate.
919
920 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}  
921 is returned, and zero or positive code on success.
922
923 @strong{Since:} 2.12.0
924 @end deftypefun
925
926 @subheading gnutls_pubkey_verify_data2
927 @anchor{gnutls_pubkey_verify_data2}
928 @deftypefun {int} {gnutls_pubkey_verify_data2} (gnutls_pubkey_t @var{pubkey}, gnutls_sign_algorithm_t @var{algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, const gnutls_datum_t * @var{signature})
929 @var{pubkey}: Holds the public key
930
931 @var{algo}: The signature algorithm used
932
933 @var{flags}: should be 0 for now
934
935 @var{data}: holds the signed data
936
937 @var{signature}: contains the signature
938
939 This function will verify the given signed data, using the
940 parameters from the certificate.
941
942 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}  
943 is returned, and zero or positive code on success.
944
945 @strong{Since:} 3.0
946 @end deftypefun
947
948 @subheading gnutls_pubkey_verify_hash
949 @anchor{gnutls_pubkey_verify_hash}
950 @deftypefun {int} {gnutls_pubkey_verify_hash} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash}, const gnutls_datum_t * @var{signature})
951 @var{key}: Holds the public key
952
953 @var{flags}: should be 0 for now
954
955 @var{hash}: holds the hash digest to be verified
956
957 @var{signature}: contains the signature
958
959 This function will verify the given signed digest, using the
960 parameters from the public key. 
961
962 Deprecated. This function cannot be easily used securely. 
963 Use @code{gnutls_pubkey_verify_hash2()}  instead.
964
965 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}  
966 is returned, and zero or positive code on success.
967
968 @strong{Since:} 2.12.0
969 @end deftypefun
970
971 @subheading gnutls_pubkey_verify_hash2
972 @anchor{gnutls_pubkey_verify_hash2}
973 @deftypefun {int} {gnutls_pubkey_verify_hash2} (gnutls_pubkey_t @var{key}, gnutls_sign_algorithm_t @var{algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash}, const gnutls_datum_t * @var{signature})
974 @var{key}: Holds the public key
975
976 @var{algo}: The signature algorithm used
977
978 @var{flags}: should be 0 for now
979
980 @var{hash}: holds the hash digest to be verified
981
982 @var{signature}: contains the signature
983
984 This function will verify the given signed digest, using the
985 parameters from the public key.
986
987 @strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED}  
988 is returned, and zero or positive code on success.
989
990 @strong{Since:} 3.0
991 @end deftypefun
992
993 @subheading gnutls_x509_crl_privkey_sign
994 @anchor{gnutls_x509_crl_privkey_sign}
995 @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})
996 @var{crl}: should contain a gnutls_x509_crl_t structure
997
998 @var{issuer}: is the certificate of the certificate issuer
999
1000 @var{issuer_key}: holds the issuer's private key
1001
1002 @var{dig}: The message digest to use. GNUTLS_DIG_SHA1 is the safe choice unless you know what you're doing.
1003
1004 @var{flags}: must be 0
1005
1006 This function will sign the CRL with the issuer's private key, and
1007 will copy the issuer's information into the CRL.
1008
1009 This must be the last step in a certificate CRL since all
1010 the previously set parameters are now signed.
1011
1012 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
1013 negative error value.
1014
1015 Since 2.12.0
1016 @end deftypefun
1017
1018 @subheading gnutls_x509_crq_privkey_sign
1019 @anchor{gnutls_x509_crq_privkey_sign}
1020 @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})
1021 @var{crq}: should contain a @code{gnutls_x509_crq_t}  structure
1022
1023 @var{key}: holds a private key
1024
1025 @var{dig}: The message digest to use, i.e., @code{GNUTLS_DIG_SHA1} 
1026
1027 @var{flags}: must be 0
1028
1029 This function will sign the certificate request with a private key.
1030 This must be the same key as the one used in
1031 @code{gnutls_x509_crt_set_key()}  since a certificate request is self
1032 signed.
1033
1034 This must be the last step in a certificate request generation
1035 since all the previously set parameters are now signed.
1036
1037 @strong{Returns:} @code{GNUTLS_E_SUCCESS}  on success, otherwise a negative error code.
1038 @code{GNUTLS_E_ASN1_VALUE_NOT_FOUND}  is returned if you didn't set all
1039 information in the certificate request (e.g., the version using
1040 @code{gnutls_x509_crq_set_version()} ).
1041
1042 @strong{Since:} 2.12.0
1043 @end deftypefun
1044
1045 @subheading gnutls_x509_crq_set_pubkey
1046 @anchor{gnutls_x509_crq_set_pubkey}
1047 @deftypefun {int} {gnutls_x509_crq_set_pubkey} (gnutls_x509_crq_t @var{crq}, gnutls_pubkey_t @var{key})
1048 @var{crq}: should contain a @code{gnutls_x509_crq_t}  structure
1049
1050 @var{key}: holds a public key
1051
1052 This function will set the public parameters from the given public
1053 key to the request.
1054
1055 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
1056 negative error value.
1057
1058 @strong{Since:} 2.12.0
1059 @end deftypefun
1060
1061 @subheading gnutls_x509_crt_privkey_sign
1062 @anchor{gnutls_x509_crt_privkey_sign}
1063 @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})
1064 @var{crt}: a certificate of type @code{gnutls_x509_crt_t} 
1065
1066 @var{issuer}: is the certificate of the certificate issuer
1067
1068 @var{issuer_key}: holds the issuer's private key
1069
1070 @var{dig}: The message digest to use, @code{GNUTLS_DIG_SHA1}  is a safe choice
1071
1072 @var{flags}: must be 0
1073
1074 This function will sign the certificate with the issuer's private key, and
1075 will copy the issuer's information into the certificate.
1076
1077 This must be the last step in a certificate generation since all
1078 the previously set parameters are now signed.
1079
1080 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
1081 negative error value.
1082 @end deftypefun
1083
1084 @subheading gnutls_x509_crt_set_pubkey
1085 @anchor{gnutls_x509_crt_set_pubkey}
1086 @deftypefun {int} {gnutls_x509_crt_set_pubkey} (gnutls_x509_crt_t @var{crt}, gnutls_pubkey_t @var{key})
1087 @var{crt}: should contain a @code{gnutls_x509_crt_t}  structure
1088
1089 @var{key}: holds a public key
1090
1091 This function will set the public parameters from the given public
1092 key to the request.
1093
1094 @strong{Returns:} On success, @code{GNUTLS_E_SUCCESS}  (0) is returned, otherwise a
1095 negative error value.
1096
1097 @strong{Since:} 2.12.0
1098 @end deftypefun
1099