Added gnutls_session_get_random()
[gnutls.git] / lib / includes / gnutls / gnutls.h.in
blobf314be8b212a98bacd22578d3962e65ec3a3ec1e
1 /* -*- c -*-
2 * Copyright (C) 2000-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 /* This file contains the types and prototypes for all the
24 * high level functionality of the gnutls main library.
26 * If the optional C++ binding was built, it is available in
27 * gnutls/gnutlsxx.h.
29 * The openssl compatibility layer (which is under the GNU GPL
30 * license) is in gnutls/openssl.h.
32 * The low level cipher functionality is in gnutls/crypto.h.
36 #ifndef GNUTLS_H
37 #define GNUTLS_H
39 /* Get size_t. */
40 #include <stddef.h>
41 /* Get ssize_t. */
42 #ifndef HAVE_SSIZE_T
43 #define HAVE_SSIZE_T
44 /* *INDENT-OFF* */
45 @DEFINE_SSIZE_T@
46 /* *INDENT-ON* */
47 #endif
48 /* Get time_t. */
49 #include <time.h>
50 #ifdef __cplusplus
51 extern "C"
53 #endif
55 #define GNUTLS_VERSION "@VERSION@"
57 #define GNUTLS_VERSION_MAJOR @MAJOR_VERSION@
58 #define GNUTLS_VERSION_MINOR @MINOR_VERSION@
59 #define GNUTLS_VERSION_PATCH @PATCH_VERSION@
61 #define GNUTLS_VERSION_NUMBER @NUMBER_VERSION@
63 #define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC
64 #define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC
65 #define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC
66 #define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128
68 /**
69 * gnutls_cipher_algorithm_t:
70 * @GNUTLS_CIPHER_UNKNOWN: Unknown algorithm.
71 * @GNUTLS_CIPHER_NULL: NULL algorithm.
72 * @GNUTLS_CIPHER_ARCFOUR_128: ARCFOUR stream cipher with 128-bit keys.
73 * @GNUTLS_CIPHER_3DES_CBC: 3DES in CBC mode.
74 * @GNUTLS_CIPHER_AES_128_CBC: AES in CBC mode with 128-bit keys.
75 * @GNUTLS_CIPHER_AES_192_CBC: AES in CBC mode with 192-bit keys.
76 * @GNUTLS_CIPHER_AES_256_CBC: AES in CBC mode with 256-bit keys.
77 * @GNUTLS_CIPHER_ARCFOUR_40: ARCFOUR stream cipher with 40-bit keys.
78 * @GNUTLS_CIPHER_CAMELLIA_128_CBC: Camellia in CBC mode with 128-bit keys.
79 * @GNUTLS_CIPHER_CAMELLIA_256_CBC: Camellia in CBC mode with 256-bit keys.
80 * @GNUTLS_CIPHER_RC2_40_CBC: RC2 in CBC mode with 40-bit keys.
81 * @GNUTLS_CIPHER_DES_CBC: DES in CBC mode (56-bit keys).
82 * @GNUTLS_CIPHER_AES_128_GCM: AES in GCM mode with 128-bit keys.
83 * @GNUTLS_CIPHER_AES_256_GCM: AES in GCM mode with 256-bit keys.
84 * @GNUTLS_CIPHER_IDEA_PGP_CFB: IDEA in CFB mode.
85 * @GNUTLS_CIPHER_3DES_PGP_CFB: 3DES in CFB mode.
86 * @GNUTLS_CIPHER_CAST5_PGP_CFB: CAST5 in CFB mode.
87 * @GNUTLS_CIPHER_BLOWFISH_PGP_CFB: Blowfish in CFB mode.
88 * @GNUTLS_CIPHER_SAFER_SK128_PGP_CFB: Safer-SK in CFB mode with 128-bit keys.
89 * @GNUTLS_CIPHER_AES128_PGP_CFB: AES in CFB mode with 128-bit keys.
90 * @GNUTLS_CIPHER_AES192_PGP_CFB: AES in CFB mode with 192-bit keys.
91 * @GNUTLS_CIPHER_AES256_PGP_CFB: AES in CFB mode with 256-bit keys.
92 * @GNUTLS_CIPHER_TWOFISH_PGP_CFB: Twofish in CFB mode.
94 * Enumeration of different symmetric encryption algorithms.
96 typedef enum gnutls_cipher_algorithm
98 GNUTLS_CIPHER_UNKNOWN = 0,
99 GNUTLS_CIPHER_NULL = 1,
100 GNUTLS_CIPHER_ARCFOUR_128 = 2,
101 GNUTLS_CIPHER_3DES_CBC = 3,
102 GNUTLS_CIPHER_AES_128_CBC = 4,
103 GNUTLS_CIPHER_AES_256_CBC = 5,
104 GNUTLS_CIPHER_ARCFOUR_40 = 6,
105 GNUTLS_CIPHER_CAMELLIA_128_CBC = 7,
106 GNUTLS_CIPHER_CAMELLIA_256_CBC = 8,
107 GNUTLS_CIPHER_RC2_40_CBC = 90,
108 GNUTLS_CIPHER_DES_CBC = 91,
109 GNUTLS_CIPHER_AES_192_CBC = 92,
110 GNUTLS_CIPHER_AES_128_GCM = 93,
111 GNUTLS_CIPHER_AES_256_GCM = 94,
113 /* used only for PGP internals. Ignored in TLS/SSL
115 GNUTLS_CIPHER_IDEA_PGP_CFB = 200,
116 GNUTLS_CIPHER_3DES_PGP_CFB = 201,
117 GNUTLS_CIPHER_CAST5_PGP_CFB = 202,
118 GNUTLS_CIPHER_BLOWFISH_PGP_CFB = 203,
119 GNUTLS_CIPHER_SAFER_SK128_PGP_CFB = 204,
120 GNUTLS_CIPHER_AES128_PGP_CFB = 205,
121 GNUTLS_CIPHER_AES192_PGP_CFB = 206,
122 GNUTLS_CIPHER_AES256_PGP_CFB = 207,
123 GNUTLS_CIPHER_TWOFISH_PGP_CFB = 208
124 } gnutls_cipher_algorithm_t;
127 * gnutls_kx_algorithm_t:
128 * @GNUTLS_KX_UNKNOWN: Unknown key-exchange algorithm.
129 * @GNUTLS_KX_RSA: RSA key-exchange algorithm.
130 * @GNUTLS_KX_DHE_DSS: DHE-DSS key-exchange algorithm.
131 * @GNUTLS_KX_DHE_RSA: DHE-RSA key-exchange algorithm.
132 * @GNUTLS_KX_ECDHE_RSA: ECDHE-RSA key-exchange algorithm.
133 * @GNUTLS_KX_ECDHE_ECDSA: ECDHE-ECDSA key-exchange algorithm.
134 * @GNUTLS_KX_ANON_DH: Anon-DH key-exchange algorithm.
135 * @GNUTLS_KX_ANON_ECDH: Anon-ECDH key-exchange algorithm.
136 * @GNUTLS_KX_SRP: SRP key-exchange algorithm.
137 * @GNUTLS_KX_RSA_EXPORT: RSA-EXPORT key-exchange algorithm.
138 * @GNUTLS_KX_SRP_RSA: SRP-RSA key-exchange algorithm.
139 * @GNUTLS_KX_SRP_DSS: SRP-DSS key-exchange algorithm.
140 * @GNUTLS_KX_PSK: PSK key-exchange algorithm.
141 * @GNUTLS_KX_DHE_PSK: DHE-PSK key-exchange algorithm.
142 * @GNUTLS_KX_ECDHE_PSK: ECDHE-PSK key-exchange algorithm.
144 * Enumeration of different key exchange algorithms.
146 typedef enum
148 GNUTLS_KX_UNKNOWN = 0,
149 GNUTLS_KX_RSA = 1,
150 GNUTLS_KX_DHE_DSS = 2,
151 GNUTLS_KX_DHE_RSA = 3,
152 GNUTLS_KX_ANON_DH = 4,
153 GNUTLS_KX_SRP = 5,
154 GNUTLS_KX_RSA_EXPORT = 6,
155 GNUTLS_KX_SRP_RSA = 7,
156 GNUTLS_KX_SRP_DSS = 8,
157 GNUTLS_KX_PSK = 9,
158 GNUTLS_KX_DHE_PSK = 10,
159 GNUTLS_KX_ANON_ECDH = 11,
160 GNUTLS_KX_ECDHE_RSA = 12,
161 GNUTLS_KX_ECDHE_ECDSA = 13,
162 GNUTLS_KX_ECDHE_PSK = 14,
163 } gnutls_kx_algorithm_t;
166 * gnutls_params_type_t:
167 * @GNUTLS_PARAMS_RSA_EXPORT: Session RSA-EXPORT parameters.
168 * @GNUTLS_PARAMS_DH: Session Diffie-Hellman parameters.
169 * @GNUTLS_PARAMS_ECDH: Session Elliptic-Curve Diffie-Hellman parameters.
171 * Enumeration of different TLS session parameter types.
173 typedef enum
175 GNUTLS_PARAMS_RSA_EXPORT = 1,
176 GNUTLS_PARAMS_DH = 2,
177 GNUTLS_PARAMS_ECDH = 3,
178 } gnutls_params_type_t;
181 * gnutls_credentials_type_t:
182 * @GNUTLS_CRD_CERTIFICATE: Certificate credential.
183 * @GNUTLS_CRD_ANON: Anonymous credential.
184 * @GNUTLS_CRD_SRP: SRP credential.
185 * @GNUTLS_CRD_PSK: PSK credential.
186 * @GNUTLS_CRD_IA: IA credential.
188 * Enumeration of different credential types.
190 typedef enum
192 GNUTLS_CRD_CERTIFICATE = 1,
193 GNUTLS_CRD_ANON,
194 GNUTLS_CRD_SRP,
195 GNUTLS_CRD_PSK,
196 GNUTLS_CRD_IA
197 } gnutls_credentials_type_t;
199 #define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1
200 #define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1
203 * gnutls_mac_algorithm_t:
204 * @GNUTLS_MAC_UNKNOWN: Unknown MAC algorithm.
205 * @GNUTLS_MAC_NULL: NULL MAC algorithm (empty output).
206 * @GNUTLS_MAC_MD5: HMAC-MD5 algorithm.
207 * @GNUTLS_MAC_SHA1: HMAC-SHA-1 algorithm.
208 * @GNUTLS_MAC_RMD160: HMAC-RMD160 algorithm.
209 * @GNUTLS_MAC_MD2: HMAC-MD2 algorithm.
210 * @GNUTLS_MAC_SHA256: HMAC-SHA-256 algorithm.
211 * @GNUTLS_MAC_SHA384: HMAC-SHA-384 algorithm.
212 * @GNUTLS_MAC_SHA512: HMAC-SHA-512 algorithm.
213 * @GNUTLS_MAC_SHA224: HMAC-SHA-224 algorithm.
214 * @GNUTLS_MAC_AEAD: MAC implicit through AEAD cipher.
216 * Enumeration of different Message Authentication Code (MAC)
217 * algorithms.
219 typedef enum
221 GNUTLS_MAC_UNKNOWN = 0,
222 GNUTLS_MAC_NULL = 1,
223 GNUTLS_MAC_MD5 = 2,
224 GNUTLS_MAC_SHA1 = 3,
225 GNUTLS_MAC_RMD160 = 4,
226 GNUTLS_MAC_MD2 = 5,
227 GNUTLS_MAC_SHA256 = 6,
228 GNUTLS_MAC_SHA384 = 7,
229 GNUTLS_MAC_SHA512 = 8,
230 GNUTLS_MAC_SHA224 = 9,
231 /* If you add anything here, make sure you align with
232 gnutls_digest_algorithm_t. */
233 GNUTLS_MAC_AEAD = 200 /* indicates that MAC is on the cipher */
234 } gnutls_mac_algorithm_t;
237 * gnutls_digest_algorithm_t:
238 * @GNUTLS_DIG_UNKNOWN: Unknown hash algorithm.
239 * @GNUTLS_DIG_NULL: NULL hash algorithm (empty output).
240 * @GNUTLS_DIG_MD5: MD5 algorithm.
241 * @GNUTLS_DIG_SHA1: SHA-1 algorithm.
242 * @GNUTLS_DIG_RMD160: RMD160 algorithm.
243 * @GNUTLS_DIG_MD2: MD2 algorithm.
244 * @GNUTLS_DIG_SHA256: SHA-256 algorithm.
245 * @GNUTLS_DIG_SHA384: SHA-384 algorithm.
246 * @GNUTLS_DIG_SHA512: SHA-512 algorithm.
247 * @GNUTLS_DIG_SHA224: SHA-224 algorithm.
249 * Enumeration of different digest (hash) algorithms.
251 typedef enum
253 GNUTLS_DIG_UNKNOWN = GNUTLS_MAC_UNKNOWN,
254 GNUTLS_DIG_NULL = GNUTLS_MAC_NULL,
255 GNUTLS_DIG_MD5 = GNUTLS_MAC_MD5,
256 GNUTLS_DIG_SHA1 = GNUTLS_MAC_SHA1,
257 GNUTLS_DIG_RMD160 = GNUTLS_MAC_RMD160,
258 GNUTLS_DIG_MD2 = GNUTLS_MAC_MD2,
259 GNUTLS_DIG_SHA256 = GNUTLS_MAC_SHA256,
260 GNUTLS_DIG_SHA384 = GNUTLS_MAC_SHA384,
261 GNUTLS_DIG_SHA512 = GNUTLS_MAC_SHA512,
262 GNUTLS_DIG_SHA224 = GNUTLS_MAC_SHA224
263 /* If you add anything here, make sure you align with
264 gnutls_mac_algorithm_t. */
265 } gnutls_digest_algorithm_t;
267 /* exported for other gnutls headers. This is the maximum number of
268 * algorithms (ciphers, kx or macs).
270 #define GNUTLS_MAX_ALGORITHM_NUM 32
273 * gnutls_compression_method_t:
274 * @GNUTLS_COMP_UNKNOWN: Unknown compression method.
275 * @GNUTLS_COMP_NULL: The NULL compression method (no compression).
276 * @GNUTLS_COMP_DEFLATE: The DEFLATE compression method from zlib.
277 * @GNUTLS_COMP_ZLIB: Same as %GNUTLS_COMP_DEFLATE.
279 * Enumeration of different TLS compression methods.
281 typedef enum
283 GNUTLS_COMP_UNKNOWN = 0,
284 GNUTLS_COMP_NULL = 1,
285 GNUTLS_COMP_DEFLATE = 2,
286 GNUTLS_COMP_ZLIB = GNUTLS_COMP_DEFLATE,
287 } gnutls_compression_method_t;
290 * Flags for gnutls_init()
292 * @GNUTLS_SERVER: Connection end is a server.
293 * @GNUTLS_CLIENT: Connection end is a client.
294 * @GNUTLS_DATAGRAM: Connection is datagram oriented (DTLS).
295 * @GNUTLS_NONBLOCK: Connection should not block (DTLS).
297 * Enumeration of different TLS connection end types.
299 #define GNUTLS_SERVER 1
300 #define GNUTLS_CLIENT (1<<1)
301 #define GNUTLS_DATAGRAM (1<<2)
302 #define GNUTLS_NONBLOCK (1<<3)
305 * gnutls_alert_level_t:
306 * @GNUTLS_AL_WARNING: Alert of warning severity.
307 * @GNUTLS_AL_FATAL: Alert of fatal severity.
309 * Enumeration of different TLS alert severities.
311 typedef enum
313 GNUTLS_AL_WARNING = 1,
314 GNUTLS_AL_FATAL
315 } gnutls_alert_level_t;
318 * gnutls_alert_description_t:
319 * @GNUTLS_A_CLOSE_NOTIFY: Close notify.
320 * @GNUTLS_A_UNEXPECTED_MESSAGE: Unexpected message.
321 * @GNUTLS_A_BAD_RECORD_MAC: Bad record MAC.
322 * @GNUTLS_A_DECRYPTION_FAILED: Decryption failed.
323 * @GNUTLS_A_RECORD_OVERFLOW: Record overflow.
324 * @GNUTLS_A_DECOMPRESSION_FAILURE: Decompression failed.
325 * @GNUTLS_A_HANDSHAKE_FAILURE: Handshake failed.
326 * @GNUTLS_A_SSL3_NO_CERTIFICATE: No certificate.
327 * @GNUTLS_A_BAD_CERTIFICATE: Certificate is bad.
328 * @GNUTLS_A_UNSUPPORTED_CERTIFICATE: Certificate is not supported.
329 * @GNUTLS_A_CERTIFICATE_REVOKED: Certificate was revoked.
330 * @GNUTLS_A_CERTIFICATE_EXPIRED: Certificate is expired.
331 * @GNUTLS_A_CERTIFICATE_UNKNOWN: Unknown certificate.
332 * @GNUTLS_A_ILLEGAL_PARAMETER: Illegal parameter.
333 * @GNUTLS_A_UNKNOWN_CA: CA is unknown.
334 * @GNUTLS_A_ACCESS_DENIED: Access was denied.
335 * @GNUTLS_A_DECODE_ERROR: Decode error.
336 * @GNUTLS_A_DECRYPT_ERROR: Decrypt error.
337 * @GNUTLS_A_EXPORT_RESTRICTION: Export restriction.
338 * @GNUTLS_A_PROTOCOL_VERSION: Error in protocol version.
339 * @GNUTLS_A_INSUFFICIENT_SECURITY: Insufficient security.
340 * @GNUTLS_A_USER_CANCELED: User canceled.
341 * @GNUTLS_A_INTERNAL_ERROR: Internal error.
342 * @GNUTLS_A_NO_RENEGOTIATION: No renegotiation is allowed.
343 * @GNUTLS_A_CERTIFICATE_UNOBTAINABLE: Could not retrieve the
344 * specified certificate.
345 * @GNUTLS_A_UNSUPPORTED_EXTENSION: An unsupported extension was
346 * sent.
347 * @GNUTLS_A_UNRECOGNIZED_NAME: The server name sent was not
348 * recognized.
349 * @GNUTLS_A_UNKNOWN_PSK_IDENTITY: The SRP/PSK username is missing
350 * or not known.
352 * Enumeration of different TLS alerts.
354 typedef enum
356 GNUTLS_A_CLOSE_NOTIFY,
357 GNUTLS_A_UNEXPECTED_MESSAGE = 10,
358 GNUTLS_A_BAD_RECORD_MAC = 20,
359 GNUTLS_A_DECRYPTION_FAILED,
360 GNUTLS_A_RECORD_OVERFLOW,
361 GNUTLS_A_DECOMPRESSION_FAILURE = 30,
362 GNUTLS_A_HANDSHAKE_FAILURE = 40,
363 GNUTLS_A_SSL3_NO_CERTIFICATE = 41,
364 GNUTLS_A_BAD_CERTIFICATE = 42,
365 GNUTLS_A_UNSUPPORTED_CERTIFICATE,
366 GNUTLS_A_CERTIFICATE_REVOKED,
367 GNUTLS_A_CERTIFICATE_EXPIRED,
368 GNUTLS_A_CERTIFICATE_UNKNOWN,
369 GNUTLS_A_ILLEGAL_PARAMETER,
370 GNUTLS_A_UNKNOWN_CA,
371 GNUTLS_A_ACCESS_DENIED,
372 GNUTLS_A_DECODE_ERROR = 50,
373 GNUTLS_A_DECRYPT_ERROR,
374 GNUTLS_A_EXPORT_RESTRICTION = 60,
375 GNUTLS_A_PROTOCOL_VERSION = 70,
376 GNUTLS_A_INSUFFICIENT_SECURITY,
377 GNUTLS_A_INTERNAL_ERROR = 80,
378 GNUTLS_A_USER_CANCELED = 90,
379 GNUTLS_A_NO_RENEGOTIATION = 100,
380 GNUTLS_A_UNSUPPORTED_EXTENSION = 110,
381 GNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111,
382 GNUTLS_A_UNRECOGNIZED_NAME = 112,
383 GNUTLS_A_UNKNOWN_PSK_IDENTITY = 115,
384 } gnutls_alert_description_t;
387 * gnutls_handshake_description_t:
388 * @GNUTLS_HANDSHAKE_HELLO_REQUEST: Hello request.
389 * @GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST: DTLS Hello verify request.
390 * @GNUTLS_HANDSHAKE_CLIENT_HELLO: Client hello.
391 * @GNUTLS_HANDSHAKE_SERVER_HELLO: Server hello.
392 * @GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: New session ticket.
393 * @GNUTLS_HANDSHAKE_CERTIFICATE_PKT: Certificate packet.
394 * @GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: Server key exchange.
395 * @GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: Certificate request.
396 * @GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: Server hello done.
397 * @GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: Certificate verify.
398 * @GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: Client key exchange.
399 * @GNUTLS_HANDSHAKE_FINISHED: Finished.
400 * @GNUTLS_HANDSHAKE_SUPPLEMENTAL: Supplemental.
401 * @GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC: Change Cipher Spec
402 * @GNUTLS_HANDSHAKE_CLIENT_HELLO_V2: SSLv2 Client Hello.
404 * Enumeration of different TLS handshake packets.
406 typedef enum
408 GNUTLS_HANDSHAKE_HELLO_REQUEST = 0,
409 GNUTLS_HANDSHAKE_CLIENT_HELLO = 1,
410 GNUTLS_HANDSHAKE_SERVER_HELLO = 2,
411 GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST = 3,
412 GNUTLS_HANDSHAKE_NEW_SESSION_TICKET = 4,
413 GNUTLS_HANDSHAKE_CERTIFICATE_PKT = 11,
414 GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE = 12,
415 GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST = 13,
416 GNUTLS_HANDSHAKE_SERVER_HELLO_DONE = 14,
417 GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY = 15,
418 GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16,
419 GNUTLS_HANDSHAKE_FINISHED = 20,
420 GNUTLS_HANDSHAKE_SUPPLEMENTAL = 23,
421 GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC = 254,
422 GNUTLS_HANDSHAKE_CLIENT_HELLO_V2 = 1024,
423 } gnutls_handshake_description_t;
426 * gnutls_certificate_status_t:
427 * @GNUTLS_CERT_INVALID: The certificate is not signed by one of the
428 * known authorities or the signature is invalid.
429 * @GNUTLS_CERT_REVOKED: Certificate is revoked by its authority. In X.509 this will be
430 * set only if CRLs are checked.
431 * @GNUTLS_CERT_SIGNER_NOT_FOUND: The certificate's issuer is not known.
432 * This is the case if the issue is not included in the trusted certificate list.
433 * not found.
434 * @GNUTLS_CERT_SIGNER_NOT_CA: The certificate’s signer was not a CA. This
435 * may happen if this was a version 1 certificate, which is common with
436 * some CAs, or a version 3 certificate without the basic constrains extension.
437 * @GNUTLS_CERT_INSECURE_ALGORITHM: The certificate was signed using an insecure
438 * algorithm such as MD2 or MD5. These algorithms have been broken and
439 * should not be trusted.
440 * @GNUTLS_CERT_NOT_ACTIVATED: The certificate is not yet activated.
441 * @GNUTLS_CERT_EXPIRED: The certificate has expired.
443 * Enumeration of certificate status codes. Note that the status
444 * bits have different meanings in OpenPGP keys and X.509
445 * certificate verification.
447 typedef enum
449 GNUTLS_CERT_INVALID = 2,
450 GNUTLS_CERT_REVOKED = 32,
451 GNUTLS_CERT_SIGNER_NOT_FOUND = 64,
452 GNUTLS_CERT_SIGNER_NOT_CA = 128,
453 GNUTLS_CERT_INSECURE_ALGORITHM = 256,
454 GNUTLS_CERT_NOT_ACTIVATED = 512,
455 GNUTLS_CERT_EXPIRED = 1024
456 } gnutls_certificate_status_t;
459 * gnutls_certificate_request_t:
460 * @GNUTLS_CERT_IGNORE: Ignore certificate.
461 * @GNUTLS_CERT_REQUEST: Request certificate.
462 * @GNUTLS_CERT_REQUIRE: Require certificate.
464 * Enumeration of certificate request types.
466 typedef enum
468 GNUTLS_CERT_IGNORE = 0,
469 GNUTLS_CERT_REQUEST = 1,
470 GNUTLS_CERT_REQUIRE = 2
471 } gnutls_certificate_request_t;
474 * gnutls_openpgp_crt_status_t:
475 * @GNUTLS_OPENPGP_CERT: Send entire certificate.
476 * @GNUTLS_OPENPGP_CERT_FINGERPRINT: Send only certificate fingerprint.
478 * Enumeration of ways to send OpenPGP certificate.
480 typedef enum
482 GNUTLS_OPENPGP_CERT = 0,
483 GNUTLS_OPENPGP_CERT_FINGERPRINT = 1
484 } gnutls_openpgp_crt_status_t;
487 * gnutls_close_request_t:
488 * @GNUTLS_SHUT_RDWR: Disallow further receives/sends.
489 * @GNUTLS_SHUT_WR: Disallow further sends.
491 * Enumeration of how TLS session should be terminated. See gnutls_bye().
493 typedef enum
495 GNUTLS_SHUT_RDWR = 0,
496 GNUTLS_SHUT_WR = 1
497 } gnutls_close_request_t;
500 * gnutls_protocol_t:
501 * @GNUTLS_SSL3: SSL version 3.0.
502 * @GNUTLS_TLS1_0: TLS version 1.0.
503 * @GNUTLS_TLS1: Same as %GNUTLS_TLS1_0.
504 * @GNUTLS_TLS1_1: TLS version 1.1.
505 * @GNUTLS_TLS1_2: TLS version 1.2.
506 * @GNUTLS_DTLS1_0: DTLS version 1.0.
507 * @GNUTLS_VERSION_MAX: Maps to the highest supported TLS version.
508 * @GNUTLS_VERSION_UNKNOWN: Unknown SSL/TLS version.
510 * Enumeration of different SSL/TLS protocol versions.
512 typedef enum
514 GNUTLS_SSL3 = 1,
515 GNUTLS_TLS1_0 = 2,
516 GNUTLS_TLS1 = GNUTLS_TLS1_0,
517 GNUTLS_TLS1_1 = 3,
518 GNUTLS_TLS1_2 = 4,
519 GNUTLS_DTLS1_0 = 5,
520 GNUTLS_VERSION_MAX = GNUTLS_DTLS1_0,
521 GNUTLS_VERSION_UNKNOWN = 0xff
522 } gnutls_protocol_t;
525 * gnutls_certificate_type_t:
526 * @GNUTLS_CRT_UNKNOWN: Unknown certificate type.
527 * @GNUTLS_CRT_X509: X.509 Certificate.
528 * @GNUTLS_CRT_OPENPGP: OpenPGP certificate.
529 * @GNUTLS_CRT_RAW: Raw public key (SubjectPublicKey)
531 * Enumeration of different certificate types.
533 typedef enum
535 GNUTLS_CRT_UNKNOWN = 0,
536 GNUTLS_CRT_X509 = 1,
537 GNUTLS_CRT_OPENPGP = 2,
538 GNUTLS_CRT_RAW = 3
539 } gnutls_certificate_type_t;
542 * gnutls_x509_crt_fmt_t:
543 * @GNUTLS_X509_FMT_DER: X.509 certificate in DER format (binary).
544 * @GNUTLS_X509_FMT_PEM: X.509 certificate in PEM format (text).
546 * Enumeration of different certificate encoding formats.
548 typedef enum
550 GNUTLS_X509_FMT_DER = 0,
551 GNUTLS_X509_FMT_PEM = 1
552 } gnutls_x509_crt_fmt_t;
555 * gnutls_certificate_print_formats_t:
556 * @GNUTLS_CRT_PRINT_FULL: Full information about certificate.
557 * @GNUTLS_CRT_PRINT_COMPACT: Information about certificate name in one line, plus identification of the public key.
558 * @GNUTLS_CRT_PRINT_ONELINE: Information about certificate in one line.
559 * @GNUTLS_CRT_PRINT_UNSIGNED_FULL: All info for an unsigned certificate.
561 * Enumeration of different certificate printing variants.
563 typedef enum gnutls_certificate_print_formats
565 GNUTLS_CRT_PRINT_FULL = 0,
566 GNUTLS_CRT_PRINT_ONELINE = 1,
567 GNUTLS_CRT_PRINT_UNSIGNED_FULL = 2,
568 GNUTLS_CRT_PRINT_COMPACT = 3
569 } gnutls_certificate_print_formats_t;
571 #define GNUTLS_PK_ECC GNUTLS_PK_EC
573 * gnutls_pk_algorithm_t:
574 * @GNUTLS_PK_UNKNOWN: Unknown public-key algorithm.
575 * @GNUTLS_PK_RSA: RSA public-key algorithm.
576 * @GNUTLS_PK_DSA: DSA public-key algorithm.
577 * @GNUTLS_PK_DH: Diffie-Hellman algorithm. Used to generate parameters.
578 * @GNUTLS_PK_EC: Elliptic curve algorithm. Used to generate parameters.
580 * Enumeration of different public-key algorithms.
582 typedef enum
584 GNUTLS_PK_UNKNOWN = 0,
585 GNUTLS_PK_RSA = 1,
586 GNUTLS_PK_DSA = 2,
587 GNUTLS_PK_DH = 3,
588 GNUTLS_PK_EC = 4,
589 } gnutls_pk_algorithm_t;
591 const char *gnutls_pk_algorithm_get_name (gnutls_pk_algorithm_t algorithm);
594 * gnutls_sign_algorithm_t:
595 * @GNUTLS_SIGN_UNKNOWN: Unknown signature algorithm.
596 * @GNUTLS_SIGN_RSA_SHA1: Digital signature algorithm RSA with SHA-1
597 * @GNUTLS_SIGN_RSA_SHA: Same as %GNUTLS_SIGN_RSA_SHA1.
598 * @GNUTLS_SIGN_DSA_SHA1: Digital signature algorithm DSA with SHA-1
599 * @GNUTLS_SIGN_DSA_SHA224: Digital signature algorithm DSA with SHA-224
600 * @GNUTLS_SIGN_DSA_SHA256: Digital signature algorithm DSA with SHA-256
601 * @GNUTLS_SIGN_DSA_SHA: Same as %GNUTLS_SIGN_DSA_SHA1.
602 * @GNUTLS_SIGN_RSA_MD5: Digital signature algorithm RSA with MD5.
603 * @GNUTLS_SIGN_RSA_MD2: Digital signature algorithm RSA with MD2.
604 * @GNUTLS_SIGN_RSA_RMD160: Digital signature algorithm RSA with RMD-160.
605 * @GNUTLS_SIGN_RSA_SHA256: Digital signature algorithm RSA with SHA-256.
606 * @GNUTLS_SIGN_RSA_SHA384: Digital signature algorithm RSA with SHA-384.
607 * @GNUTLS_SIGN_RSA_SHA512: Digital signature algorithm RSA with SHA-512.
608 * @GNUTLS_SIGN_RSA_SHA224: Digital signature algorithm RSA with SHA-224.
609 * @GNUTLS_SIGN_ECDSA_SHA1: ECDSA with SHA1.
610 * @GNUTLS_SIGN_ECDSA_SHA256: Digital signature algorithm ECDSA with SHA-256.
611 * @GNUTLS_SIGN_ECDSA_SHA384: Digital signature algorithm ECDSA with SHA-384.
612 * @GNUTLS_SIGN_ECDSA_SHA512: Digital signature algorithm ECDSA with SHA-512.
613 * @GNUTLS_SIGN_ECDSA_SHA224: Digital signature algorithm ECDSA with SHA-224.
615 * Enumeration of different digital signature algorithms.
617 typedef enum
619 GNUTLS_SIGN_UNKNOWN = 0,
620 GNUTLS_SIGN_RSA_SHA1 = 1,
621 GNUTLS_SIGN_RSA_SHA = GNUTLS_SIGN_RSA_SHA1,
622 GNUTLS_SIGN_DSA_SHA1 = 2,
623 GNUTLS_SIGN_DSA_SHA = GNUTLS_SIGN_DSA_SHA1,
624 GNUTLS_SIGN_RSA_MD5 = 3,
625 GNUTLS_SIGN_RSA_MD2 = 4,
626 GNUTLS_SIGN_RSA_RMD160 = 5,
627 GNUTLS_SIGN_RSA_SHA256 = 6,
628 GNUTLS_SIGN_RSA_SHA384 = 7,
629 GNUTLS_SIGN_RSA_SHA512 = 8,
630 GNUTLS_SIGN_RSA_SHA224 = 9,
631 GNUTLS_SIGN_DSA_SHA224 = 10,
632 GNUTLS_SIGN_DSA_SHA256 = 11,
633 GNUTLS_SIGN_ECDSA_SHA1 = 12,
634 GNUTLS_SIGN_ECDSA_SHA224 = 13,
635 GNUTLS_SIGN_ECDSA_SHA256 = 14,
636 GNUTLS_SIGN_ECDSA_SHA384 = 15,
637 GNUTLS_SIGN_ECDSA_SHA512 = 16,
638 } gnutls_sign_algorithm_t;
641 * gnutls_ecc_curve_t:
642 * @GNUTLS_ECC_CURVE_INVALID: Cannot be known
643 * @GNUTLS_ECC_CURVE_SECP192R1: the SECP192R1 curve
644 * @GNUTLS_ECC_CURVE_SECP224R1: the SECP224R1 curve
645 * @GNUTLS_ECC_CURVE_SECP256R1: the SECP256R1 curve
646 * @GNUTLS_ECC_CURVE_SECP384R1: the SECP384R1 curve
647 * @GNUTLS_ECC_CURVE_SECP521R1: the SECP521R1 curve
649 * Enumeration of ECC curves.
651 typedef enum
653 GNUTLS_ECC_CURVE_INVALID=0,
654 GNUTLS_ECC_CURVE_SECP224R1,
655 GNUTLS_ECC_CURVE_SECP256R1,
656 GNUTLS_ECC_CURVE_SECP384R1,
657 GNUTLS_ECC_CURVE_SECP521R1,
658 GNUTLS_ECC_CURVE_SECP192R1,
659 } gnutls_ecc_curve_t;
661 #define GNUTLS_SEC_PARAM_WEAK GNUTLS_SEC_PARAM_LOW
664 * gnutls_sec_param_t:
665 * @GNUTLS_SEC_PARAM_UNKNOWN: Cannot be known
666 * @GNUTLS_SEC_PARAM_LOW: low security level
667 * @GNUTLS_SEC_PARAM_LEGACY: 96 bits of security
668 * @GNUTLS_SEC_PARAM_NORMAL: 112 bits of security
669 * @GNUTLS_SEC_PARAM_HIGH: 128 bits of security
670 * @GNUTLS_SEC_PARAM_ULTRA: 192 bits of security
672 * Enumeration of security parameters for passive attacks.
674 typedef enum
676 GNUTLS_SEC_PARAM_UNKNOWN,
677 GNUTLS_SEC_PARAM_LOW = 1,
678 GNUTLS_SEC_PARAM_LEGACY = 2,
679 GNUTLS_SEC_PARAM_NORMAL = 3,
680 GNUTLS_SEC_PARAM_HIGH = 4,
681 GNUTLS_SEC_PARAM_ULTRA = 5,
682 } gnutls_sec_param_t;
685 * gnutls_channel_binding_t:
686 * @GNUTLS_CB_TLS_UNIQUE: "tls-unique" (RFC 5929) channel binding
688 * Enumeration of support channel binding types.
690 typedef enum
692 GNUTLS_CB_TLS_UNIQUE
693 } gnutls_channel_binding_t;
695 /* If you want to change this, then also change the define in
696 * gnutls_int.h, and recompile.
698 typedef void *gnutls_transport_ptr_t;
700 struct gnutls_session_int;
701 typedef struct gnutls_session_int *gnutls_session_t;
703 struct gnutls_dh_params_int;
704 typedef struct gnutls_dh_params_int *gnutls_dh_params_t;
706 struct gnutls_ecdh_params_int;
707 typedef struct gnutls_ecdh_params_int *gnutls_ecdh_params_t;
709 /* XXX ugly. */
710 struct gnutls_x509_privkey_int;
711 typedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t;
713 struct gnutls_priority_st;
714 typedef struct gnutls_priority_st *gnutls_priority_t;
716 typedef struct
718 unsigned char *data;
719 unsigned int size;
720 } gnutls_datum_t;
723 typedef struct gnutls_params_st
725 gnutls_params_type_t type;
726 union params
728 gnutls_dh_params_t dh;
729 gnutls_ecdh_params_t ecdh;
730 gnutls_rsa_params_t rsa_export;
731 } params;
732 int deinit;
733 } gnutls_params_st;
735 typedef int gnutls_params_function (gnutls_session_t, gnutls_params_type_t,
736 gnutls_params_st *);
738 /* internal functions */
740 int gnutls_init (gnutls_session_t * session,
741 unsigned int flags);
742 void gnutls_deinit (gnutls_session_t session);
743 #define _gnutls_deinit(x) gnutls_deinit(x)
745 int gnutls_bye (gnutls_session_t session, gnutls_close_request_t how);
747 int gnutls_handshake (gnutls_session_t session);
748 int gnutls_rehandshake (gnutls_session_t session);
750 gnutls_alert_description_t gnutls_alert_get (gnutls_session_t session);
751 int gnutls_alert_send (gnutls_session_t session,
752 gnutls_alert_level_t level,
753 gnutls_alert_description_t desc);
754 int gnutls_alert_send_appropriate (gnutls_session_t session, int err);
755 const char *gnutls_alert_get_name (gnutls_alert_description_t alert);
756 const char * gnutls_alert_get_strname (gnutls_alert_description_t alert);
758 gnutls_sec_param_t gnutls_pk_bits_to_sec_param (gnutls_pk_algorithm_t algo,
759 unsigned int bits);
760 const char *gnutls_sec_param_get_name (gnutls_sec_param_t param);
761 unsigned int gnutls_sec_param_to_pk_bits (gnutls_pk_algorithm_t algo,
762 gnutls_sec_param_t param);
764 /* Elliptic curves */
765 const char * gnutls_ecc_curve_get_name (gnutls_ecc_curve_t curve);
766 int gnutls_ecc_curve_get_size (gnutls_ecc_curve_t curve);
767 gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
769 /* get information on the current session */
770 gnutls_cipher_algorithm_t gnutls_cipher_get (gnutls_session_t session);
771 gnutls_kx_algorithm_t gnutls_kx_get (gnutls_session_t session);
772 gnutls_mac_algorithm_t gnutls_mac_get (gnutls_session_t session);
773 gnutls_compression_method_t
774 gnutls_compression_get (gnutls_session_t session);
775 gnutls_certificate_type_t
776 gnutls_certificate_type_get (gnutls_session_t session);
777 int gnutls_sign_algorithm_get_requested (gnutls_session_t session,
778 size_t indx,
779 gnutls_sign_algorithm_t * algo);
781 size_t gnutls_cipher_get_key_size (gnutls_cipher_algorithm_t algorithm);
782 size_t gnutls_mac_get_key_size (gnutls_mac_algorithm_t algorithm);
784 /* the name of the specified algorithms */
785 const char *gnutls_cipher_get_name (gnutls_cipher_algorithm_t algorithm);
786 const char *gnutls_mac_get_name (gnutls_mac_algorithm_t algorithm);
787 const char *gnutls_compression_get_name (gnutls_compression_method_t
788 algorithm);
789 const char *gnutls_kx_get_name (gnutls_kx_algorithm_t algorithm);
790 const char *gnutls_certificate_type_get_name (gnutls_certificate_type_t
791 type);
792 const char *gnutls_pk_get_name (gnutls_pk_algorithm_t algorithm);
793 const char *gnutls_sign_get_name (gnutls_sign_algorithm_t algorithm);
794 #define gnutls_sign_algorithm_get_name gnutls_sign_get_name
796 gnutls_mac_algorithm_t gnutls_mac_get_id (const char *name);
797 gnutls_compression_method_t gnutls_compression_get_id (const char *name);
798 gnutls_cipher_algorithm_t gnutls_cipher_get_id (const char *name);
799 gnutls_kx_algorithm_t gnutls_kx_get_id (const char *name);
800 gnutls_protocol_t gnutls_protocol_get_id (const char *name);
801 gnutls_certificate_type_t gnutls_certificate_type_get_id (const char *name);
802 gnutls_pk_algorithm_t gnutls_pk_get_id (const char *name);
803 gnutls_sign_algorithm_t gnutls_sign_get_id (const char *name);
805 /* list supported algorithms */
806 const gnutls_ecc_curve_t * gnutls_ecc_curve_list (void);
807 const gnutls_cipher_algorithm_t *gnutls_cipher_list (void);
808 const gnutls_mac_algorithm_t *gnutls_mac_list (void);
809 const gnutls_compression_method_t *gnutls_compression_list (void);
810 const gnutls_protocol_t *gnutls_protocol_list (void);
811 const gnutls_certificate_type_t *gnutls_certificate_type_list (void);
812 const gnutls_kx_algorithm_t *gnutls_kx_list (void);
813 const gnutls_pk_algorithm_t *gnutls_pk_list (void);
814 const gnutls_sign_algorithm_t *gnutls_sign_list (void);
815 const char *gnutls_cipher_suite_info (size_t idx,
816 unsigned char *cs_id,
817 gnutls_kx_algorithm_t * kx,
818 gnutls_cipher_algorithm_t * cipher,
819 gnutls_mac_algorithm_t * mac,
820 gnutls_protocol_t * min_version);
822 /* error functions */
823 int gnutls_error_is_fatal (int error);
824 int gnutls_error_to_alert (int err, int *level);
826 void gnutls_perror (int error);
827 const char *gnutls_strerror (int error);
828 const char *gnutls_strerror_name (int error);
830 /* Semi-internal functions.
832 void gnutls_handshake_set_private_extensions (gnutls_session_t session,
833 int allow);
834 gnutls_handshake_description_t
835 gnutls_handshake_get_last_out (gnutls_session_t session);
836 gnutls_handshake_description_t
837 gnutls_handshake_get_last_in (gnutls_session_t session);
839 /* Record layer functions.
841 ssize_t gnutls_record_send (gnutls_session_t session, const void *data,
842 size_t data_size);
843 ssize_t gnutls_record_recv (gnutls_session_t session, void *data,
844 size_t data_size);
845 #define gnutls_read gnutls_record_recv
846 #define gnutls_write gnutls_record_send
847 ssize_t gnutls_record_recv_seq (gnutls_session_t session, void *data, size_t data_size,
848 unsigned char *seq);
850 void gnutls_session_enable_compatibility_mode (gnutls_session_t session);
852 void gnutls_record_disable_padding (gnutls_session_t session);
854 int gnutls_record_get_direction (gnutls_session_t session);
856 size_t gnutls_record_get_max_size (gnutls_session_t session);
857 ssize_t gnutls_record_set_max_size (gnutls_session_t session, size_t size);
859 size_t gnutls_record_check_pending (gnutls_session_t session);
861 int gnutls_prf (gnutls_session_t session,
862 size_t label_size, const char *label,
863 int server_random_first,
864 size_t extra_size, const char *extra,
865 size_t outsize, char *out);
867 int gnutls_prf_raw (gnutls_session_t session,
868 size_t label_size, const char *label,
869 size_t seed_size, const char *seed,
870 size_t outsize, char *out);
873 * gnutls_server_name_type_t:
874 * @GNUTLS_NAME_DNS: Domain Name System name type.
876 * Enumeration of different server name types.
878 typedef enum
880 GNUTLS_NAME_DNS = 1
881 } gnutls_server_name_type_t;
883 int gnutls_server_name_set (gnutls_session_t session,
884 gnutls_server_name_type_t type,
885 const void *name, size_t name_length);
887 int gnutls_server_name_get (gnutls_session_t session,
888 void *data, size_t * data_length,
889 unsigned int *type, unsigned int indx);
891 /* Safe renegotiation */
892 int gnutls_safe_renegotiation_status (gnutls_session_t session);
895 * gnutls_supplemental_data_format_type_t:
896 * @GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA: Supplemental user mapping data.
898 * Enumeration of different supplemental data types (RFC 4680).
900 typedef enum
902 GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0
903 } gnutls_supplemental_data_format_type_t;
905 const char
906 *gnutls_supplemental_get_name (gnutls_supplemental_data_format_type_t
907 type);
909 /* SessionTicket, RFC 5077. */
910 int gnutls_session_ticket_key_generate (gnutls_datum_t * key);
911 int gnutls_session_ticket_enable_client (gnutls_session_t session);
912 int gnutls_session_ticket_enable_server (gnutls_session_t session,
913 const gnutls_datum_t * key);
915 int gnutls_key_generate (gnutls_datum_t * key, unsigned int key_size);
917 /* if you just want some defaults, use the following.
919 int gnutls_priority_init (gnutls_priority_t * priority_cache,
920 const char *priorities, const char **err_pos);
921 void gnutls_priority_deinit (gnutls_priority_t priority_cache);
922 int gnutls_priority_get_cipher_suite_index (gnutls_priority_t pcache, unsigned int idx, unsigned int *sidx);
924 int gnutls_priority_set (gnutls_session_t session,
925 gnutls_priority_t priority);
926 int gnutls_priority_set_direct (gnutls_session_t session,
927 const char *priorities,
928 const char **err_pos);
930 int gnutls_priority_certificate_type_list (gnutls_priority_t pcache, const unsigned int** list);
931 int gnutls_priority_sign_list (gnutls_priority_t pcache, const unsigned int** list);
932 int gnutls_priority_protocol_list (gnutls_priority_t pcache, const unsigned int** list);
933 int gnutls_priority_compression_list (gnutls_priority_t pcache, const unsigned int** list);
934 int gnutls_priority_ecc_curve_list (gnutls_priority_t pcache, const unsigned int** list);
936 /* for compatibility
938 int gnutls_set_default_priority (gnutls_session_t session);
940 /* Returns the name of a cipher suite */
941 const char *gnutls_cipher_suite_get_name (gnutls_kx_algorithm_t
942 kx_algorithm,
943 gnutls_cipher_algorithm_t
944 cipher_algorithm,
945 gnutls_mac_algorithm_t
946 mac_algorithm);
948 /* get the currently used protocol version */
949 gnutls_protocol_t gnutls_protocol_get_version (gnutls_session_t session);
951 const char *gnutls_protocol_get_name (gnutls_protocol_t version);
954 /* get/set session
956 int gnutls_session_set_data (gnutls_session_t session,
957 const void *session_data,
958 size_t session_data_size);
959 int gnutls_session_get_data (gnutls_session_t session, void *session_data,
960 size_t * session_data_size);
961 int gnutls_session_get_data2 (gnutls_session_t session,
962 gnutls_datum_t * data);
963 void gnutls_session_get_random (gnutls_session_t session, gnutls_datum_t* client,
964 gnutls_datum_t* server);
966 /* returns the session ID */
967 #define GNUTLS_MAX_SESSION_ID 32
968 int gnutls_session_get_id (gnutls_session_t session, void *session_id,
969 size_t * session_id_size);
972 int gnutls_session_channel_binding (gnutls_session_t session,
973 gnutls_channel_binding_t cbtype,
974 gnutls_datum_t * cb);
976 /* checks if this session is a resumed one
978 int gnutls_session_is_resumed (gnutls_session_t session);
979 int gnutls_session_resumption_requested (gnutls_session_t session);
981 typedef int (*gnutls_db_store_func) (void *, gnutls_datum_t key,
982 gnutls_datum_t data);
983 typedef int (*gnutls_db_remove_func) (void *, gnutls_datum_t key);
984 typedef gnutls_datum_t (*gnutls_db_retr_func) (void *, gnutls_datum_t key);
986 void gnutls_db_set_cache_expiration (gnutls_session_t session, int seconds);
988 void gnutls_db_remove_session (gnutls_session_t session);
989 void gnutls_db_set_retrieve_function (gnutls_session_t session,
990 gnutls_db_retr_func retr_func);
991 void gnutls_db_set_remove_function (gnutls_session_t session,
992 gnutls_db_remove_func rem_func);
993 void gnutls_db_set_store_function (gnutls_session_t session,
994 gnutls_db_store_func store_func);
995 void gnutls_db_set_ptr (gnutls_session_t session, void *ptr);
996 void *gnutls_db_get_ptr (gnutls_session_t session);
997 int gnutls_db_check_entry (gnutls_session_t session,
998 gnutls_datum_t session_entry);
1000 typedef int (*gnutls_handshake_post_client_hello_func) (gnutls_session_t);
1001 void
1002 gnutls_handshake_set_post_client_hello_function (gnutls_session_t session,
1003 gnutls_handshake_post_client_hello_func
1004 func);
1006 void gnutls_handshake_set_max_packet_length (gnutls_session_t session,
1007 size_t max);
1009 /* returns libgnutls version (call it with a NULL argument)
1011 const char *gnutls_check_version (const char *req_version);
1013 /* Functions for setting/clearing credentials
1015 void gnutls_credentials_clear (gnutls_session_t session);
1017 /* cred is a structure defined by the kx algorithm
1019 int gnutls_credentials_set (gnutls_session_t session,
1020 gnutls_credentials_type_t type, void *cred);
1021 #define gnutls_cred_set gnutls_credentials_set
1023 /* x.509 types */
1025 struct gnutls_x509_privkey_int;
1026 typedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;
1028 struct gnutls_x509_crl_int;
1029 typedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;
1031 struct gnutls_x509_crt_int;
1032 typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;
1034 struct gnutls_x509_crq_int;
1035 typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;
1037 struct gnutls_openpgp_keyring_int;
1038 typedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;
1041 /* Credential structures - used in gnutls_credentials_set(); */
1043 struct gnutls_certificate_credentials_st;
1044 typedef struct gnutls_certificate_credentials_st
1045 *gnutls_certificate_credentials_t;
1046 typedef gnutls_certificate_credentials_t
1047 gnutls_certificate_server_credentials;
1048 typedef gnutls_certificate_credentials_t
1049 gnutls_certificate_client_credentials;
1051 typedef struct gnutls_anon_server_credentials_st
1052 *gnutls_anon_server_credentials_t;
1053 typedef struct gnutls_anon_client_credentials_st
1054 *gnutls_anon_client_credentials_t;
1056 void gnutls_anon_free_server_credentials (gnutls_anon_server_credentials_t
1057 sc);
1059 gnutls_anon_allocate_server_credentials (gnutls_anon_server_credentials_t
1060 * sc);
1062 void gnutls_anon_set_server_dh_params (gnutls_anon_server_credentials_t res,
1063 gnutls_dh_params_t dh_params);
1065 void
1066 gnutls_anon_set_server_params_function (gnutls_anon_server_credentials_t
1067 res,
1068 gnutls_params_function * func);
1070 void
1071 gnutls_anon_free_client_credentials (gnutls_anon_client_credentials_t sc);
1073 gnutls_anon_allocate_client_credentials (gnutls_anon_client_credentials_t
1074 * sc);
1076 /* CERTFILE is an x509 certificate in PEM form.
1077 * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).
1079 void
1080 gnutls_certificate_free_credentials (gnutls_certificate_credentials_t sc);
1082 gnutls_certificate_allocate_credentials (gnutls_certificate_credentials_t
1083 * res);
1086 gnutls_certificate_get_issuer (gnutls_certificate_credentials_t sc,
1087 gnutls_x509_crt_t cert, gnutls_x509_crt_t* issuer, unsigned int flags);
1089 void gnutls_certificate_free_keys (gnutls_certificate_credentials_t sc);
1090 void gnutls_certificate_free_cas (gnutls_certificate_credentials_t sc);
1091 void gnutls_certificate_free_ca_names (gnutls_certificate_credentials_t sc);
1092 void gnutls_certificate_free_crls (gnutls_certificate_credentials_t sc);
1094 void gnutls_certificate_set_dh_params (gnutls_certificate_credentials_t res,
1095 gnutls_dh_params_t dh_params);
1096 void gnutls_certificate_set_verify_flags (gnutls_certificate_credentials_t
1097 res, unsigned int flags);
1098 void gnutls_certificate_set_verify_limits (gnutls_certificate_credentials_t
1099 res, unsigned int max_bits,
1100 unsigned int max_depth);
1103 gnutls_certificate_set_x509_trust_file (gnutls_certificate_credentials_t
1104 cred, const char *cafile,
1105 gnutls_x509_crt_fmt_t type);
1106 int gnutls_certificate_set_x509_trust_mem (gnutls_certificate_credentials_t
1107 res, const gnutls_datum_t * ca,
1108 gnutls_x509_crt_fmt_t type);
1111 gnutls_certificate_set_x509_crl_file (gnutls_certificate_credentials_t
1112 res, const char *crlfile,
1113 gnutls_x509_crt_fmt_t type);
1114 int gnutls_certificate_set_x509_crl_mem (gnutls_certificate_credentials_t
1115 res, const gnutls_datum_t * CRL,
1116 gnutls_x509_crt_fmt_t type);
1119 gnutls_certificate_set_x509_key_file (gnutls_certificate_credentials_t
1120 res, const char *certfile,
1121 const char *keyfile,
1122 gnutls_x509_crt_fmt_t type);
1123 int gnutls_certificate_set_x509_key_mem (gnutls_certificate_credentials_t
1124 res, const gnutls_datum_t * cert,
1125 const gnutls_datum_t * key,
1126 gnutls_x509_crt_fmt_t type);
1128 void gnutls_certificate_send_x509_rdn_sequence (gnutls_session_t session,
1129 int status);
1131 int gnutls_certificate_set_x509_simple_pkcs12_file (gnutls_certificate_credentials_t res, const char *pkcs12file,
1132 gnutls_x509_crt_fmt_t type, const char *password);
1133 int gnutls_certificate_set_x509_simple_pkcs12_mem (gnutls_certificate_credentials_t res, const gnutls_datum_t * p12blob,
1134 gnutls_x509_crt_fmt_t type, const char *password);
1136 /* New functions to allow setting already parsed X.509 stuff.
1139 int gnutls_certificate_set_x509_key (gnutls_certificate_credentials_t res,
1140 gnutls_x509_crt_t * cert_list,
1141 int cert_list_size,
1142 gnutls_x509_privkey_t key);
1143 int gnutls_certificate_set_x509_trust (gnutls_certificate_credentials_t res,
1144 gnutls_x509_crt_t * ca_list,
1145 int ca_list_size);
1146 int gnutls_certificate_set_x509_crl (gnutls_certificate_credentials_t res,
1147 gnutls_x509_crl_t * crl_list,
1148 int crl_list_size);
1150 void
1151 gnutls_certificate_get_openpgp_keyring (gnutls_certificate_credentials_t
1153 gnutls_openpgp_keyring_t *
1154 keyring);
1156 /* global state functions
1158 int gnutls_global_init (void);
1159 void gnutls_global_deinit (void);
1162 * gnutls_time_func:
1163 * @t: where to store time.
1165 * Function prototype for time()-like function. Set with
1166 * gnutls_global_set_time_function().
1168 * Returns: Number of seconds since the epoch, or (time_t)-1 on errors.
1170 typedef time_t (*gnutls_time_func) (time_t *t);
1172 typedef int (*mutex_init_func) (void **mutex);
1173 typedef int (*mutex_lock_func) (void **mutex);
1174 typedef int (*mutex_unlock_func) (void **mutex);
1175 typedef int (*mutex_deinit_func) (void **mutex);
1177 void gnutls_global_set_mutex (mutex_init_func init, mutex_deinit_func deinit,
1178 mutex_lock_func lock, mutex_unlock_func unlock);
1180 typedef void *(*gnutls_alloc_function) (size_t);
1181 typedef void *(*gnutls_calloc_function) (size_t, size_t);
1182 typedef int (*gnutls_is_secure_function) (const void *);
1183 typedef void (*gnutls_free_function) (void *);
1184 typedef void *(*gnutls_realloc_function) (void *, size_t);
1186 void
1187 gnutls_global_set_mem_functions (gnutls_alloc_function alloc_func,
1188 gnutls_alloc_function secure_alloc_func,
1189 gnutls_is_secure_function is_secure_func,
1190 gnutls_realloc_function realloc_func,
1191 gnutls_free_function free_func);
1193 void gnutls_global_set_time_function (gnutls_time_func time_func);
1195 /* For use in callbacks */
1196 extern gnutls_alloc_function gnutls_malloc;
1197 extern gnutls_alloc_function gnutls_secure_malloc;
1198 extern gnutls_realloc_function gnutls_realloc;
1199 extern gnutls_calloc_function gnutls_calloc;
1200 extern gnutls_free_function gnutls_free;
1202 extern char *(*gnutls_strdup) (const char *);
1204 typedef void (*gnutls_log_func) (int, const char *);
1205 typedef void (*gnutls_audit_log_func) (gnutls_session_t, const char *);
1206 void gnutls_global_set_log_function (gnutls_log_func log_func);
1207 void gnutls_global_set_audit_log_function (gnutls_audit_log_func log_func);
1208 void gnutls_global_set_log_level (int level);
1210 /* Diffie-Hellman parameter handling.
1212 int gnutls_dh_params_init (gnutls_dh_params_t * dh_params);
1213 void gnutls_dh_params_deinit (gnutls_dh_params_t dh_params);
1214 int gnutls_dh_params_import_raw (gnutls_dh_params_t dh_params,
1215 const gnutls_datum_t * prime,
1216 const gnutls_datum_t * generator);
1217 int gnutls_dh_params_import_pkcs3 (gnutls_dh_params_t params,
1218 const gnutls_datum_t * pkcs3_params,
1219 gnutls_x509_crt_fmt_t format);
1220 int gnutls_dh_params_generate2 (gnutls_dh_params_t params,
1221 unsigned int bits);
1222 int gnutls_dh_params_export_pkcs3 (gnutls_dh_params_t params,
1223 gnutls_x509_crt_fmt_t format,
1224 unsigned char *params_data,
1225 size_t * params_data_size);
1226 int gnutls_dh_params_export_raw (gnutls_dh_params_t params,
1227 gnutls_datum_t * prime,
1228 gnutls_datum_t * generator,
1229 unsigned int *bits);
1230 int gnutls_dh_params_cpy (gnutls_dh_params_t dst, gnutls_dh_params_t src);
1234 /* Session stuff
1236 typedef struct
1238 void *iov_base; /* Starting address */
1239 size_t iov_len; /* Number of bytes to transfer */
1240 } giovec_t;
1242 typedef ssize_t (*gnutls_pull_func) (gnutls_transport_ptr_t, void *,
1243 size_t);
1244 typedef ssize_t (*gnutls_push_func) (gnutls_transport_ptr_t, const void *,
1245 size_t);
1247 typedef int (*gnutls_pull_timeout_func) (gnutls_transport_ptr_t, unsigned int ms);
1249 typedef ssize_t (*gnutls_vec_push_func) (gnutls_transport_ptr_t,
1250 const giovec_t * iov, int iovcnt);
1252 typedef int (*gnutls_errno_func) (gnutls_transport_ptr_t);
1254 void gnutls_transport_set_ptr (gnutls_session_t session,
1255 gnutls_transport_ptr_t ptr);
1256 void gnutls_transport_set_ptr2 (gnutls_session_t session,
1257 gnutls_transport_ptr_t recv_ptr,
1258 gnutls_transport_ptr_t send_ptr);
1260 gnutls_transport_ptr_t gnutls_transport_get_ptr (gnutls_session_t session);
1261 void gnutls_transport_get_ptr2 (gnutls_session_t session,
1262 gnutls_transport_ptr_t * recv_ptr,
1263 gnutls_transport_ptr_t * send_ptr);
1265 void gnutls_transport_set_vec_push_function (gnutls_session_t session,
1266 gnutls_vec_push_func vec_func);
1267 void gnutls_transport_set_push_function (gnutls_session_t session,
1268 gnutls_push_func push_func);
1269 void gnutls_transport_set_pull_function (gnutls_session_t session,
1270 gnutls_pull_func pull_func);
1272 void gnutls_transport_set_pull_timeout_function (gnutls_session_t session,
1273 gnutls_pull_timeout_func func);
1275 void gnutls_transport_set_errno_function (gnutls_session_t session,
1276 gnutls_errno_func errno_func);
1278 void gnutls_transport_set_errno (gnutls_session_t session, int err);
1280 /* session specific
1282 void gnutls_session_set_ptr (gnutls_session_t session, void *ptr);
1283 void *gnutls_session_get_ptr (gnutls_session_t session);
1285 void gnutls_openpgp_send_cert (gnutls_session_t session,
1286 gnutls_openpgp_crt_status_t status);
1288 /* This function returns the hash of the given data.
1290 int gnutls_fingerprint (gnutls_digest_algorithm_t algo,
1291 const gnutls_datum_t * data, void *result,
1292 size_t * result_size);
1295 * gnutls_random_art_t:
1296 * @GNUTLS_RANDOM_ART_OPENSSH: OpenSSH-style random art.
1298 * Enumeration of different random art types.
1300 typedef enum gnutls_random_art
1302 GNUTLS_RANDOM_ART_OPENSSH=1,
1303 } gnutls_random_art_t;
1305 int gnutls_random_art (gnutls_random_art_t type,
1306 const char* key_type, unsigned int key_size,
1307 void * fpr, size_t fpr_size,
1308 gnutls_datum_t* art);
1310 /* SRP
1313 typedef struct gnutls_srp_server_credentials_st
1314 *gnutls_srp_server_credentials_t;
1315 typedef struct gnutls_srp_client_credentials_st
1316 *gnutls_srp_client_credentials_t;
1318 void
1319 gnutls_srp_free_client_credentials (gnutls_srp_client_credentials_t sc);
1321 gnutls_srp_allocate_client_credentials (gnutls_srp_client_credentials_t *
1322 sc);
1323 int gnutls_srp_set_client_credentials (gnutls_srp_client_credentials_t res,
1324 const char *username,
1325 const char *password);
1327 void
1328 gnutls_srp_free_server_credentials (gnutls_srp_server_credentials_t sc);
1330 gnutls_srp_allocate_server_credentials (gnutls_srp_server_credentials_t *
1331 sc);
1332 int gnutls_srp_set_server_credentials_file (gnutls_srp_server_credentials_t
1333 res, const char *password_file,
1334 const char *password_conf_file);
1336 const char *gnutls_srp_server_get_username (gnutls_session_t session);
1338 extern void gnutls_srp_set_prime_bits (gnutls_session_t session,
1339 unsigned int bits);
1341 int gnutls_srp_verifier (const char *username,
1342 const char *password,
1343 const gnutls_datum_t * salt,
1344 const gnutls_datum_t * generator,
1345 const gnutls_datum_t * prime,
1346 gnutls_datum_t * res);
1348 /* The static parameters defined in draft-ietf-tls-srp-05
1349 * Those should be used as input to gnutls_srp_verifier().
1351 extern const gnutls_datum_t gnutls_srp_4096_group_prime;
1352 extern const gnutls_datum_t gnutls_srp_4096_group_generator;
1354 extern const gnutls_datum_t gnutls_srp_3072_group_prime;
1355 extern const gnutls_datum_t gnutls_srp_3072_group_generator;
1357 extern const gnutls_datum_t gnutls_srp_2048_group_prime;
1358 extern const gnutls_datum_t gnutls_srp_2048_group_generator;
1360 extern const gnutls_datum_t gnutls_srp_1536_group_prime;
1361 extern const gnutls_datum_t gnutls_srp_1536_group_generator;
1363 extern const gnutls_datum_t gnutls_srp_1024_group_prime;
1364 extern const gnutls_datum_t gnutls_srp_1024_group_generator;
1366 typedef int gnutls_srp_server_credentials_function (gnutls_session_t,
1367 const char *username,
1368 gnutls_datum_t * salt,
1369 gnutls_datum_t *
1370 verifier,
1371 gnutls_datum_t *
1372 generator,
1373 gnutls_datum_t * prime);
1374 void
1375 gnutls_srp_set_server_credentials_function (
1376 gnutls_srp_server_credentials_t cred,
1377 gnutls_srp_server_credentials_function * func);
1379 typedef int gnutls_srp_client_credentials_function (gnutls_session_t,
1380 char **, char **);
1381 void
1382 gnutls_srp_set_client_credentials_function (
1383 gnutls_srp_client_credentials_t cred,
1384 gnutls_srp_client_credentials_function * func);
1386 int gnutls_srp_base64_encode (const gnutls_datum_t * data, char *result,
1387 size_t * result_size);
1388 int gnutls_srp_base64_encode_alloc (const gnutls_datum_t * data,
1389 gnutls_datum_t * result);
1391 int gnutls_srp_base64_decode (const gnutls_datum_t * b64_data, char *result,
1392 size_t * result_size);
1393 int gnutls_srp_base64_decode_alloc (const gnutls_datum_t * b64_data,
1394 gnutls_datum_t * result);
1396 /* PSK stuff */
1397 typedef struct gnutls_psk_server_credentials_st
1398 *gnutls_psk_server_credentials_t;
1399 typedef struct gnutls_psk_client_credentials_st
1400 *gnutls_psk_client_credentials_t;
1403 * gnutls_psk_key_flags:
1404 * @GNUTLS_PSK_KEY_RAW: PSK-key in raw format.
1405 * @GNUTLS_PSK_KEY_HEX: PSK-key in hex format.
1407 * Enumeration of different PSK key flags.
1409 typedef enum gnutls_psk_key_flags
1411 GNUTLS_PSK_KEY_RAW = 0,
1412 GNUTLS_PSK_KEY_HEX
1413 } gnutls_psk_key_flags;
1415 void
1416 gnutls_psk_free_client_credentials (gnutls_psk_client_credentials_t sc);
1418 gnutls_psk_allocate_client_credentials (gnutls_psk_client_credentials_t *
1419 sc);
1420 int gnutls_psk_set_client_credentials (gnutls_psk_client_credentials_t res,
1421 const char *username,
1422 const gnutls_datum_t * key,
1423 gnutls_psk_key_flags flags);
1425 void
1426 gnutls_psk_free_server_credentials (gnutls_psk_server_credentials_t sc);
1428 gnutls_psk_allocate_server_credentials (gnutls_psk_server_credentials_t *
1429 sc);
1430 int gnutls_psk_set_server_credentials_file (gnutls_psk_server_credentials_t
1431 res, const char *password_file);
1434 gnutls_psk_set_server_credentials_hint (gnutls_psk_server_credentials_t
1435 res, const char *hint);
1437 const char *gnutls_psk_server_get_username (gnutls_session_t session);
1438 const char *gnutls_psk_client_get_hint (gnutls_session_t session);
1440 typedef int gnutls_psk_server_credentials_function (gnutls_session_t,
1441 const char *username,
1442 gnutls_datum_t * key);
1443 void
1444 gnutls_psk_set_server_credentials_function (
1445 gnutls_psk_server_credentials_t cred,
1446 gnutls_psk_server_credentials_function * func);
1448 typedef int gnutls_psk_client_credentials_function (gnutls_session_t,
1449 char **username,
1450 gnutls_datum_t * key);
1451 void
1452 gnutls_psk_set_client_credentials_function (
1453 gnutls_psk_client_credentials_t cred,
1454 gnutls_psk_client_credentials_function * func);
1456 int gnutls_hex_encode (const gnutls_datum_t * data, char *result,
1457 size_t * result_size);
1458 int gnutls_hex_decode (const gnutls_datum_t * hex_data, void *result,
1459 size_t * result_size);
1461 void
1462 gnutls_psk_set_server_dh_params (gnutls_psk_server_credentials_t res,
1463 gnutls_dh_params_t dh_params);
1465 void
1466 gnutls_psk_set_server_params_function (gnutls_psk_server_credentials_t
1467 res,
1468 gnutls_params_function * func);
1471 * gnutls_x509_subject_alt_name_t:
1472 * @GNUTLS_SAN_DNSNAME: DNS-name SAN.
1473 * @GNUTLS_SAN_RFC822NAME: E-mail address SAN.
1474 * @GNUTLS_SAN_URI: URI SAN.
1475 * @GNUTLS_SAN_IPADDRESS: IP address SAN.
1476 * @GNUTLS_SAN_OTHERNAME: OtherName SAN.
1477 * @GNUTLS_SAN_DN: DN SAN.
1478 * @GNUTLS_SAN_OTHERNAME_XMPP: Virtual SAN, used by
1479 * gnutls_x509_crt_get_subject_alt_othername_oid.
1481 * Enumeration of different subject alternative names types.
1483 typedef enum gnutls_x509_subject_alt_name_t
1485 GNUTLS_SAN_DNSNAME = 1,
1486 GNUTLS_SAN_RFC822NAME = 2,
1487 GNUTLS_SAN_URI = 3,
1488 GNUTLS_SAN_IPADDRESS = 4,
1489 GNUTLS_SAN_OTHERNAME = 5,
1490 GNUTLS_SAN_DN = 6,
1491 /* The following are "virtual" subject alternative name types, in
1492 that they are represented by an otherName value and an OID.
1493 Used by gnutls_x509_crt_get_subject_alt_othername_oid. */
1494 GNUTLS_SAN_OTHERNAME_XMPP = 1000
1495 } gnutls_x509_subject_alt_name_t;
1497 struct gnutls_openpgp_crt_int;
1498 typedef struct gnutls_openpgp_crt_int *gnutls_openpgp_crt_t;
1500 struct gnutls_openpgp_privkey_int;
1501 typedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t;
1503 struct gnutls_pkcs11_privkey_st;
1504 typedef struct gnutls_pkcs11_privkey_st *gnutls_pkcs11_privkey_t;
1507 * gnutls_privkey_type_t:
1508 * @GNUTLS_PRIVKEY_X509: X.509 private key, #gnutls_x509_privkey_t.
1509 * @GNUTLS_PRIVKEY_OPENPGP: OpenPGP private key, #gnutls_openpgp_privkey_t.
1510 * @GNUTLS_PRIVKEY_PKCS11: PKCS11 private key, #gnutls_pkcs11_privkey_t.
1511 * @GNUTLS_PRIVKEY_EXT: External private key, operating using callbacks.
1513 * Enumeration of different private key types.
1515 typedef enum
1517 GNUTLS_PRIVKEY_X509,
1518 GNUTLS_PRIVKEY_OPENPGP,
1519 GNUTLS_PRIVKEY_PKCS11,
1520 GNUTLS_PRIVKEY_EXT
1521 } gnutls_privkey_type_t;
1523 typedef struct gnutls_retr2_st
1525 gnutls_certificate_type_t cert_type;
1526 gnutls_privkey_type_t key_type;
1528 union
1530 gnutls_x509_crt_t *x509;
1531 gnutls_openpgp_crt_t pgp;
1532 } cert;
1533 unsigned int ncerts; /* one for pgp keys */
1535 union
1537 gnutls_x509_privkey_t x509;
1538 gnutls_openpgp_privkey_t pgp;
1539 gnutls_pkcs11_privkey_t pkcs11;
1540 } key;
1542 unsigned int deinit_all; /* if non zero all keys will be deinited */
1543 } gnutls_retr2_st;
1546 /* Functions that allow auth_info_t structures handling
1549 gnutls_credentials_type_t gnutls_auth_get_type (gnutls_session_t session);
1550 gnutls_credentials_type_t
1551 gnutls_auth_server_get_type (gnutls_session_t session);
1552 gnutls_credentials_type_t
1553 gnutls_auth_client_get_type (gnutls_session_t session);
1555 /* DH */
1557 void gnutls_dh_set_prime_bits (gnutls_session_t session, unsigned int bits);
1558 int gnutls_dh_get_secret_bits (gnutls_session_t session);
1559 int gnutls_dh_get_peers_public_bits (gnutls_session_t session);
1560 int gnutls_dh_get_prime_bits (gnutls_session_t session);
1562 int gnutls_dh_get_group (gnutls_session_t session, gnutls_datum_t * raw_gen,
1563 gnutls_datum_t * raw_prime);
1564 int gnutls_dh_get_pubkey (gnutls_session_t session,
1565 gnutls_datum_t * raw_key);
1567 /* X509PKI */
1570 /* These are set on the credentials structure.
1573 /* use gnutls_certificate_set_retrieve_function2() in abstract.h
1574 * instead. It's much more efficient.
1577 typedef int gnutls_certificate_retrieve_function (gnutls_session_t,
1578 const
1579 gnutls_datum_t *
1580 req_ca_rdn,
1581 int nreqs,
1582 const
1583 gnutls_pk_algorithm_t
1584 * pk_algos,
1586 pk_algos_length,
1587 gnutls_retr2_st *);
1590 void gnutls_certificate_set_retrieve_function (
1591 gnutls_certificate_credentials_t cred,
1592 gnutls_certificate_retrieve_function * func);
1594 typedef int gnutls_certificate_verify_function (gnutls_session_t);
1595 void
1596 gnutls_certificate_set_verify_function (gnutls_certificate_credentials_t
1597 cred,
1598 gnutls_certificate_verify_function
1599 * func);
1601 void
1602 gnutls_certificate_server_set_request (gnutls_session_t session,
1603 gnutls_certificate_request_t req);
1605 /* get data from the session
1607 const gnutls_datum_t *gnutls_certificate_get_peers (gnutls_session_t
1608 session,
1609 unsigned int
1610 *list_size);
1611 const gnutls_datum_t *gnutls_certificate_get_ours (gnutls_session_t
1612 session);
1614 time_t gnutls_certificate_activation_time_peers (gnutls_session_t session);
1615 time_t gnutls_certificate_expiration_time_peers (gnutls_session_t session);
1617 int gnutls_certificate_client_get_request_status (gnutls_session_t session);
1618 int gnutls_certificate_verify_peers2 (gnutls_session_t session,
1619 unsigned int *status);
1621 int gnutls_pem_base64_encode (const char *msg, const gnutls_datum_t * data,
1622 char *result, size_t * result_size);
1623 int gnutls_pem_base64_decode (const char *header,
1624 const gnutls_datum_t * b64_data,
1625 unsigned char *result, size_t * result_size);
1627 int gnutls_pem_base64_encode_alloc (const char *msg,
1628 const gnutls_datum_t * data,
1629 gnutls_datum_t * result);
1630 int gnutls_pem_base64_decode_alloc (const char *header,
1631 const gnutls_datum_t * b64_data,
1632 gnutls_datum_t * result);
1634 /* key_usage will be an OR of the following values:
1637 /* when the key is to be used for signing: */
1638 #define GNUTLS_KEY_DIGITAL_SIGNATURE 128
1639 #define GNUTLS_KEY_NON_REPUDIATION 64
1640 /* when the key is to be used for encryption: */
1641 #define GNUTLS_KEY_KEY_ENCIPHERMENT 32
1642 #define GNUTLS_KEY_DATA_ENCIPHERMENT 16
1643 #define GNUTLS_KEY_KEY_AGREEMENT 8
1644 #define GNUTLS_KEY_KEY_CERT_SIGN 4
1645 #define GNUTLS_KEY_CRL_SIGN 2
1646 #define GNUTLS_KEY_ENCIPHER_ONLY 1
1647 #define GNUTLS_KEY_DECIPHER_ONLY 32768
1649 void
1650 gnutls_certificate_set_params_function (gnutls_certificate_credentials_t
1651 res,
1652 gnutls_params_function * func);
1653 void gnutls_anon_set_params_function (gnutls_anon_server_credentials_t res,
1654 gnutls_params_function * func);
1655 void gnutls_psk_set_params_function (gnutls_psk_server_credentials_t res,
1656 gnutls_params_function * func);
1658 int gnutls_hex2bin (const char *hex_data, size_t hex_size,
1659 void *bin_data, size_t * bin_size);
1661 /* Trust on first use (or ssh like) functions */
1663 /* stores the provided information to a database
1665 typedef int (*gnutls_tdb_store_func) (const char* db_name,
1666 const char* host,
1667 const char* service,
1668 time_t expiration,
1669 const gnutls_datum_t* pubkey);
1671 typedef int (*gnutls_tdb_store_commitment_func) (const char* db_name,
1672 const char* host,
1673 const char* service,
1674 time_t expiration,
1675 gnutls_digest_algorithm_t hash_algo,
1676 const gnutls_datum_t* hash);
1678 /* searches for the provided host/service pair that match the
1679 * provided public key in the database. */
1680 typedef int (*gnutls_tdb_verify_func) (const char* db_name,
1681 const char* host,
1682 const char* service,
1683 const gnutls_datum_t *pubkey);
1686 struct gnutls_tdb_int;
1687 typedef struct gnutls_tdb_int *gnutls_tdb_t;
1689 int gnutls_tdb_init (gnutls_tdb_t *tdb);
1690 void gnutls_tdb_set_store_func (gnutls_tdb_t tdb,
1691 gnutls_tdb_store_func store);
1692 void gnutls_tdb_set_store_commitment_func (gnutls_tdb_t tdb,
1693 gnutls_tdb_store_commitment_func cstore);
1694 void gnutls_tdb_set_verify_func (gnutls_tdb_t tdb,
1695 gnutls_tdb_verify_func verify);
1696 void gnutls_tdb_deinit (gnutls_tdb_t tdb);
1698 int gnutls_verify_stored_pubkey (const char* db_name,
1699 gnutls_tdb_t tdb,
1700 const char* host,
1701 const char* service,
1702 gnutls_certificate_type_t cert_type,
1703 const gnutls_datum_t * cert,
1704 unsigned int flags);
1706 int gnutls_store_commitment (const char* db_name,
1707 gnutls_tdb_t tdb,
1708 const char* host,
1709 const char* service,
1710 gnutls_digest_algorithm_t hash_algo,
1711 const gnutls_datum_t* hash,
1712 time_t expiration,
1713 unsigned int flags);
1715 int gnutls_store_pubkey (const char* db_name,
1716 gnutls_tdb_t tdb,
1717 const char* host,
1718 const char* service,
1719 gnutls_certificate_type_t cert_type,
1720 const gnutls_datum_t * cert,
1721 time_t expiration,
1722 unsigned int flags);
1725 /* Gnutls error codes. The mapping to a TLS alert is also shown in
1726 * comments.
1729 #define GNUTLS_E_SUCCESS 0
1730 #define GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3
1731 #define GNUTLS_E_UNKNOWN_CIPHER_TYPE -6
1732 #define GNUTLS_E_LARGE_PACKET -7
1733 #define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8 /* GNUTLS_A_PROTOCOL_VERSION */
1734 #define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9 /* GNUTLS_A_RECORD_OVERFLOW */
1735 #define GNUTLS_E_INVALID_SESSION -10
1736 #define GNUTLS_E_FATAL_ALERT_RECEIVED -12
1737 #define GNUTLS_E_UNEXPECTED_PACKET -15 /* GNUTLS_A_UNEXPECTED_MESSAGE */
1738 #define GNUTLS_E_WARNING_ALERT_RECEIVED -16
1739 #define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18
1740 #define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19
1741 #define GNUTLS_E_UNKNOWN_CIPHER_SUITE -21 /* GNUTLS_A_HANDSHAKE_FAILURE */
1742 #define GNUTLS_E_UNWANTED_ALGORITHM -22
1743 #define GNUTLS_E_MPI_SCAN_FAILED -23
1744 #define GNUTLS_E_DECRYPTION_FAILED -24 /* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */
1745 #define GNUTLS_E_MEMORY_ERROR -25
1746 #define GNUTLS_E_DECOMPRESSION_FAILED -26 /* GNUTLS_A_DECOMPRESSION_FAILURE */
1747 #define GNUTLS_E_COMPRESSION_FAILED -27
1748 #define GNUTLS_E_AGAIN -28
1749 #define GNUTLS_E_EXPIRED -29
1750 #define GNUTLS_E_DB_ERROR -30
1751 #define GNUTLS_E_SRP_PWD_ERROR -31
1752 #define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32
1753 #define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
1754 #define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS
1755 #define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS /* for backwards compatibility only */
1757 #define GNUTLS_E_HASH_FAILED -33
1758 #define GNUTLS_E_BASE64_DECODING_ERROR -34
1760 #define GNUTLS_E_MPI_PRINT_FAILED -35
1761 #define GNUTLS_E_REHANDSHAKE -37 /* GNUTLS_A_NO_RENEGOTIATION */
1762 #define GNUTLS_E_GOT_APPLICATION_DATA -38
1763 #define GNUTLS_E_RECORD_LIMIT_REACHED -39
1764 #define GNUTLS_E_ENCRYPTION_FAILED -40
1766 #define GNUTLS_E_PK_ENCRYPTION_FAILED -44
1767 #define GNUTLS_E_PK_DECRYPTION_FAILED -45
1768 #define GNUTLS_E_PK_SIGN_FAILED -46
1769 #define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47
1770 #define GNUTLS_E_KEY_USAGE_VIOLATION -48
1771 #define GNUTLS_E_NO_CERTIFICATE_FOUND -49 /* GNUTLS_A_BAD_CERTIFICATE */
1772 #define GNUTLS_E_INVALID_REQUEST -50
1773 #define GNUTLS_E_SHORT_MEMORY_BUFFER -51
1774 #define GNUTLS_E_INTERRUPTED -52
1775 #define GNUTLS_E_PUSH_ERROR -53
1776 #define GNUTLS_E_PULL_ERROR -54
1777 #define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
1778 #define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56
1779 #define GNUTLS_E_PKCS1_WRONG_PAD -57
1780 #define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58
1781 #define GNUTLS_E_INTERNAL_ERROR -59
1782 #define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63
1783 #define GNUTLS_E_FILE_ERROR -64
1784 #define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78
1785 #define GNUTLS_E_UNKNOWN_PK_ALGORITHM -80
1786 #define GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS -81
1788 /* returned if you need to generate temporary RSA
1789 * parameters. These are needed for export cipher suites.
1791 #define GNUTLS_E_NO_TEMPORARY_RSA_PARAMS -84
1793 #define GNUTLS_E_NO_COMPRESSION_ALGORITHMS -86
1794 #define GNUTLS_E_NO_CIPHER_SUITES -87
1796 #define GNUTLS_E_OPENPGP_GETKEY_FAILED -88
1797 #define GNUTLS_E_PK_SIG_VERIFY_FAILED -89
1799 #define GNUTLS_E_ILLEGAL_SRP_USERNAME -90
1800 #define GNUTLS_E_SRP_PWD_PARSING_ERROR -91
1801 #define GNUTLS_E_NO_TEMPORARY_DH_PARAMS -93
1803 /* For certificate and key stuff
1805 #define GNUTLS_E_ASN1_ELEMENT_NOT_FOUND -67
1806 #define GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND -68
1807 #define GNUTLS_E_ASN1_DER_ERROR -69
1808 #define GNUTLS_E_ASN1_VALUE_NOT_FOUND -70
1809 #define GNUTLS_E_ASN1_GENERIC_ERROR -71
1810 #define GNUTLS_E_ASN1_VALUE_NOT_VALID -72
1811 #define GNUTLS_E_ASN1_TAG_ERROR -73
1812 #define GNUTLS_E_ASN1_TAG_IMPLICIT -74
1813 #define GNUTLS_E_ASN1_TYPE_ANY_ERROR -75
1814 #define GNUTLS_E_ASN1_SYNTAX_ERROR -76
1815 #define GNUTLS_E_ASN1_DER_OVERFLOW -77
1816 #define GNUTLS_E_OPENPGP_UID_REVOKED -79
1817 #define GNUTLS_E_CERTIFICATE_ERROR -43
1818 #define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR
1819 #define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60
1820 #define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61 /* GNUTLS_A_UNSUPPORTED_CERTIFICATE */
1821 #define GNUTLS_E_X509_UNKNOWN_SAN -62
1822 #define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94
1823 #define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95
1824 #define GNUTLS_E_UNKNOWN_HASH_ALGORITHM -96
1825 #define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97
1826 #define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98
1827 #define GNUTLS_E_INVALID_PASSWORD -99
1828 #define GNUTLS_E_MAC_VERIFY_FAILED -100 /* for PKCS #12 MAC */
1829 #define GNUTLS_E_CONSTRAINT_ERROR -101
1831 #define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102
1832 #define GNUTLS_E_WARNING_IA_FPHF_RECEIVED -103
1834 #define GNUTLS_E_IA_VERIFY_FAILED -104
1835 #define GNUTLS_E_UNKNOWN_ALGORITHM -105
1836 #define GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM -106
1837 #define GNUTLS_E_SAFE_RENEGOTIATION_FAILED -107
1838 #define GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED -108
1839 #define GNUTLS_E_UNKNOWN_SRP_USERNAME -109
1840 #define GNUTLS_E_PREMATURE_TERMINATION -110
1842 #define GNUTLS_E_BASE64_ENCODING_ERROR -201
1843 #define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202 /* obsolete */
1844 #define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202
1845 #define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203
1847 #define GNUTLS_E_OPENPGP_KEYRING_ERROR -204
1848 #define GNUTLS_E_X509_UNSUPPORTED_OID -205
1850 #define GNUTLS_E_RANDOM_FAILED -206
1851 #define GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR -207
1853 #define GNUTLS_E_OPENPGP_SUBKEY_ERROR -208
1855 #define GNUTLS_E_CRYPTO_ALREADY_REGISTERED -209
1857 #define GNUTLS_E_HANDSHAKE_TOO_LARGE -210
1859 #define GNUTLS_E_CRYPTODEV_IOCTL_ERROR -211
1860 #define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212
1862 #define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213
1863 #define GNUTLS_E_BAD_COOKIE -214
1864 #define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215
1865 #define GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL -216
1867 /* PKCS11 related */
1868 #define GNUTLS_E_PKCS11_ERROR -300
1869 #define GNUTLS_E_PKCS11_LOAD_ERROR -301
1870 #define GNUTLS_E_PARSING_ERROR -302
1871 #define GNUTLS_E_PKCS11_PIN_ERROR -303
1873 #define GNUTLS_E_PKCS11_SLOT_ERROR -305
1874 #define GNUTLS_E_LOCKING_ERROR -306
1875 #define GNUTLS_E_PKCS11_ATTRIBUTE_ERROR -307
1876 #define GNUTLS_E_PKCS11_DEVICE_ERROR -308
1877 #define GNUTLS_E_PKCS11_DATA_ERROR -309
1878 #define GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR -310
1879 #define GNUTLS_E_PKCS11_KEY_ERROR -311
1880 #define GNUTLS_E_PKCS11_PIN_EXPIRED -312
1881 #define GNUTLS_E_PKCS11_PIN_LOCKED -313
1882 #define GNUTLS_E_PKCS11_SESSION_ERROR -314
1883 #define GNUTLS_E_PKCS11_SIGNATURE_ERROR -315
1884 #define GNUTLS_E_PKCS11_TOKEN_ERROR -316
1885 #define GNUTLS_E_PKCS11_USER_ERROR -317
1887 #define GNUTLS_E_CRYPTO_INIT_FAILED -318
1888 #define GNUTLS_E_TIMEDOUT -319
1889 #define GNUTLS_E_USER_ERROR -320
1890 #define GNUTLS_E_ECC_NO_SUPPORTED_CURVES -321
1891 #define GNUTLS_E_ECC_UNSUPPORTED_CURVE -322
1892 #define GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE -323
1893 #define GNUTLS_E_CERTIFICATE_LIST_UNSORTED -324
1894 #define GNUTLS_E_ILLEGAL_PARAMETER -325
1895 #define GNUTLS_E_NO_PRIORITIES_WERE_SET -326
1896 #define GNUTLS_E_X509_UNSUPPORTED_EXTENSION -327
1897 #define GNUTLS_E_SESSION_EOF -328
1899 #define GNUTLS_E_UNIMPLEMENTED_FEATURE -1250
1903 #define GNUTLS_E_APPLICATION_ERROR_MAX -65000
1904 #define GNUTLS_E_APPLICATION_ERROR_MIN -65500
1906 #ifdef __cplusplus
1908 #endif
1910 #include <gnutls/compat.h>
1912 #endif /* GNUTLS_H */