use explicit casts to unsigned int in the CURVE_TO_BITS et al
[gnutls:gnutls.git] / lib / includes / gnutls / gnutls.h.in
1 /* -*- c -*-
2  * Copyright (C) 2000-2012 Free Software Foundation, Inc.
3  *
4  * Author: Nikos Mavrogiannopoulos
5  *
6  * This file is part of GnuTLS.
7  *
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 2.1 of
11  * the License, or (at your option) any later version.
12  *
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.
17  *
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/>
20  *
21  */
22
23 /* This file contains the types and prototypes for all the
24  * high level functionality of the gnutls main library.
25  *
26  * If the optional C++ binding was built, it is available in
27  * gnutls/gnutlsxx.h.
28  *
29  * The openssl compatibility layer (which is under the GNU GPL
30  * license) is in gnutls/openssl.h.
31  *
32  * The low level cipher functionality is in gnutls/crypto.h.
33  */
34
35
36 #ifndef GNUTLS_H
37 #define GNUTLS_H
38
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
51 /* *INDENT-OFF* */
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 /* *INDENT-ON* */
56
57 #define GNUTLS_VERSION "@VERSION@"
58
59 #define GNUTLS_VERSION_MAJOR @MAJOR_VERSION@
60 #define GNUTLS_VERSION_MINOR @MINOR_VERSION@
61 #define GNUTLS_VERSION_PATCH @PATCH_VERSION@
62
63 #define GNUTLS_VERSION_NUMBER @NUMBER_VERSION@
64
65 #define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC
66 #define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC
67 #define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC
68 #define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128
69
70 #if !defined(GNUTLS_INTERNAL_BUILD) && defined(_WIN32)
71 # define _SYM_EXPORT __declspec(dllimport)
72 #else
73 # define _SYM_EXPORT
74 #endif
75
76 /**
77  * gnutls_cipher_algorithm_t:
78  * @GNUTLS_CIPHER_UNKNOWN: Unknown algorithm.
79  * @GNUTLS_CIPHER_NULL: NULL algorithm.
80  * @GNUTLS_CIPHER_ARCFOUR_128: ARCFOUR stream cipher with 128-bit keys.
81  * @GNUTLS_CIPHER_3DES_CBC: 3DES in CBC mode.
82  * @GNUTLS_CIPHER_AES_128_CBC: AES in CBC mode with 128-bit keys.
83  * @GNUTLS_CIPHER_AES_192_CBC: AES in CBC mode with 192-bit keys.
84  * @GNUTLS_CIPHER_AES_256_CBC: AES in CBC mode with 256-bit keys.
85  * @GNUTLS_CIPHER_ARCFOUR_40: ARCFOUR stream cipher with 40-bit keys.
86  * @GNUTLS_CIPHER_CAMELLIA_128_CBC: Camellia in CBC mode with 128-bit keys.
87  * @GNUTLS_CIPHER_CAMELLIA_192_CBC: Camellia in CBC mode with 192-bit keys.
88  * @GNUTLS_CIPHER_CAMELLIA_256_CBC: Camellia in CBC mode with 256-bit keys.
89  * @GNUTLS_CIPHER_RC2_40_CBC: RC2 in CBC mode with 40-bit keys.
90  * @GNUTLS_CIPHER_DES_CBC: DES in CBC mode (56-bit keys).
91  * @GNUTLS_CIPHER_AES_128_GCM: AES in GCM mode with 128-bit keys.
92  * @GNUTLS_CIPHER_AES_256_GCM: AES in GCM mode with 256-bit keys.
93  * @GNUTLS_CIPHER_AES_128_CCM: AES in CCM mode with 128-bit keys.
94  * @GNUTLS_CIPHER_AES_256_CCM: AES in CCM mode with 256-bit keys.
95  * @GNUTLS_CIPHER_CAMELLIA_128_GCM: CAMELLIA in GCM mode with 128-bit keys.
96  * @GNUTLS_CIPHER_CAMELLIA_256_GCM: CAMELLIA in GCM mode with 256-bit keys.
97  * @GNUTLS_CIPHER_SALSA20_256: Salsa20 with 256-bit keys.
98  * @GNUTLS_CIPHER_ESTREAM_SALSA20_256: Estream's Salsa20 variant with 256-bit keys.
99  * @GNUTLS_CIPHER_IDEA_PGP_CFB: IDEA in CFB mode.
100  * @GNUTLS_CIPHER_3DES_PGP_CFB: 3DES in CFB mode.
101  * @GNUTLS_CIPHER_CAST5_PGP_CFB: CAST5 in CFB mode.
102  * @GNUTLS_CIPHER_BLOWFISH_PGP_CFB: Blowfish in CFB mode.
103  * @GNUTLS_CIPHER_SAFER_SK128_PGP_CFB: Safer-SK in CFB mode with 128-bit keys.
104  * @GNUTLS_CIPHER_AES128_PGP_CFB: AES in CFB mode with 128-bit keys.
105  * @GNUTLS_CIPHER_AES192_PGP_CFB: AES in CFB mode with 192-bit keys.
106  * @GNUTLS_CIPHER_AES256_PGP_CFB: AES in CFB mode with 256-bit keys.
107  * @GNUTLS_CIPHER_TWOFISH_PGP_CFB: Twofish in CFB mode.
108  *
109  * Enumeration of different symmetric encryption algorithms.
110  */
111 typedef enum gnutls_cipher_algorithm {
112         GNUTLS_CIPHER_UNKNOWN = 0,
113         GNUTLS_CIPHER_NULL = 1,
114         GNUTLS_CIPHER_ARCFOUR_128 = 2,
115         GNUTLS_CIPHER_3DES_CBC = 3,
116         GNUTLS_CIPHER_AES_128_CBC = 4,
117         GNUTLS_CIPHER_AES_256_CBC = 5,
118         GNUTLS_CIPHER_ARCFOUR_40 = 6,
119         GNUTLS_CIPHER_CAMELLIA_128_CBC = 7,
120         GNUTLS_CIPHER_CAMELLIA_256_CBC = 8,
121         GNUTLS_CIPHER_AES_192_CBC = 9,
122         GNUTLS_CIPHER_AES_128_GCM = 10,
123         GNUTLS_CIPHER_AES_256_GCM = 11,
124         GNUTLS_CIPHER_CAMELLIA_192_CBC = 12,
125         GNUTLS_CIPHER_SALSA20_256 = 13,
126         GNUTLS_CIPHER_ESTREAM_SALSA20_256 = 14,
127         GNUTLS_CIPHER_CAMELLIA_128_GCM = 15,
128         GNUTLS_CIPHER_CAMELLIA_256_GCM = 16,
129         GNUTLS_CIPHER_RC2_40_CBC = 17,
130         GNUTLS_CIPHER_DES_CBC = 18,
131         GNUTLS_CIPHER_AES_128_CCM = 19,
132         GNUTLS_CIPHER_AES_256_CCM = 20,
133
134         /* used only for PGP internals. Ignored in TLS/SSL
135          */
136         GNUTLS_CIPHER_IDEA_PGP_CFB = 200,
137         GNUTLS_CIPHER_3DES_PGP_CFB = 201,
138         GNUTLS_CIPHER_CAST5_PGP_CFB = 202,
139         GNUTLS_CIPHER_BLOWFISH_PGP_CFB = 203,
140         GNUTLS_CIPHER_SAFER_SK128_PGP_CFB = 204,
141         GNUTLS_CIPHER_AES128_PGP_CFB = 205,
142         GNUTLS_CIPHER_AES192_PGP_CFB = 206,
143         GNUTLS_CIPHER_AES256_PGP_CFB = 207,
144         GNUTLS_CIPHER_TWOFISH_PGP_CFB = 208
145 } gnutls_cipher_algorithm_t;
146
147 /**
148  * gnutls_kx_algorithm_t:
149  * @GNUTLS_KX_UNKNOWN: Unknown key-exchange algorithm.
150  * @GNUTLS_KX_RSA: RSA key-exchange algorithm.
151  * @GNUTLS_KX_DHE_DSS: DHE-DSS key-exchange algorithm.
152  * @GNUTLS_KX_DHE_RSA: DHE-RSA key-exchange algorithm.
153  * @GNUTLS_KX_ECDHE_RSA: ECDHE-RSA key-exchange algorithm.
154  * @GNUTLS_KX_ECDHE_ECDSA: ECDHE-ECDSA key-exchange algorithm.
155  * @GNUTLS_KX_ANON_DH: Anon-DH key-exchange algorithm.
156  * @GNUTLS_KX_ANON_ECDH: Anon-ECDH key-exchange algorithm.
157  * @GNUTLS_KX_SRP: SRP key-exchange algorithm.
158  * @GNUTLS_KX_RSA_EXPORT: RSA-EXPORT key-exchange algorithm (defunc).
159  * @GNUTLS_KX_SRP_RSA: SRP-RSA key-exchange algorithm.
160  * @GNUTLS_KX_SRP_DSS: SRP-DSS key-exchange algorithm.
161  * @GNUTLS_KX_PSK: PSK key-exchange algorithm.
162  * @GNUTLS_KX_DHE_PSK: DHE-PSK key-exchange algorithm.
163  * @GNUTLS_KX_ECDHE_PSK: ECDHE-PSK key-exchange algorithm.
164  * @GNUTLS_KX_RSA_PSK: RSA-PSK key-exchange algorithm.
165  *
166  * Enumeration of different key exchange algorithms.
167  */
168 typedef enum {
169         GNUTLS_KX_UNKNOWN = 0,
170         GNUTLS_KX_RSA = 1,
171         GNUTLS_KX_DHE_DSS = 2,
172         GNUTLS_KX_DHE_RSA = 3,
173         GNUTLS_KX_ANON_DH = 4,
174         GNUTLS_KX_SRP = 5,
175         GNUTLS_KX_RSA_EXPORT = 6,
176         GNUTLS_KX_SRP_RSA = 7,
177         GNUTLS_KX_SRP_DSS = 8,
178         GNUTLS_KX_PSK = 9,
179         GNUTLS_KX_DHE_PSK = 10,
180         GNUTLS_KX_ANON_ECDH = 11,
181         GNUTLS_KX_ECDHE_RSA = 12,
182         GNUTLS_KX_ECDHE_ECDSA = 13,
183         GNUTLS_KX_ECDHE_PSK = 14,
184         GNUTLS_KX_RSA_PSK = 15
185 } gnutls_kx_algorithm_t;
186
187 /**
188  * gnutls_params_type_t:
189  * @GNUTLS_PARAMS_RSA_EXPORT: Session RSA-EXPORT parameters (defunc).
190  * @GNUTLS_PARAMS_DH: Session Diffie-Hellman parameters.
191  * @GNUTLS_PARAMS_ECDH: Session Elliptic-Curve Diffie-Hellman parameters.
192  *
193  * Enumeration of different TLS session parameter types.
194  */
195 typedef enum {
196         GNUTLS_PARAMS_RSA_EXPORT = 1,
197         GNUTLS_PARAMS_DH = 2,
198         GNUTLS_PARAMS_ECDH = 3
199 } gnutls_params_type_t;
200
201 /**
202  * gnutls_credentials_type_t:
203  * @GNUTLS_CRD_CERTIFICATE: Certificate credential.
204  * @GNUTLS_CRD_ANON: Anonymous credential.
205  * @GNUTLS_CRD_SRP: SRP credential.
206  * @GNUTLS_CRD_PSK: PSK credential.
207  * @GNUTLS_CRD_IA: IA credential.
208  *
209  * Enumeration of different credential types.
210  */
211 typedef enum {
212         GNUTLS_CRD_CERTIFICATE = 1,
213         GNUTLS_CRD_ANON,
214         GNUTLS_CRD_SRP,
215         GNUTLS_CRD_PSK,
216         GNUTLS_CRD_IA
217 } gnutls_credentials_type_t;
218
219 #define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1
220 #define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1
221
222 /**
223  * gnutls_mac_algorithm_t:
224  * @GNUTLS_MAC_UNKNOWN: Unknown MAC algorithm.
225  * @GNUTLS_MAC_NULL: NULL MAC algorithm (empty output).
226  * @GNUTLS_MAC_MD5: HMAC-MD5 algorithm.
227  * @GNUTLS_MAC_SHA1: HMAC-SHA-1 algorithm.
228  * @GNUTLS_MAC_RMD160: HMAC-RMD160 algorithm.
229  * @GNUTLS_MAC_MD2: HMAC-MD2 algorithm.
230  * @GNUTLS_MAC_SHA256: HMAC-SHA-256 algorithm.
231  * @GNUTLS_MAC_SHA384: HMAC-SHA-384 algorithm.
232  * @GNUTLS_MAC_SHA512: HMAC-SHA-512 algorithm.
233  * @GNUTLS_MAC_SHA224: HMAC-SHA-224 algorithm.
234  * @GNUTLS_MAC_AEAD: MAC implicit through AEAD cipher.
235  * @GNUTLS_MAC_UMAC_96: The UMAC-96 MAC algorithm.
236  * @GNUTLS_MAC_UMAC_128: The UMAC-128 MAC algorithm.
237  *
238  * Enumeration of different Message Authentication Code (MAC)
239  * algorithms.
240  */
241 typedef enum {
242         GNUTLS_MAC_UNKNOWN = 0,
243         GNUTLS_MAC_NULL = 1,
244         GNUTLS_MAC_MD5 = 2,
245         GNUTLS_MAC_SHA1 = 3,
246         GNUTLS_MAC_RMD160 = 4,
247         GNUTLS_MAC_MD2 = 5,
248         GNUTLS_MAC_SHA256 = 6,
249         GNUTLS_MAC_SHA384 = 7,
250         GNUTLS_MAC_SHA512 = 8,
251         GNUTLS_MAC_SHA224 = 9,
252         /* If you add anything here, make sure you align with
253            gnutls_digest_algorithm_t. */
254         GNUTLS_MAC_AEAD = 200,  /* indicates that MAC is on the cipher */
255         GNUTLS_MAC_UMAC_96 = 201,
256         GNUTLS_MAC_UMAC_128 = 202
257 } gnutls_mac_algorithm_t;
258
259 /**
260  * gnutls_digest_algorithm_t:
261  * @GNUTLS_DIG_UNKNOWN: Unknown hash algorithm.
262  * @GNUTLS_DIG_NULL: NULL hash algorithm (empty output).
263  * @GNUTLS_DIG_MD5: MD5 algorithm.
264  * @GNUTLS_DIG_SHA1: SHA-1 algorithm.
265  * @GNUTLS_DIG_RMD160: RMD160 algorithm.
266  * @GNUTLS_DIG_MD2: MD2 algorithm.
267  * @GNUTLS_DIG_SHA256: SHA-256 algorithm.
268  * @GNUTLS_DIG_SHA384: SHA-384 algorithm.
269  * @GNUTLS_DIG_SHA512: SHA-512 algorithm.
270  * @GNUTLS_DIG_SHA224: SHA-224 algorithm.
271  *
272  * Enumeration of different digest (hash) algorithms.
273  */
274 typedef enum {
275         GNUTLS_DIG_UNKNOWN = GNUTLS_MAC_UNKNOWN,
276         GNUTLS_DIG_NULL = GNUTLS_MAC_NULL,
277         GNUTLS_DIG_MD5 = GNUTLS_MAC_MD5,
278         GNUTLS_DIG_SHA1 = GNUTLS_MAC_SHA1,
279         GNUTLS_DIG_RMD160 = GNUTLS_MAC_RMD160,
280         GNUTLS_DIG_MD2 = GNUTLS_MAC_MD2,
281         GNUTLS_DIG_SHA256 = GNUTLS_MAC_SHA256,
282         GNUTLS_DIG_SHA384 = GNUTLS_MAC_SHA384,
283         GNUTLS_DIG_SHA512 = GNUTLS_MAC_SHA512,
284         GNUTLS_DIG_SHA224 = GNUTLS_MAC_SHA224
285             /* If you add anything here, make sure you align with
286                gnutls_mac_algorithm_t. */
287 } gnutls_digest_algorithm_t;
288
289   /* exported for other gnutls headers. This is the maximum number of
290    * algorithms (ciphers, kx or macs).
291    */
292 #define GNUTLS_MAX_ALGORITHM_NUM 32
293 #define GNUTLS_MAX_SESSION_ID_SIZE 32
294
295
296 /**
297  * gnutls_compression_method_t:
298  * @GNUTLS_COMP_UNKNOWN: Unknown compression method.
299  * @GNUTLS_COMP_NULL: The NULL compression method (no compression).
300  * @GNUTLS_COMP_DEFLATE: The DEFLATE compression method from zlib.
301  * @GNUTLS_COMP_ZLIB: Same as %GNUTLS_COMP_DEFLATE.
302  *
303  * Enumeration of different TLS compression methods.
304  */
305 typedef enum {
306         GNUTLS_COMP_UNKNOWN = 0,
307         GNUTLS_COMP_NULL = 1,
308         GNUTLS_COMP_DEFLATE = 2,
309         GNUTLS_COMP_ZLIB = GNUTLS_COMP_DEFLATE
310 } gnutls_compression_method_t;
311
312   /*
313    * Flags for gnutls_init()
314    *
315    * @GNUTLS_SERVER: Connection end is a server.
316    * @GNUTLS_CLIENT: Connection end is a client.
317    * @GNUTLS_DATAGRAM: Connection is datagram oriented (DTLS).
318    * @GNUTLS_NONBLOCK: Connection should not block (DTLS).
319    * @GNUTLS_NO_EXTENSIONS: Do not enable any TLS extensions by default.
320    * @GNUTLS_NO_REPLAY_PROTECTION: Disable any replay protection in DTLS.
321    *
322    */
323 #define GNUTLS_SERVER 1
324 #define GNUTLS_CLIENT (1<<1)
325 #define GNUTLS_DATAGRAM (1<<2)
326 #define GNUTLS_NONBLOCK (1<<3)
327 #define GNUTLS_NO_EXTENSIONS (1<<4)
328 #define GNUTLS_NO_REPLAY_PROTECTION (1<<5)
329
330 /**
331  * gnutls_alert_level_t:
332  * @GNUTLS_AL_WARNING: Alert of warning severity.
333  * @GNUTLS_AL_FATAL: Alert of fatal severity.
334  *
335  * Enumeration of different TLS alert severities.
336  */
337 typedef enum {
338         GNUTLS_AL_WARNING = 1,
339         GNUTLS_AL_FATAL
340 } gnutls_alert_level_t;
341
342 /**
343  * gnutls_alert_description_t:
344  * @GNUTLS_A_CLOSE_NOTIFY: Close notify.
345  * @GNUTLS_A_UNEXPECTED_MESSAGE: Unexpected message.
346  * @GNUTLS_A_BAD_RECORD_MAC: Bad record MAC.
347  * @GNUTLS_A_DECRYPTION_FAILED: Decryption failed.
348  * @GNUTLS_A_RECORD_OVERFLOW: Record overflow.
349  * @GNUTLS_A_DECOMPRESSION_FAILURE: Decompression failed.
350  * @GNUTLS_A_HANDSHAKE_FAILURE: Handshake failed.
351  * @GNUTLS_A_SSL3_NO_CERTIFICATE: No certificate.
352  * @GNUTLS_A_BAD_CERTIFICATE: Certificate is bad.
353  * @GNUTLS_A_UNSUPPORTED_CERTIFICATE: Certificate is not supported.
354  * @GNUTLS_A_CERTIFICATE_REVOKED: Certificate was revoked.
355  * @GNUTLS_A_CERTIFICATE_EXPIRED: Certificate is expired.
356  * @GNUTLS_A_CERTIFICATE_UNKNOWN: Unknown certificate.
357  * @GNUTLS_A_ILLEGAL_PARAMETER: Illegal parameter.
358  * @GNUTLS_A_UNKNOWN_CA: CA is unknown.
359  * @GNUTLS_A_ACCESS_DENIED: Access was denied.
360  * @GNUTLS_A_DECODE_ERROR: Decode error.
361  * @GNUTLS_A_DECRYPT_ERROR: Decrypt error.
362  * @GNUTLS_A_EXPORT_RESTRICTION: Export restriction.
363  * @GNUTLS_A_PROTOCOL_VERSION: Error in protocol version.
364  * @GNUTLS_A_INSUFFICIENT_SECURITY: Insufficient security.
365  * @GNUTLS_A_USER_CANCELED: User canceled.
366  * @GNUTLS_A_INTERNAL_ERROR: Internal error.
367  * @GNUTLS_A_NO_RENEGOTIATION: No renegotiation is allowed.
368  * @GNUTLS_A_CERTIFICATE_UNOBTAINABLE: Could not retrieve the
369  *   specified certificate.
370  * @GNUTLS_A_UNSUPPORTED_EXTENSION: An unsupported extension was
371  *   sent.
372  * @GNUTLS_A_UNRECOGNIZED_NAME: The server name sent was not
373  *   recognized.
374  * @GNUTLS_A_UNKNOWN_PSK_IDENTITY: The SRP/PSK username is missing
375  *   or not known.
376  * @GNUTLS_A_NO_APPLICATION_PROTOCOL: The ALPN protocol requested is
377  *   not supported by the peer.
378  *
379  * Enumeration of different TLS alerts.
380  */
381 typedef enum {
382         GNUTLS_A_CLOSE_NOTIFY,
383         GNUTLS_A_UNEXPECTED_MESSAGE = 10,
384         GNUTLS_A_BAD_RECORD_MAC = 20,
385         GNUTLS_A_DECRYPTION_FAILED,
386         GNUTLS_A_RECORD_OVERFLOW,
387         GNUTLS_A_DECOMPRESSION_FAILURE = 30,
388         GNUTLS_A_HANDSHAKE_FAILURE = 40,
389         GNUTLS_A_SSL3_NO_CERTIFICATE = 41,
390         GNUTLS_A_BAD_CERTIFICATE = 42,
391         GNUTLS_A_UNSUPPORTED_CERTIFICATE,
392         GNUTLS_A_CERTIFICATE_REVOKED,
393         GNUTLS_A_CERTIFICATE_EXPIRED,
394         GNUTLS_A_CERTIFICATE_UNKNOWN,
395         GNUTLS_A_ILLEGAL_PARAMETER,
396         GNUTLS_A_UNKNOWN_CA,
397         GNUTLS_A_ACCESS_DENIED,
398         GNUTLS_A_DECODE_ERROR = 50,
399         GNUTLS_A_DECRYPT_ERROR,
400         GNUTLS_A_EXPORT_RESTRICTION = 60,
401         GNUTLS_A_PROTOCOL_VERSION = 70,
402         GNUTLS_A_INSUFFICIENT_SECURITY,
403         GNUTLS_A_INTERNAL_ERROR = 80,
404         GNUTLS_A_USER_CANCELED = 90,
405         GNUTLS_A_NO_RENEGOTIATION = 100,
406         GNUTLS_A_UNSUPPORTED_EXTENSION = 110,
407         GNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111,
408         GNUTLS_A_UNRECOGNIZED_NAME = 112,
409         GNUTLS_A_UNKNOWN_PSK_IDENTITY = 115,
410         GNUTLS_A_NO_APPLICATION_PROTOCOL = 120
411 } gnutls_alert_description_t;
412
413 /**
414  * gnutls_handshake_description_t:
415  * @GNUTLS_HANDSHAKE_HELLO_REQUEST: Hello request.
416  * @GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST: DTLS Hello verify request.
417  * @GNUTLS_HANDSHAKE_CLIENT_HELLO: Client hello.
418  * @GNUTLS_HANDSHAKE_SERVER_HELLO: Server hello.
419  * @GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: New session ticket.
420  * @GNUTLS_HANDSHAKE_CERTIFICATE_PKT: Certificate packet.
421  * @GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: Server key exchange.
422  * @GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: Certificate request.
423  * @GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: Server hello done.
424  * @GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: Certificate verify.
425  * @GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: Client key exchange.
426  * @GNUTLS_HANDSHAKE_FINISHED: Finished.
427  * @GNUTLS_HANDSHAKE_CERTIFICATE_STATUS: Certificate status (OCSP).
428  * @GNUTLS_HANDSHAKE_SUPPLEMENTAL: Supplemental.
429  * @GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC: Change Cipher Spec.
430  * @GNUTLS_HANDSHAKE_CLIENT_HELLO_V2: SSLv2 Client Hello.
431  *
432  * Enumeration of different TLS handshake packets.
433  */
434 typedef enum {
435         GNUTLS_HANDSHAKE_HELLO_REQUEST = 0,
436         GNUTLS_HANDSHAKE_CLIENT_HELLO = 1,
437         GNUTLS_HANDSHAKE_SERVER_HELLO = 2,
438         GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST = 3,
439         GNUTLS_HANDSHAKE_NEW_SESSION_TICKET = 4,
440         GNUTLS_HANDSHAKE_CERTIFICATE_PKT = 11,
441         GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE = 12,
442         GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST = 13,
443         GNUTLS_HANDSHAKE_SERVER_HELLO_DONE = 14,
444         GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY = 15,
445         GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16,
446         GNUTLS_HANDSHAKE_FINISHED = 20,
447         GNUTLS_HANDSHAKE_CERTIFICATE_STATUS = 22,
448         GNUTLS_HANDSHAKE_SUPPLEMENTAL = 23,
449         GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC = 254,
450         GNUTLS_HANDSHAKE_CLIENT_HELLO_V2 = 1024
451 } gnutls_handshake_description_t;
452
453 #define GNUTLS_HANDSHAKE_ANY ((unsigned int)-1)
454
455 const char
456     *gnutls_handshake_description_get_name(gnutls_handshake_description_t
457                                            type);
458
459 /**
460  * gnutls_certificate_status_t:
461  * @GNUTLS_CERT_INVALID: The certificate is not signed by one of the
462  *   known authorities or the signature is invalid (deprecated by the flags 
463  *   %GNUTLS_CERT_SIGNATURE_FAILURE and %GNUTLS_CERT_SIGNER_NOT_FOUND).
464  * @GNUTLS_CERT_SIGNATURE_FAILURE: The signature verification failed.
465  * @GNUTLS_CERT_REVOKED: Certificate is revoked by its authority.  In X.509 this will be
466  *   set only if CRLs are checked.
467  * @GNUTLS_CERT_SIGNER_NOT_FOUND: The certificate's issuer is not known. 
468  *   This is the case if the issuer is not included in the trusted certificate list.
469  * @GNUTLS_CERT_SIGNER_NOT_CA: The certificate's signer was not a CA. This
470  *   may happen if this was a version 1 certificate, which is common with 
471  *   some CAs, or a version 3 certificate without the basic constrains extension.
472  * @GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE: The certificate's signer constraints were
473  *   violated.
474  * @GNUTLS_CERT_INSECURE_ALGORITHM:  The certificate was signed using an insecure
475  *   algorithm such as MD2 or MD5. These algorithms have been broken and
476  *   should not be trusted.
477  * @GNUTLS_CERT_NOT_ACTIVATED: The certificate is not yet activated.
478  * @GNUTLS_CERT_EXPIRED: The certificate has expired.
479  * @GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED: The revocation data are old and have been superseded.
480  * @GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE: The revocation data have a future issue date.
481  * @GNUTLS_CERT_UNEXPECTED_OWNER: The owner is not the expected one.
482  * @GNUTLS_CERT_MISMATCH: The certificate presented isn't the expected one (TOFU)
483  * @GNUTLS_CERT_PURPOSE_MISMATCH: The certificate or an intermediate does not match the intended purpose (extended key usage).
484  *
485  * Enumeration of certificate status codes.  Note that the status
486  * bits may have different meanings in OpenPGP keys and X.509
487  * certificate verification.
488  */
489 typedef enum {
490         GNUTLS_CERT_INVALID = 1 << 1,
491         GNUTLS_CERT_REVOKED = 1 << 5,
492         GNUTLS_CERT_SIGNER_NOT_FOUND = 1 << 6,
493         GNUTLS_CERT_SIGNER_NOT_CA = 1 << 7,
494         GNUTLS_CERT_INSECURE_ALGORITHM = 1 << 8,
495         GNUTLS_CERT_NOT_ACTIVATED = 1 << 9,
496         GNUTLS_CERT_EXPIRED = 1 << 10,
497         GNUTLS_CERT_SIGNATURE_FAILURE = 1 << 11,
498         GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED = 1 << 12,
499         GNUTLS_CERT_UNEXPECTED_OWNER = 1 << 14,
500         GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE = 1 << 15,
501         GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE = 1 << 16,
502         GNUTLS_CERT_MISMATCH = 1 << 17,
503         GNUTLS_CERT_PURPOSE_MISMATCH = 1 << 18
504 } gnutls_certificate_status_t;
505
506 /**
507  * gnutls_certificate_request_t:
508  * @GNUTLS_CERT_IGNORE: Ignore certificate.
509  * @GNUTLS_CERT_REQUEST: Request certificate.
510  * @GNUTLS_CERT_REQUIRE: Require certificate.
511  *
512  * Enumeration of certificate request types.
513  */
514 typedef enum {
515         GNUTLS_CERT_IGNORE = 0,
516         GNUTLS_CERT_REQUEST = 1,
517         GNUTLS_CERT_REQUIRE = 2
518 } gnutls_certificate_request_t;
519
520 /**
521  * gnutls_openpgp_crt_status_t:
522  * @GNUTLS_OPENPGP_CERT: Send entire certificate.
523  * @GNUTLS_OPENPGP_CERT_FINGERPRINT: Send only certificate fingerprint.
524  *
525  * Enumeration of ways to send OpenPGP certificate.
526  */
527 typedef enum {
528         GNUTLS_OPENPGP_CERT = 0,
529         GNUTLS_OPENPGP_CERT_FINGERPRINT = 1
530 } gnutls_openpgp_crt_status_t;
531
532 /**
533  * gnutls_close_request_t:
534  * @GNUTLS_SHUT_RDWR: Disallow further receives/sends.
535  * @GNUTLS_SHUT_WR: Disallow further sends.
536  *
537  * Enumeration of how TLS session should be terminated.  See gnutls_bye().
538  */
539 typedef enum {
540         GNUTLS_SHUT_RDWR = 0,
541         GNUTLS_SHUT_WR = 1
542 } gnutls_close_request_t;
543
544 /**
545  * gnutls_protocol_t:
546  * @GNUTLS_SSL3: SSL version 3.0.
547  * @GNUTLS_TLS1_0: TLS version 1.0.
548  * @GNUTLS_TLS1: Same as %GNUTLS_TLS1_0.
549  * @GNUTLS_TLS1_1: TLS version 1.1.
550  * @GNUTLS_TLS1_2: TLS version 1.2.
551  * @GNUTLS_DTLS1_0: DTLS version 1.0.
552  * @GNUTLS_DTLS1_2: DTLS version 1.2.
553  * @GNUTLS_DTLS0_9: DTLS version 0.9 (Cisco AnyConnect / OpenSSL 0.9.8e).
554  * @GNUTLS_VERSION_MAX: Maps to the highest supported TLS version.
555  * @GNUTLS_VERSION_UNKNOWN: Unknown SSL/TLS version.
556  *
557  * Enumeration of different SSL/TLS protocol versions.
558  */
559 typedef enum {
560         GNUTLS_SSL3 = 1,
561         GNUTLS_TLS1_0 = 2,
562         GNUTLS_TLS1 = GNUTLS_TLS1_0,
563         GNUTLS_TLS1_1 = 3,
564         GNUTLS_TLS1_2 = 4,
565
566         GNUTLS_DTLS0_9 = 200,
567         GNUTLS_DTLS1_0 = 201,   /* 201 */
568         GNUTLS_DTLS1_2 = 202,
569         GNUTLS_DTLS_VERSION_MIN = GNUTLS_DTLS1_0,
570         GNUTLS_DTLS_VERSION_MAX = GNUTLS_DTLS1_2,
571         GNUTLS_TLS_VERSION_MAX = GNUTLS_TLS1_2,
572         GNUTLS_VERSION_UNKNOWN = 0xff   /* change it to 0xffff */
573 } gnutls_protocol_t;
574
575 /**
576  * gnutls_certificate_type_t:
577  * @GNUTLS_CRT_UNKNOWN: Unknown certificate type.
578  * @GNUTLS_CRT_X509: X.509 Certificate.
579  * @GNUTLS_CRT_OPENPGP: OpenPGP certificate.
580  * @GNUTLS_CRT_RAW: Raw public key (SubjectPublicKey)
581  *
582  * Enumeration of different certificate types.
583  */
584 typedef enum {
585         GNUTLS_CRT_UNKNOWN = 0,
586         GNUTLS_CRT_X509 = 1,
587         GNUTLS_CRT_OPENPGP = 2,
588         GNUTLS_CRT_RAW = 3
589 } gnutls_certificate_type_t;
590
591 /**
592  * gnutls_x509_crt_fmt_t:
593  * @GNUTLS_X509_FMT_DER: X.509 certificate in DER format (binary).
594  * @GNUTLS_X509_FMT_PEM: X.509 certificate in PEM format (text).
595  *
596  * Enumeration of different certificate encoding formats.
597  */
598 typedef enum {
599         GNUTLS_X509_FMT_DER = 0,
600         GNUTLS_X509_FMT_PEM = 1
601 } gnutls_x509_crt_fmt_t;
602
603 /**
604  * gnutls_certificate_print_formats_t:
605  * @GNUTLS_CRT_PRINT_FULL: Full information about certificate.
606  * @GNUTLS_CRT_PRINT_FULL_NUMBERS: Full information about certificate and include easy to parse public key parameters.
607  * @GNUTLS_CRT_PRINT_COMPACT: Information about certificate name in one line, plus identification of the public key.
608  * @GNUTLS_CRT_PRINT_ONELINE: Information about certificate in one line.
609  * @GNUTLS_CRT_PRINT_UNSIGNED_FULL: All info for an unsigned certificate.
610  *
611  * Enumeration of different certificate printing variants.
612  */
613 typedef enum gnutls_certificate_print_formats {
614         GNUTLS_CRT_PRINT_FULL = 0,
615         GNUTLS_CRT_PRINT_ONELINE = 1,
616         GNUTLS_CRT_PRINT_UNSIGNED_FULL = 2,
617         GNUTLS_CRT_PRINT_COMPACT = 3,
618         GNUTLS_CRT_PRINT_FULL_NUMBERS = 4
619 } gnutls_certificate_print_formats_t;
620
621 #define GNUTLS_PK_ECC GNUTLS_PK_EC
622 /**
623  * gnutls_pk_algorithm_t:
624  * @GNUTLS_PK_UNKNOWN: Unknown public-key algorithm.
625  * @GNUTLS_PK_RSA: RSA public-key algorithm.
626  * @GNUTLS_PK_DSA: DSA public-key algorithm.
627  * @GNUTLS_PK_DH: Diffie-Hellman algorithm. Used to generate parameters.
628  * @GNUTLS_PK_EC: Elliptic curve algorithm. Used to generate parameters.
629  *
630  * Enumeration of different public-key algorithms.
631  */
632 typedef enum {
633         GNUTLS_PK_UNKNOWN = 0,
634         GNUTLS_PK_RSA = 1,
635         GNUTLS_PK_DSA = 2,
636         GNUTLS_PK_DH = 3,
637         GNUTLS_PK_EC = 4
638 } gnutls_pk_algorithm_t;
639
640 const char *gnutls_pk_algorithm_get_name(gnutls_pk_algorithm_t algorithm);
641
642 /**
643  * gnutls_sign_algorithm_t:
644  * @GNUTLS_SIGN_UNKNOWN: Unknown signature algorithm.
645  * @GNUTLS_SIGN_RSA_SHA1: Digital signature algorithm RSA with SHA-1
646  * @GNUTLS_SIGN_RSA_SHA: Same as %GNUTLS_SIGN_RSA_SHA1.
647  * @GNUTLS_SIGN_DSA_SHA1: Digital signature algorithm DSA with SHA-1
648  * @GNUTLS_SIGN_DSA_SHA224: Digital signature algorithm DSA with SHA-224
649  * @GNUTLS_SIGN_DSA_SHA256: Digital signature algorithm DSA with SHA-256
650  * @GNUTLS_SIGN_DSA_SHA384: Digital signature algorithm DSA with SHA-384
651  * @GNUTLS_SIGN_DSA_SHA512: Digital signature algorithm DSA with SHA-512
652  * @GNUTLS_SIGN_DSA_SHA: Same as %GNUTLS_SIGN_DSA_SHA1.
653  * @GNUTLS_SIGN_RSA_MD5: Digital signature algorithm RSA with MD5.
654  * @GNUTLS_SIGN_RSA_MD2: Digital signature algorithm RSA with MD2.
655  * @GNUTLS_SIGN_RSA_RMD160: Digital signature algorithm RSA with RMD-160.
656  * @GNUTLS_SIGN_RSA_SHA256: Digital signature algorithm RSA with SHA-256.
657  * @GNUTLS_SIGN_RSA_SHA384: Digital signature algorithm RSA with SHA-384.
658  * @GNUTLS_SIGN_RSA_SHA512: Digital signature algorithm RSA with SHA-512.
659  * @GNUTLS_SIGN_RSA_SHA224: Digital signature algorithm RSA with SHA-224.
660  * @GNUTLS_SIGN_ECDSA_SHA1: ECDSA with SHA1.
661  * @GNUTLS_SIGN_ECDSA_SHA256: Digital signature algorithm ECDSA with SHA-256.
662  * @GNUTLS_SIGN_ECDSA_SHA384: Digital signature algorithm ECDSA with SHA-384.
663  * @GNUTLS_SIGN_ECDSA_SHA512: Digital signature algorithm ECDSA with SHA-512.
664  * @GNUTLS_SIGN_ECDSA_SHA224: Digital signature algorithm ECDSA with SHA-224.
665  *
666  * Enumeration of different digital signature algorithms.
667  */
668 typedef enum {
669         GNUTLS_SIGN_UNKNOWN = 0,
670         GNUTLS_SIGN_RSA_SHA1 = 1,
671         GNUTLS_SIGN_RSA_SHA = GNUTLS_SIGN_RSA_SHA1,
672         GNUTLS_SIGN_DSA_SHA1 = 2,
673         GNUTLS_SIGN_DSA_SHA = GNUTLS_SIGN_DSA_SHA1,
674         GNUTLS_SIGN_RSA_MD5 = 3,
675         GNUTLS_SIGN_RSA_MD2 = 4,
676         GNUTLS_SIGN_RSA_RMD160 = 5,
677         GNUTLS_SIGN_RSA_SHA256 = 6,
678         GNUTLS_SIGN_RSA_SHA384 = 7,
679         GNUTLS_SIGN_RSA_SHA512 = 8,
680         GNUTLS_SIGN_RSA_SHA224 = 9,
681         GNUTLS_SIGN_DSA_SHA224 = 10,
682         GNUTLS_SIGN_DSA_SHA256 = 11,
683         GNUTLS_SIGN_ECDSA_SHA1 = 12,
684         GNUTLS_SIGN_ECDSA_SHA224 = 13,
685         GNUTLS_SIGN_ECDSA_SHA256 = 14,
686         GNUTLS_SIGN_ECDSA_SHA384 = 15,
687         GNUTLS_SIGN_ECDSA_SHA512 = 16,
688         GNUTLS_SIGN_DSA_SHA384 = 17,
689         GNUTLS_SIGN_DSA_SHA512 = 18
690 } gnutls_sign_algorithm_t;
691
692 /**
693  * gnutls_ecc_curve_t:
694  * @GNUTLS_ECC_CURVE_INVALID: Cannot be known
695  * @GNUTLS_ECC_CURVE_SECP192R1: the SECP192R1 curve
696  * @GNUTLS_ECC_CURVE_SECP224R1: the SECP224R1 curve
697  * @GNUTLS_ECC_CURVE_SECP256R1: the SECP256R1 curve
698  * @GNUTLS_ECC_CURVE_SECP384R1: the SECP384R1 curve
699  * @GNUTLS_ECC_CURVE_SECP521R1: the SECP521R1 curve
700  *
701  * Enumeration of ECC curves.
702  */
703 typedef enum {
704         GNUTLS_ECC_CURVE_INVALID = 0,
705         GNUTLS_ECC_CURVE_SECP224R1,
706         GNUTLS_ECC_CURVE_SECP256R1,
707         GNUTLS_ECC_CURVE_SECP384R1,
708         GNUTLS_ECC_CURVE_SECP521R1,
709         GNUTLS_ECC_CURVE_SECP192R1
710 } gnutls_ecc_curve_t;
711
712 /* macros to allow specifying a specific curve in gnutls_privkey_generate()
713  * and gnutls_x509_privkey_generate() */
714 #define GNUTLS_CURVE_TO_BITS(curve) (unsigned int)((1<<31)|((unsigned int)(curve)))
715 #define GNUTLS_BITS_TO_CURVE(bits) (((unsigned int)(bits)) & 0x7FFFFFFF)
716 #define GNUTLS_BITS_ARE_CURVE(bits) (((unsigned int)(bits)) & 0x80000000)
717
718 /**
719  * gnutls_sec_param_t:
720  * @GNUTLS_SEC_PARAM_UNKNOWN: Cannot be known
721  * @GNUTLS_SEC_PARAM_INSECURE: Less than 42 bits of security
722  * @GNUTLS_SEC_PARAM_EXPORT: 42 bits of security
723  * @GNUTLS_SEC_PARAM_VERY_WEAK: 64 bits of security
724  * @GNUTLS_SEC_PARAM_WEAK: 72 bits of security
725  * @GNUTLS_SEC_PARAM_LOW: 80 bits of security
726  * @GNUTLS_SEC_PARAM_LEGACY: 96 bits of security
727  * @GNUTLS_SEC_PARAM_MEDIUM: 112 bits of security (used to be %GNUTLS_SEC_PARAM_NORMAL)
728  * @GNUTLS_SEC_PARAM_HIGH: 128 bits of security
729  * @GNUTLS_SEC_PARAM_ULTRA: 192 bits of security
730  *
731  * Enumeration of security parameters for passive attacks.
732  */
733 typedef enum {
734         GNUTLS_SEC_PARAM_UNKNOWN = 0,
735         GNUTLS_SEC_PARAM_INSECURE = 5,
736         GNUTLS_SEC_PARAM_EXPORT = 10,
737         GNUTLS_SEC_PARAM_VERY_WEAK = 15,
738         GNUTLS_SEC_PARAM_WEAK = 20,
739         GNUTLS_SEC_PARAM_LOW = 25,
740         GNUTLS_SEC_PARAM_LEGACY = 30,
741         GNUTLS_SEC_PARAM_MEDIUM = 35,
742         GNUTLS_SEC_PARAM_HIGH = 40,
743         GNUTLS_SEC_PARAM_ULTRA = 45
744 } gnutls_sec_param_t;
745
746 /* old name */
747 #define GNUTLS_SEC_PARAM_NORMAL GNUTLS_SEC_PARAM_MEDIUM
748
749 /**
750  * gnutls_channel_binding_t:
751  * @GNUTLS_CB_TLS_UNIQUE: "tls-unique" (RFC 5929) channel binding
752  *
753  * Enumeration of support channel binding types.
754  */
755 typedef enum {
756         GNUTLS_CB_TLS_UNIQUE
757 } gnutls_channel_binding_t;
758
759
760 /* If you want to change this, then also change the define in
761  * gnutls_int.h, and recompile.
762  */
763 typedef void *gnutls_transport_ptr_t;
764
765 struct gnutls_session_int;
766 typedef struct gnutls_session_int *gnutls_session_t;
767
768 struct gnutls_dh_params_int;
769 typedef struct gnutls_dh_params_int *gnutls_dh_params_t;
770
771   /* XXX ugly. */
772 struct gnutls_x509_privkey_int;
773 typedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t;
774
775 struct gnutls_priority_st;
776 typedef struct gnutls_priority_st *gnutls_priority_t;
777
778 typedef struct {
779         unsigned char *data;
780         unsigned int size;
781 } gnutls_datum_t;
782
783
784 typedef struct gnutls_params_st {
785         gnutls_params_type_t type;
786         union params {
787                 gnutls_dh_params_t dh;
788                 gnutls_rsa_params_t rsa_export;
789         } params;
790         int deinit;
791 } gnutls_params_st;
792
793 typedef int gnutls_params_function(gnutls_session_t, gnutls_params_type_t,
794                                    gnutls_params_st *);
795
796 /* internal functions */
797
798 int gnutls_init(gnutls_session_t * session, unsigned int flags);
799 void gnutls_deinit(gnutls_session_t session);
800 #define _gnutls_deinit(x) gnutls_deinit(x)
801
802 int gnutls_bye(gnutls_session_t session, gnutls_close_request_t how);
803
804 int gnutls_handshake(gnutls_session_t session);
805
806 #define GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT ((unsigned int)-1)
807 void gnutls_handshake_set_timeout(gnutls_session_t session,
808                                   unsigned int ms);
809 int gnutls_rehandshake(gnutls_session_t session);
810
811 gnutls_alert_description_t gnutls_alert_get(gnutls_session_t session);
812 int gnutls_alert_send(gnutls_session_t session,
813                       gnutls_alert_level_t level,
814                       gnutls_alert_description_t desc);
815 int gnutls_alert_send_appropriate(gnutls_session_t session, int err);
816 const char *gnutls_alert_get_name(gnutls_alert_description_t alert);
817 const char *gnutls_alert_get_strname(gnutls_alert_description_t alert);
818
819 gnutls_sec_param_t gnutls_pk_bits_to_sec_param(gnutls_pk_algorithm_t algo,
820                                                unsigned int bits);
821 const char *gnutls_sec_param_get_name(gnutls_sec_param_t param);
822 unsigned int gnutls_sec_param_to_pk_bits(gnutls_pk_algorithm_t algo,
823                                          gnutls_sec_param_t param);
824 unsigned int
825 gnutls_sec_param_to_symmetric_bits(gnutls_sec_param_t param);
826
827 /* Elliptic curves */
828 const char *gnutls_ecc_curve_get_name(gnutls_ecc_curve_t curve);
829 int gnutls_ecc_curve_get_size(gnutls_ecc_curve_t curve);
830 gnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);
831
832 /* get information on the current session */
833 gnutls_cipher_algorithm_t gnutls_cipher_get(gnutls_session_t session);
834 gnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session);
835 gnutls_mac_algorithm_t gnutls_mac_get(gnutls_session_t session);
836 gnutls_compression_method_t
837 gnutls_compression_get(gnutls_session_t session);
838 gnutls_certificate_type_t
839 gnutls_certificate_type_get(gnutls_session_t session);
840
841 int gnutls_sign_algorithm_get(gnutls_session_t session);
842 int gnutls_sign_algorithm_get_client(gnutls_session_t session);
843
844 int gnutls_sign_algorithm_get_requested(gnutls_session_t session,
845                                         size_t indx,
846                                         gnutls_sign_algorithm_t * algo);
847
848 /* the name of the specified algorithms */
849 const char *gnutls_cipher_get_name(gnutls_cipher_algorithm_t algorithm);
850 const char *gnutls_mac_get_name(gnutls_mac_algorithm_t algorithm);
851 const char *gnutls_digest_get_name(gnutls_digest_algorithm_t algorithm);
852 const char *gnutls_compression_get_name(gnutls_compression_method_t
853                                         algorithm);
854 const char *gnutls_kx_get_name(gnutls_kx_algorithm_t algorithm);
855 const char *gnutls_certificate_type_get_name(gnutls_certificate_type_t
856                                              type);
857 const char *gnutls_pk_get_name(gnutls_pk_algorithm_t algorithm);
858 const char *gnutls_sign_get_name(gnutls_sign_algorithm_t algorithm);
859
860 size_t gnutls_cipher_get_key_size(gnutls_cipher_algorithm_t algorithm);
861 size_t gnutls_mac_get_key_size(gnutls_mac_algorithm_t algorithm);
862
863 int gnutls_sign_is_secure(gnutls_sign_algorithm_t algorithm);
864 gnutls_digest_algorithm_t
865 gnutls_sign_get_hash_algorithm(gnutls_sign_algorithm_t sign);
866 gnutls_pk_algorithm_t
867 gnutls_sign_get_pk_algorithm(gnutls_sign_algorithm_t sign);
868 gnutls_sign_algorithm_t
869 gnutls_pk_to_sign(gnutls_pk_algorithm_t pk,
870                   gnutls_digest_algorithm_t hash);
871
872 #define gnutls_sign_algorithm_get_name gnutls_sign_get_name
873
874 gnutls_mac_algorithm_t gnutls_mac_get_id(const char *name);
875 gnutls_digest_algorithm_t gnutls_digest_get_id(const char *name);
876 gnutls_compression_method_t gnutls_compression_get_id(const char *name);
877 gnutls_cipher_algorithm_t gnutls_cipher_get_id(const char *name);
878 gnutls_kx_algorithm_t gnutls_kx_get_id(const char *name);
879 gnutls_protocol_t gnutls_protocol_get_id(const char *name);
880 gnutls_certificate_type_t gnutls_certificate_type_get_id(const char *name);
881 gnutls_pk_algorithm_t gnutls_pk_get_id(const char *name);
882 gnutls_sign_algorithm_t gnutls_sign_get_id(const char *name);
883
884   /* list supported algorithms */
885 const gnutls_ecc_curve_t *gnutls_ecc_curve_list(void);
886 const gnutls_cipher_algorithm_t *gnutls_cipher_list(void);
887 const gnutls_mac_algorithm_t *gnutls_mac_list(void);
888 const gnutls_digest_algorithm_t *gnutls_digest_list(void);
889 const gnutls_compression_method_t *gnutls_compression_list(void);
890 const gnutls_protocol_t *gnutls_protocol_list(void);
891 const gnutls_certificate_type_t *gnutls_certificate_type_list(void);
892 const gnutls_kx_algorithm_t *gnutls_kx_list(void);
893 const gnutls_pk_algorithm_t *gnutls_pk_list(void);
894 const gnutls_sign_algorithm_t *gnutls_sign_list(void);
895 const char *gnutls_cipher_suite_info(size_t idx,
896                                      unsigned char *cs_id,
897                                      gnutls_kx_algorithm_t * kx,
898                                      gnutls_cipher_algorithm_t * cipher,
899                                      gnutls_mac_algorithm_t * mac,
900                                      gnutls_protocol_t * min_version);
901
902   /* error functions */
903 int gnutls_error_is_fatal(int error);
904 int gnutls_error_to_alert(int err, int *level);
905
906 void gnutls_perror(int error);
907 const char *gnutls_strerror(int error);
908 const char *gnutls_strerror_name(int error);
909
910 /* Semi-internal functions.
911  */
912 void gnutls_handshake_set_private_extensions(gnutls_session_t session,
913                                              int allow);
914 int gnutls_handshake_set_random(gnutls_session_t session,
915                                 const gnutls_datum_t * random);
916
917 gnutls_handshake_description_t
918 gnutls_handshake_get_last_out(gnutls_session_t session);
919 gnutls_handshake_description_t
920 gnutls_handshake_get_last_in(gnutls_session_t session);
921
922 /* Record layer functions.
923  */
924 #define GNUTLS_HEARTBEAT_WAIT 1
925 int gnutls_heartbeat_ping(gnutls_session_t session, size_t data_size,
926                           unsigned int max_tries, unsigned int flags);
927 int gnutls_heartbeat_pong(gnutls_session_t session, unsigned int flags);
928
929 void gnutls_record_set_timeout(gnutls_session_t session, unsigned int ms);
930 void gnutls_record_disable_padding(gnutls_session_t session);
931
932 void gnutls_record_cork(gnutls_session_t session);
933 #define GNUTLS_RECORD_WAIT 1
934 int gnutls_record_uncork(gnutls_session_t session, unsigned int flags);
935 size_t gnutls_record_discard_queued(gnutls_session_t session);
936
937 typedef struct {
938         size_t low;
939         size_t high;
940 } gnutls_range_st;
941
942 int gnutls_range_split(gnutls_session_t session,
943                        const gnutls_range_st * orig,
944                        gnutls_range_st * small_range,
945                        gnutls_range_st * rem_range);
946
947 ssize_t gnutls_record_send(gnutls_session_t session, const void *data,
948                            size_t data_size);
949 ssize_t gnutls_record_send_range(gnutls_session_t session,
950                                  const void *data, size_t data_size,
951                                  const gnutls_range_st * range);
952 ssize_t gnutls_record_recv(gnutls_session_t session, void *data,
953                            size_t data_size);
954
955 typedef struct mbuffer_st *gnutls_packet_t;
956
957 ssize_t
958 gnutls_record_recv_packet(gnutls_session_t session, 
959                           gnutls_packet_t *packet);
960
961 void gnutls_packet_get(gnutls_packet_t packet, gnutls_datum_t *data, unsigned char *sequence);
962 void gnutls_packet_deinit(gnutls_packet_t packet);
963
964 #define gnutls_read gnutls_record_recv
965 #define gnutls_write gnutls_record_send
966 ssize_t gnutls_record_recv_seq(gnutls_session_t session, void *data,
967                                size_t data_size, unsigned char *seq);
968
969 size_t gnutls_record_overhead_size(gnutls_session_t session);
970
971 size_t gnutls_est_record_overhead_size(gnutls_protocol_t version,
972                                        gnutls_cipher_algorithm_t cipher,
973                                        gnutls_mac_algorithm_t mac,
974                                        gnutls_compression_method_t comp,
975                                        unsigned int flags);
976
977 void gnutls_session_enable_compatibility_mode(gnutls_session_t session);
978 void gnutls_record_set_max_empty_records(gnutls_session_t session,
979                                          const unsigned int i);
980
981 int gnutls_record_can_use_length_hiding(gnutls_session_t session);
982
983 int gnutls_record_get_direction(gnutls_session_t session);
984
985 size_t gnutls_record_get_max_size(gnutls_session_t session);
986 ssize_t gnutls_record_set_max_size(gnutls_session_t session, size_t size);
987
988 size_t gnutls_record_check_pending(gnutls_session_t session);
989 size_t gnutls_record_check_corked(gnutls_session_t session);
990
991 void gnutls_session_force_valid(gnutls_session_t session);
992
993 int gnutls_prf(gnutls_session_t session,
994                size_t label_size, const char *label,
995                int server_random_first,
996                size_t extra_size, const char *extra,
997                size_t outsize, char *out);
998
999 int gnutls_prf_raw(gnutls_session_t session,
1000                    size_t label_size, const char *label,
1001                    size_t seed_size, const char *seed,
1002                    size_t outsize, char *out);
1003
1004 /**
1005  * gnutls_server_name_type_t:
1006  * @GNUTLS_NAME_DNS: Domain Name System name type.
1007  *
1008  * Enumeration of different server name types.
1009  */
1010 typedef enum {
1011         GNUTLS_NAME_DNS = 1
1012 } gnutls_server_name_type_t;
1013
1014 int gnutls_server_name_set(gnutls_session_t session,
1015                            gnutls_server_name_type_t type,
1016                            const void *name, size_t name_length);
1017
1018 int gnutls_server_name_get(gnutls_session_t session,
1019                            void *data, size_t * data_length,
1020                            unsigned int *type, unsigned int indx);
1021
1022 unsigned int gnutls_heartbeat_get_timeout(gnutls_session_t session);
1023 void gnutls_heartbeat_set_timeouts(gnutls_session_t session,
1024                                    unsigned int retrans_timeout,
1025                                    unsigned int total_timeout);
1026
1027 #define GNUTLS_HB_PEER_ALLOWED_TO_SEND (1)
1028 #define GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND (1<<1)
1029
1030   /* Heartbeat */
1031 void gnutls_heartbeat_enable(gnutls_session_t session, unsigned int type);
1032
1033 #define GNUTLS_HB_LOCAL_ALLOWED_TO_SEND (1<<2)
1034 int gnutls_heartbeat_allowed(gnutls_session_t session, unsigned int type);
1035
1036   /* Safe renegotiation */
1037 int gnutls_safe_renegotiation_status(gnutls_session_t session);
1038 unsigned gnutls_session_ext_master_secret_status(gnutls_session_t session);
1039 unsigned gnutls_session_etm_status(gnutls_session_t session);
1040
1041 /**
1042  * gnutls_supplemental_data_format_type_t:
1043  * @GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA: Supplemental user mapping data.
1044  *
1045  * Enumeration of different supplemental data types (RFC 4680).
1046  */
1047 typedef enum {
1048         GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA = 0
1049 } gnutls_supplemental_data_format_type_t;
1050
1051 const char
1052 *gnutls_supplemental_get_name(gnutls_supplemental_data_format_type_t type);
1053
1054   /* SessionTicket, RFC 5077. */
1055 int gnutls_session_ticket_key_generate(gnutls_datum_t * key);
1056 int gnutls_session_ticket_enable_client(gnutls_session_t session);
1057 int gnutls_session_ticket_enable_server(gnutls_session_t session,
1058                                         const gnutls_datum_t * key);
1059
1060   /* SRTP, RFC 5764 */
1061
1062 /**
1063  * gnutls_srtp_profile_t:
1064  * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80: 128 bit AES with a 80 bit HMAC-SHA1
1065  * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32: 128 bit AES with a 32 bit HMAC-SHA1
1066  * @GNUTLS_SRTP_NULL_HMAC_SHA1_80: NULL cipher with a 80 bit HMAC-SHA1
1067  * @GNUTLS_SRTP_NULL_HMAC_SHA1_32: NULL cipher with a 32 bit HMAC-SHA1
1068  *
1069  * Enumeration of different SRTP protection profiles.
1070  */
1071 typedef enum {
1072         GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80 = 0x0001,
1073         GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32 = 0x0002,
1074         GNUTLS_SRTP_NULL_HMAC_SHA1_80 = 0x0005,
1075         GNUTLS_SRTP_NULL_HMAC_SHA1_32 = 0x0006
1076 } gnutls_srtp_profile_t;
1077
1078 int gnutls_srtp_set_profile(gnutls_session_t session,
1079                             gnutls_srtp_profile_t profile);
1080 int gnutls_srtp_set_profile_direct(gnutls_session_t session,
1081                                    const char *profiles,
1082                                    const char **err_pos);
1083 int gnutls_srtp_get_selected_profile(gnutls_session_t session,
1084                                      gnutls_srtp_profile_t * profile);
1085
1086 const char *gnutls_srtp_get_profile_name(gnutls_srtp_profile_t profile);
1087 int gnutls_srtp_get_profile_id(const char *name,
1088                                gnutls_srtp_profile_t * profile);
1089 int gnutls_srtp_get_keys(gnutls_session_t session,
1090                          void *key_material,
1091                          unsigned int key_material_size,
1092                          gnutls_datum_t * client_key,
1093                          gnutls_datum_t * client_salt,
1094                          gnutls_datum_t * server_key,
1095                          gnutls_datum_t * server_salt);
1096
1097 int gnutls_srtp_set_mki(gnutls_session_t session,
1098                         const gnutls_datum_t * mki);
1099 int gnutls_srtp_get_mki(gnutls_session_t session, gnutls_datum_t * mki);
1100
1101 /* ALPN TLS extension */
1102 #define GNUTLS_ALPN_MAND 1
1103 int gnutls_alpn_get_selected_protocol(gnutls_session_t session,
1104                                       gnutls_datum_t * protocol);
1105 int gnutls_alpn_set_protocols(gnutls_session_t session,
1106                               const gnutls_datum_t * protocols,
1107                               unsigned protocols_size, unsigned flags);
1108
1109 int gnutls_key_generate(gnutls_datum_t * key, unsigned int key_size);
1110
1111 /* if you just want some defaults, use the following.
1112  */
1113
1114 int gnutls_priority_init(gnutls_priority_t * priority_cache,
1115                          const char *priorities, const char **err_pos);
1116 void gnutls_priority_deinit(gnutls_priority_t priority_cache);
1117 int gnutls_priority_get_cipher_suite_index(gnutls_priority_t pcache,
1118                                            unsigned int idx,
1119                                            unsigned int *sidx);
1120
1121 #define GNUTLS_PRIORITY_LIST_INIT_KEYWORDS 1
1122 #define GNUTLS_PRIORITY_LIST_SPECIAL 2
1123 const char *
1124 gnutls_priority_string_list(unsigned iter, unsigned int flags);
1125
1126 int gnutls_priority_set(gnutls_session_t session,
1127                         gnutls_priority_t priority);
1128 int gnutls_priority_set_direct(gnutls_session_t session,
1129                                const char *priorities,
1130                                const char **err_pos);
1131
1132 int gnutls_priority_certificate_type_list(gnutls_priority_t pcache,
1133                                           const unsigned int **list);
1134 int gnutls_priority_sign_list(gnutls_priority_t pcache,
1135                               const unsigned int **list);
1136 int gnutls_priority_protocol_list(gnutls_priority_t pcache,
1137                                   const unsigned int **list);
1138 int gnutls_priority_compression_list(gnutls_priority_t pcache,
1139                                      const unsigned int **list);
1140 int gnutls_priority_ecc_curve_list(gnutls_priority_t pcache,
1141                                    const unsigned int **list);
1142
1143 int gnutls_priority_kx_list(gnutls_priority_t pcache,
1144                             const unsigned int **list);
1145 int gnutls_priority_cipher_list(gnutls_priority_t pcache,
1146                                 const unsigned int **list);
1147 int gnutls_priority_mac_list(gnutls_priority_t pcache,
1148                              const unsigned int **list);
1149
1150   /* for compatibility
1151    */
1152 int gnutls_set_default_priority(gnutls_session_t session);
1153
1154 /* Returns the name of a cipher suite */
1155 const char *gnutls_cipher_suite_get_name(gnutls_kx_algorithm_t
1156                                          kx_algorithm,
1157                                          gnutls_cipher_algorithm_t
1158                                          cipher_algorithm,
1159                                          gnutls_mac_algorithm_t
1160                                          mac_algorithm);
1161
1162 /* get the currently used protocol version */
1163 gnutls_protocol_t gnutls_protocol_get_version(gnutls_session_t session);
1164
1165 const char *gnutls_protocol_get_name(gnutls_protocol_t version);
1166
1167
1168 /* get/set session 
1169  */
1170 int gnutls_session_set_data(gnutls_session_t session,
1171                             const void *session_data,
1172                             size_t session_data_size);
1173 int gnutls_session_get_data(gnutls_session_t session, void *session_data,
1174                             size_t * session_data_size);
1175 int gnutls_session_get_data2(gnutls_session_t session,
1176                              gnutls_datum_t * data);
1177 void gnutls_session_get_random(gnutls_session_t session,
1178                                gnutls_datum_t * client,
1179                                gnutls_datum_t * server);
1180 char *gnutls_session_get_desc(gnutls_session_t session);
1181
1182 int gnutls_session_set_premaster(gnutls_session_t session,
1183                                  unsigned int entity,
1184                                  gnutls_protocol_t version,
1185                                  gnutls_kx_algorithm_t kx,
1186                                  gnutls_cipher_algorithm_t cipher,
1187                                  gnutls_mac_algorithm_t mac,
1188                                  gnutls_compression_method_t comp,
1189                                  const gnutls_datum_t * master,
1190                                  const gnutls_datum_t * session_id);
1191
1192 /* returns the session ID */
1193 #define GNUTLS_MAX_SESSION_ID 32
1194 int gnutls_session_get_id(gnutls_session_t session, void *session_id,
1195                           size_t * session_id_size);
1196 int gnutls_session_get_id2(gnutls_session_t session,
1197                            gnutls_datum_t * session_id);
1198
1199 int gnutls_session_set_id(gnutls_session_t session,
1200                           const gnutls_datum_t * sid);
1201
1202 int gnutls_session_channel_binding(gnutls_session_t session,
1203                                    gnutls_channel_binding_t cbtype,
1204                                    gnutls_datum_t * cb);
1205
1206 /* checks if this session is a resumed one 
1207  */
1208 int gnutls_session_is_resumed(gnutls_session_t session);
1209 int gnutls_session_resumption_requested(gnutls_session_t session);
1210
1211 typedef int (*gnutls_db_store_func) (void *, gnutls_datum_t key,
1212                                      gnutls_datum_t data);
1213 typedef int (*gnutls_db_remove_func) (void *, gnutls_datum_t key);
1214 typedef gnutls_datum_t(*gnutls_db_retr_func) (void *, gnutls_datum_t key);
1215
1216 void gnutls_db_set_cache_expiration(gnutls_session_t session, int seconds);
1217 unsigned gnutls_db_get_default_cache_expiration(void);
1218
1219 void gnutls_db_remove_session(gnutls_session_t session);
1220 void gnutls_db_set_retrieve_function(gnutls_session_t session,
1221                                      gnutls_db_retr_func retr_func);
1222 void gnutls_db_set_remove_function(gnutls_session_t session,
1223                                    gnutls_db_remove_func rem_func);
1224 void gnutls_db_set_store_function(gnutls_session_t session,
1225                                   gnutls_db_store_func store_func);
1226 void gnutls_db_set_ptr(gnutls_session_t session, void *ptr);
1227 void *gnutls_db_get_ptr(gnutls_session_t session);
1228 int gnutls_db_check_entry(gnutls_session_t session,
1229                           gnutls_datum_t session_entry);
1230 time_t gnutls_db_check_entry_time(gnutls_datum_t * entry);
1231
1232   /**
1233    * gnutls_handshake_hook_func:
1234    * @session: the current session
1235    * @htype: the type of the handshake message (%gnutls_handshake_description_t)
1236    * @post: non zero if this is a post-process/generation call and zero otherwise
1237    * @incoming: non zero if this is an incoming message and zero if this is an outgoing message
1238    *
1239    * Function prototype for handshake hooks. It is set using
1240    * gnutls_handshake_set_hook_function().
1241    *
1242    * Returns: Non zero on error.
1243    */
1244 #define GNUTLS_HOOK_POST (1)
1245 #define GNUTLS_HOOK_PRE (0)
1246 #define GNUTLS_HOOK_BOTH (-1)
1247
1248 typedef int (*gnutls_handshake_hook_func) (gnutls_session_t,
1249                                            unsigned int htype,
1250                                            unsigned post,
1251                                            unsigned int incoming);
1252 void gnutls_handshake_set_hook_function(gnutls_session_t session,
1253                                         unsigned int htype, int post,
1254                                         gnutls_handshake_hook_func func);
1255
1256 typedef int (*gnutls_handshake_post_client_hello_func) (gnutls_session_t);
1257 void
1258 gnutls_handshake_set_post_client_hello_function(gnutls_session_t session,
1259                                                 gnutls_handshake_post_client_hello_func
1260                                                 func);
1261
1262 void gnutls_handshake_set_max_packet_length(gnutls_session_t session,
1263                                             size_t max);
1264
1265 /* returns libgnutls version (call it with a NULL argument)
1266  */
1267 const char *gnutls_check_version(const char *req_version);
1268
1269 /* Functions for setting/clearing credentials
1270  */
1271 void gnutls_credentials_clear(gnutls_session_t session);
1272
1273 /* cred is a structure defined by the kx algorithm
1274  */
1275 int gnutls_credentials_set(gnutls_session_t session,
1276                            gnutls_credentials_type_t type, void *cred);
1277 int gnutls_credentials_get(gnutls_session_t session,
1278                            gnutls_credentials_type_t type, void **cred);
1279 #define gnutls_cred_set gnutls_credentials_set
1280
1281 /* x.509 types */
1282
1283 struct gnutls_pubkey_st;
1284 typedef struct gnutls_pubkey_st *gnutls_pubkey_t;
1285
1286 struct gnutls_privkey_st;
1287 typedef struct gnutls_privkey_st *gnutls_privkey_t;
1288
1289 struct gnutls_x509_privkey_int;
1290 typedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;
1291
1292 struct gnutls_x509_crl_int;
1293 typedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;
1294
1295 struct gnutls_x509_crt_int;
1296 typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;
1297
1298 struct gnutls_x509_crq_int;
1299 typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;
1300
1301 struct gnutls_openpgp_keyring_int;
1302 typedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;
1303
1304
1305 /* Credential structures - used in gnutls_credentials_set(); */
1306
1307 struct gnutls_certificate_credentials_st;
1308 typedef struct gnutls_certificate_credentials_st
1309 *gnutls_certificate_credentials_t;
1310 typedef gnutls_certificate_credentials_t
1311     gnutls_certificate_server_credentials;
1312 typedef gnutls_certificate_credentials_t
1313     gnutls_certificate_client_credentials;
1314
1315 typedef struct gnutls_anon_server_credentials_st
1316 *gnutls_anon_server_credentials_t;
1317 typedef struct gnutls_anon_client_credentials_st
1318 *gnutls_anon_client_credentials_t;
1319
1320 void gnutls_anon_free_server_credentials(gnutls_anon_server_credentials_t
1321                                          sc);
1322 int
1323 gnutls_anon_allocate_server_credentials(gnutls_anon_server_credentials_t
1324                                         * sc);
1325
1326 void gnutls_anon_set_server_dh_params(gnutls_anon_server_credentials_t res,
1327                                       gnutls_dh_params_t dh_params);
1328
1329 void
1330 gnutls_anon_set_server_params_function(gnutls_anon_server_credentials_t
1331                                        res, gnutls_params_function * func);
1332
1333 void
1334 gnutls_anon_free_client_credentials(gnutls_anon_client_credentials_t sc);
1335 int
1336 gnutls_anon_allocate_client_credentials(gnutls_anon_client_credentials_t
1337                                         * sc);
1338
1339 /* CERTFILE is an x509 certificate in PEM form.
1340  * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).
1341  */
1342 void
1343 gnutls_certificate_free_credentials(gnutls_certificate_credentials_t sc);
1344 int
1345 gnutls_certificate_allocate_credentials(gnutls_certificate_credentials_t
1346                                         * res);
1347
1348 int
1349 gnutls_certificate_get_issuer(gnutls_certificate_credentials_t sc,
1350                               gnutls_x509_crt_t cert,
1351                               gnutls_x509_crt_t * issuer,
1352                               unsigned int flags);
1353
1354 int gnutls_certificate_get_crt_raw(gnutls_certificate_credentials_t sc,
1355                                    unsigned idx1, unsigned idx2,
1356                                    gnutls_datum_t * cert);
1357
1358 int
1359 gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res,
1360                                 unsigned index,
1361                                 gnutls_x509_crt_t **crt_list,
1362                                 unsigned *crt_list_size);
1363
1364 int
1365 gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t res,
1366                                 unsigned index,
1367                                 gnutls_x509_privkey_t *key);
1368
1369 void gnutls_certificate_free_keys(gnutls_certificate_credentials_t sc);
1370 void gnutls_certificate_free_cas(gnutls_certificate_credentials_t sc);
1371 void gnutls_certificate_free_ca_names(gnutls_certificate_credentials_t sc);
1372 void gnutls_certificate_free_crls(gnutls_certificate_credentials_t sc);
1373
1374 void gnutls_certificate_set_dh_params(gnutls_certificate_credentials_t res,
1375                                       gnutls_dh_params_t dh_params);
1376 void gnutls_certificate_set_verify_flags(gnutls_certificate_credentials_t
1377                                          res, unsigned int flags);
1378 unsigned int
1379 gnutls_certificate_get_verify_flags(gnutls_certificate_credentials_t res);
1380
1381 void gnutls_certificate_set_verify_limits(gnutls_certificate_credentials_t
1382                                           res, unsigned int max_bits,
1383                                           unsigned int max_depth);
1384
1385 unsigned int
1386 gnutls_certificate_get_verify_flags(gnutls_certificate_credentials_t);
1387
1388 int
1389 gnutls_certificate_set_x509_system_trust(gnutls_certificate_credentials_t
1390                                          cred);
1391
1392 int
1393 gnutls_certificate_set_x509_trust_file(gnutls_certificate_credentials_t
1394                                        cred, const char *cafile,
1395                                        gnutls_x509_crt_fmt_t type);
1396 int
1397 gnutls_certificate_set_x509_trust_dir(gnutls_certificate_credentials_t cred,
1398                                       const char *ca_dir,
1399                                       gnutls_x509_crt_fmt_t type);
1400
1401 int gnutls_certificate_set_x509_trust_mem(gnutls_certificate_credentials_t
1402                                           res, const gnutls_datum_t * ca,
1403                                           gnutls_x509_crt_fmt_t type);
1404
1405 int
1406 gnutls_certificate_set_x509_crl_file(gnutls_certificate_credentials_t
1407                                      res, const char *crlfile,
1408                                      gnutls_x509_crt_fmt_t type);
1409 int gnutls_certificate_set_x509_crl_mem(gnutls_certificate_credentials_t
1410                                         res, const gnutls_datum_t * CRL,
1411                                         gnutls_x509_crt_fmt_t type);
1412
1413 int
1414 gnutls_certificate_set_x509_key_file(gnutls_certificate_credentials_t
1415                                      res, const char *certfile,
1416                                      const char *keyfile,
1417                                      gnutls_x509_crt_fmt_t type);
1418
1419 int
1420 gnutls_certificate_set_x509_key_file2(gnutls_certificate_credentials_t
1421                                       res, const char *certfile,
1422                                       const char *keyfile,
1423                                       gnutls_x509_crt_fmt_t type,
1424                                       const char *pass,
1425                                       unsigned int flags);
1426
1427 int gnutls_certificate_set_x509_key_mem(gnutls_certificate_credentials_t
1428                                         res, const gnutls_datum_t * cert,
1429                                         const gnutls_datum_t * key,
1430                                         gnutls_x509_crt_fmt_t type);
1431
1432 int gnutls_certificate_set_x509_key_mem2(gnutls_certificate_credentials_t
1433                                          res, const gnutls_datum_t * cert,
1434                                          const gnutls_datum_t * key,
1435                                          gnutls_x509_crt_fmt_t type,
1436                                          const char *pass,
1437                                          unsigned int flags);
1438
1439 void gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session,
1440                                                int status);
1441
1442 int
1443 gnutls_certificate_set_x509_simple_pkcs12_file
1444 (gnutls_certificate_credentials_t res, const char *pkcs12file,
1445  gnutls_x509_crt_fmt_t type, const char *password);
1446 int
1447 gnutls_certificate_set_x509_simple_pkcs12_mem
1448 (gnutls_certificate_credentials_t res, const gnutls_datum_t * p12blob,
1449  gnutls_x509_crt_fmt_t type, const char *password);
1450
1451 /* New functions to allow setting already parsed X.509 stuff.
1452  */
1453
1454 int gnutls_certificate_set_x509_key(gnutls_certificate_credentials_t res,
1455                                     gnutls_x509_crt_t * cert_list,
1456                                     int cert_list_size,
1457                                     gnutls_x509_privkey_t key);
1458 int gnutls_certificate_set_x509_trust(gnutls_certificate_credentials_t res,
1459                                       gnutls_x509_crt_t * ca_list,
1460                                       int ca_list_size);
1461 int gnutls_certificate_set_x509_crl(gnutls_certificate_credentials_t res,
1462                                     gnutls_x509_crl_t * crl_list,
1463                                     int crl_list_size);
1464
1465 int gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t res,
1466                                     unsigned index,
1467                                     gnutls_x509_privkey_t *key);
1468 int gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res,
1469                                     unsigned index,
1470                                     gnutls_x509_crt_t **crt_list,
1471                                     unsigned *crt_list_size);
1472
1473   /* OCSP status request extension, RFC 6066 */
1474 typedef int (*gnutls_status_request_ocsp_func)
1475  (gnutls_session_t session, void *ptr, gnutls_datum_t * ocsp_response);
1476
1477 void
1478 gnutls_certificate_set_ocsp_status_request_function
1479 (gnutls_certificate_credentials_t res,
1480 gnutls_status_request_ocsp_func ocsp_func, void *ptr);
1481
1482 int
1483 gnutls_certificate_set_ocsp_status_request_file
1484 (gnutls_certificate_credentials_t res, const char *response_file,
1485  unsigned int flags);
1486
1487 int gnutls_ocsp_status_request_enable_client(gnutls_session_t session,
1488                                              gnutls_datum_t * responder_id,
1489                                              size_t responder_id_size,
1490                                              gnutls_datum_t *
1491                                              request_extensions);
1492
1493 int gnutls_ocsp_status_request_get(gnutls_session_t session,
1494                                    gnutls_datum_t * response);
1495
1496 #define GNUTLS_OCSP_SR_IS_AVAIL 1
1497 int gnutls_ocsp_status_request_is_checked(gnutls_session_t session,
1498                                           unsigned int flags);
1499
1500 /* global state functions
1501  */
1502 int gnutls_global_init(void);
1503 void gnutls_global_deinit(void);
1504
1505   /**
1506    * gnutls_time_func:
1507    * @t: where to store time.
1508    *
1509    * Function prototype for time()-like function.  Set with
1510    * gnutls_global_set_time_function().
1511    *
1512    * Returns: Number of seconds since the epoch, or (time_t)-1 on errors.
1513    */
1514 typedef time_t(*gnutls_time_func) (time_t * t);
1515
1516 typedef int (*mutex_init_func) (void **mutex);
1517 typedef int (*mutex_lock_func) (void **mutex);
1518 typedef int (*mutex_unlock_func) (void **mutex);
1519 typedef int (*mutex_deinit_func) (void **mutex);
1520
1521 void gnutls_global_set_mutex(mutex_init_func init,
1522                              mutex_deinit_func deinit,
1523                              mutex_lock_func lock,
1524                              mutex_unlock_func unlock);
1525
1526 typedef void *(*gnutls_alloc_function) (size_t);
1527 typedef void *(*gnutls_calloc_function) (size_t, size_t);
1528 typedef int (*gnutls_is_secure_function) (const void *);
1529 typedef void (*gnutls_free_function) (void *);
1530 typedef void *(*gnutls_realloc_function) (void *, size_t);
1531
1532 void gnutls_global_set_time_function(gnutls_time_func time_func);
1533
1534 /* For use in callbacks */
1535 extern _SYM_EXPORT gnutls_alloc_function gnutls_malloc;
1536 extern _SYM_EXPORT gnutls_realloc_function gnutls_realloc;
1537 extern _SYM_EXPORT gnutls_calloc_function gnutls_calloc;
1538 extern _SYM_EXPORT gnutls_free_function gnutls_free;
1539
1540 extern _SYM_EXPORT char *(*gnutls_strdup) (const char *);
1541
1542 /* a variant of memset that doesn't get optimized out */
1543 void gnutls_memset(void *data, int c, size_t size);
1544
1545 /* constant time memcmp */
1546 int gnutls_memcmp(const void *s1, const void *s2, size_t n);
1547
1548 typedef void (*gnutls_log_func) (int, const char *);
1549 typedef void (*gnutls_audit_log_func) (gnutls_session_t, const char *);
1550 void gnutls_global_set_log_function(gnutls_log_func log_func);
1551 void gnutls_global_set_audit_log_function(gnutls_audit_log_func log_func);
1552 void gnutls_global_set_log_level(int level);
1553
1554 /* Diffie-Hellman parameter handling.
1555  */
1556 int gnutls_dh_params_init(gnutls_dh_params_t * dh_params);
1557 void gnutls_dh_params_deinit(gnutls_dh_params_t dh_params);
1558 int gnutls_dh_params_import_raw(gnutls_dh_params_t dh_params,
1559                                 const gnutls_datum_t * prime,
1560                                 const gnutls_datum_t * generator);
1561 int gnutls_dh_params_import_raw2(gnutls_dh_params_t dh_params,
1562                                  const gnutls_datum_t * prime,
1563                                  const gnutls_datum_t * generator,
1564                                  unsigned key_bits);
1565 int gnutls_dh_params_import_pkcs3(gnutls_dh_params_t params,
1566                                   const gnutls_datum_t * pkcs3_params,
1567                                   gnutls_x509_crt_fmt_t format);
1568 int gnutls_dh_params_generate2(gnutls_dh_params_t params,
1569                                unsigned int bits);
1570 int gnutls_dh_params_export_pkcs3(gnutls_dh_params_t params,
1571                                   gnutls_x509_crt_fmt_t format,
1572                                   unsigned char *params_data,
1573                                   size_t * params_data_size);
1574 int gnutls_dh_params_export2_pkcs3(gnutls_dh_params_t params,
1575                                    gnutls_x509_crt_fmt_t format,
1576                                    gnutls_datum_t * out);
1577 int gnutls_dh_params_export_raw(gnutls_dh_params_t params,
1578                                 gnutls_datum_t * prime,
1579                                 gnutls_datum_t * generator,
1580                                 unsigned int *bits);
1581 int gnutls_dh_params_cpy(gnutls_dh_params_t dst, gnutls_dh_params_t src);
1582
1583
1584
1585 /* Session stuff
1586  */
1587 typedef struct {
1588         void *iov_base;         /* Starting address */
1589         size_t iov_len;         /* Number of bytes to transfer */
1590 } giovec_t;
1591
1592 typedef ssize_t(*gnutls_pull_func) (gnutls_transport_ptr_t, void *,
1593                                     size_t);
1594 typedef ssize_t(*gnutls_push_func) (gnutls_transport_ptr_t, const void *,
1595                                     size_t);
1596
1597 int gnutls_system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms);
1598 typedef int (*gnutls_pull_timeout_func) (gnutls_transport_ptr_t,
1599                                          unsigned int ms);
1600
1601 typedef ssize_t(*gnutls_vec_push_func) (gnutls_transport_ptr_t,
1602                                         const giovec_t * iov, int iovcnt);
1603
1604 typedef int (*gnutls_errno_func) (gnutls_transport_ptr_t);
1605
1606 #if 0
1607  /* This will be defined as macro. */
1608   void gnutls_transport_set_int (gnutls_session_t session, int r);
1609 #endif
1610
1611 void gnutls_transport_set_int2(gnutls_session_t session, int r, int s);
1612 #define gnutls_transport_set_int(s, i) gnutls_transport_set_int2(s, i, i)
1613
1614 void gnutls_transport_get_int2(gnutls_session_t session, int *r, int *s);
1615 int gnutls_transport_get_int(gnutls_session_t session);
1616
1617 void gnutls_transport_set_ptr(gnutls_session_t session,
1618                               gnutls_transport_ptr_t ptr);
1619 void gnutls_transport_set_ptr2(gnutls_session_t session,
1620                                gnutls_transport_ptr_t recv_ptr,
1621                                gnutls_transport_ptr_t send_ptr);
1622
1623 gnutls_transport_ptr_t gnutls_transport_get_ptr(gnutls_session_t session);
1624 void gnutls_transport_get_ptr2(gnutls_session_t session,
1625                                gnutls_transport_ptr_t * recv_ptr,
1626                                gnutls_transport_ptr_t * send_ptr);
1627
1628 void gnutls_transport_set_vec_push_function(gnutls_session_t session,
1629                                             gnutls_vec_push_func vec_func);
1630 void gnutls_transport_set_push_function(gnutls_session_t session,
1631                                         gnutls_push_func push_func);
1632 void gnutls_transport_set_pull_function(gnutls_session_t session,
1633                                         gnutls_pull_func pull_func);
1634
1635 void gnutls_transport_set_pull_timeout_function(gnutls_session_t session,
1636                                                 gnutls_pull_timeout_func
1637                                                 func);
1638
1639 void gnutls_transport_set_errno_function(gnutls_session_t session,
1640                                          gnutls_errno_func errno_func);
1641
1642 void gnutls_transport_set_errno(gnutls_session_t session, int err);
1643
1644 /* session specific 
1645  */
1646 void gnutls_session_set_ptr(gnutls_session_t session, void *ptr);
1647 void *gnutls_session_get_ptr(gnutls_session_t session);
1648
1649 void gnutls_openpgp_send_cert(gnutls_session_t session,
1650                               gnutls_openpgp_crt_status_t status);
1651
1652 /* This function returns the hash of the given data.
1653  */
1654 int gnutls_fingerprint(gnutls_digest_algorithm_t algo,
1655                        const gnutls_datum_t * data, void *result,
1656                        size_t * result_size);
1657
1658   /**
1659    * gnutls_random_art_t:
1660    * @GNUTLS_RANDOM_ART_OPENSSH: OpenSSH-style random art.
1661    *
1662    * Enumeration of different random art types.
1663    */
1664 typedef enum gnutls_random_art {
1665         GNUTLS_RANDOM_ART_OPENSSH = 1
1666 } gnutls_random_art_t;
1667
1668 int gnutls_random_art(gnutls_random_art_t type,
1669                       const char *key_type, unsigned int key_size,
1670                       void *fpr, size_t fpr_size, gnutls_datum_t * art);
1671
1672 /* SRP 
1673  */
1674
1675 typedef struct gnutls_srp_server_credentials_st
1676 *gnutls_srp_server_credentials_t;
1677 typedef struct gnutls_srp_client_credentials_st
1678 *gnutls_srp_client_credentials_t;
1679
1680 void
1681 gnutls_srp_free_client_credentials(gnutls_srp_client_credentials_t sc);
1682 int
1683 gnutls_srp_allocate_client_credentials(gnutls_srp_client_credentials_t *
1684                                        sc);
1685 int gnutls_srp_set_client_credentials(gnutls_srp_client_credentials_t res,
1686                                       const char *username,
1687                                       const char *password);
1688
1689 void
1690 gnutls_srp_free_server_credentials(gnutls_srp_server_credentials_t sc);
1691 int
1692 gnutls_srp_allocate_server_credentials(gnutls_srp_server_credentials_t *
1693                                        sc);
1694 int gnutls_srp_set_server_credentials_file(gnutls_srp_server_credentials_t
1695                                            res, const char *password_file,
1696                                            const char *password_conf_file);
1697
1698 const char *gnutls_srp_server_get_username(gnutls_session_t session);
1699
1700 void gnutls_srp_set_prime_bits(gnutls_session_t session,
1701                                unsigned int bits);
1702
1703 int gnutls_srp_verifier(const char *username,
1704                         const char *password,
1705                         const gnutls_datum_t * salt,
1706                         const gnutls_datum_t * generator,
1707                         const gnutls_datum_t * prime,
1708                         gnutls_datum_t * res);
1709
1710 /* The static parameters defined in draft-ietf-tls-srp-05
1711  * Those should be used as input to gnutls_srp_verifier().
1712  */
1713 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_prime;
1714 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_generator;
1715
1716 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_prime;
1717 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_generator;
1718
1719 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_prime;
1720 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_generator;
1721
1722 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_prime;
1723 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_generator;
1724
1725 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_prime;
1726 extern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_generator;
1727
1728 typedef int gnutls_srp_server_credentials_function(gnutls_session_t,
1729                                                    const char *username,
1730                                                    gnutls_datum_t * salt,
1731                                                    gnutls_datum_t *
1732                                                    verifier,
1733                                                    gnutls_datum_t *
1734                                                    generator,
1735                                                    gnutls_datum_t * prime);
1736 void
1737 gnutls_srp_set_server_credentials_function(gnutls_srp_server_credentials_t
1738                                            cred,
1739                                            gnutls_srp_server_credentials_function
1740                                            * func);
1741
1742 typedef int gnutls_srp_client_credentials_function(gnutls_session_t,
1743                                                    char **, char **);
1744 void
1745 gnutls_srp_set_client_credentials_function(gnutls_srp_client_credentials_t
1746                                            cred,
1747                                            gnutls_srp_client_credentials_function
1748                                            * func);
1749
1750 int gnutls_srp_base64_encode(const gnutls_datum_t * data, char *result,
1751                              size_t * result_size);
1752 int gnutls_srp_base64_encode_alloc(const gnutls_datum_t * data,
1753                                    gnutls_datum_t * result);
1754
1755 int gnutls_srp_base64_decode(const gnutls_datum_t * b64_data, char *result,
1756                              size_t * result_size);
1757 int gnutls_srp_base64_decode_alloc(const gnutls_datum_t * b64_data,
1758                                    gnutls_datum_t * result);
1759
1760 void
1761 gnutls_srp_set_server_fake_salt_seed(gnutls_srp_server_credentials_t
1762                                      sc,
1763                                      const gnutls_datum_t * seed,
1764                                      unsigned int salt_length);
1765
1766 /* PSK stuff */
1767 typedef struct gnutls_psk_server_credentials_st
1768 *gnutls_psk_server_credentials_t;
1769 typedef struct gnutls_psk_client_credentials_st
1770 *gnutls_psk_client_credentials_t;
1771
1772 /**
1773  * gnutls_psk_key_flags:
1774  * @GNUTLS_PSK_KEY_RAW: PSK-key in raw format.
1775  * @GNUTLS_PSK_KEY_HEX: PSK-key in hex format.
1776  *
1777  * Enumeration of different PSK key flags.
1778  */
1779 typedef enum gnutls_psk_key_flags {
1780         GNUTLS_PSK_KEY_RAW = 0,
1781         GNUTLS_PSK_KEY_HEX
1782 } gnutls_psk_key_flags;
1783
1784 void
1785 gnutls_psk_free_client_credentials(gnutls_psk_client_credentials_t sc);
1786 int
1787 gnutls_psk_allocate_client_credentials(gnutls_psk_client_credentials_t *
1788                                        sc);
1789 int gnutls_psk_set_client_credentials(gnutls_psk_client_credentials_t res,
1790                                       const char *username,
1791                                       const gnutls_datum_t * key,
1792                                       gnutls_psk_key_flags flags);
1793
1794 void
1795 gnutls_psk_free_server_credentials(gnutls_psk_server_credentials_t sc);
1796 int
1797 gnutls_psk_allocate_server_credentials(gnutls_psk_server_credentials_t *
1798                                        sc);
1799 int gnutls_psk_set_server_credentials_file(gnutls_psk_server_credentials_t
1800                                            res, const char *password_file);
1801
1802 int
1803 gnutls_psk_set_server_credentials_hint(gnutls_psk_server_credentials_t
1804                                        res, const char *hint);
1805
1806 const char *gnutls_psk_server_get_username(gnutls_session_t session);
1807 const char *gnutls_psk_client_get_hint(gnutls_session_t session);
1808
1809 typedef int gnutls_psk_server_credentials_function(gnutls_session_t,
1810                                                    const char *username,
1811                                                    gnutls_datum_t * key);
1812 void
1813 gnutls_psk_set_server_credentials_function(gnutls_psk_server_credentials_t
1814                                            cred,
1815                                            gnutls_psk_server_credentials_function
1816                                            * func);
1817
1818 typedef int gnutls_psk_client_credentials_function(gnutls_session_t,
1819                                                    char **username,
1820                                                    gnutls_datum_t * key);
1821 void
1822 gnutls_psk_set_client_credentials_function(gnutls_psk_client_credentials_t
1823                                            cred,
1824                                            gnutls_psk_client_credentials_function
1825                                            * func);
1826
1827 int gnutls_hex_encode(const gnutls_datum_t * data, char *result,
1828                       size_t * result_size);
1829 int gnutls_hex_decode(const gnutls_datum_t * hex_data, void *result,
1830                       size_t * result_size);
1831
1832 void
1833 gnutls_psk_set_server_dh_params(gnutls_psk_server_credentials_t res,
1834                                 gnutls_dh_params_t dh_params);
1835
1836 void
1837 gnutls_psk_set_server_params_function(gnutls_psk_server_credentials_t
1838                                       res, gnutls_params_function * func);
1839
1840 /**
1841  * gnutls_x509_subject_alt_name_t:
1842  * @GNUTLS_SAN_DNSNAME: DNS-name SAN.
1843  * @GNUTLS_SAN_RFC822NAME: E-mail address SAN.
1844  * @GNUTLS_SAN_URI: URI SAN.
1845  * @GNUTLS_SAN_IPADDRESS: IP address SAN.
1846  * @GNUTLS_SAN_OTHERNAME: OtherName SAN.
1847  * @GNUTLS_SAN_DN: DN SAN.
1848  * @GNUTLS_SAN_OTHERNAME_XMPP: Virtual SAN, used by
1849  *   gnutls_x509_crt_get_subject_alt_othername_oid.
1850  *
1851  * Enumeration of different subject alternative names types.
1852  */
1853 typedef enum gnutls_x509_subject_alt_name_t {
1854         GNUTLS_SAN_DNSNAME = 1,
1855         GNUTLS_SAN_RFC822NAME = 2,
1856         GNUTLS_SAN_URI = 3,
1857         GNUTLS_SAN_IPADDRESS = 4,
1858         GNUTLS_SAN_OTHERNAME = 5,
1859         GNUTLS_SAN_DN = 6,
1860         /* The following are "virtual" subject alternative name types, in
1861            that they are represented by an otherName value and an OID.
1862            Used by gnutls_x509_crt_get_subject_alt_othername_oid.  */
1863         GNUTLS_SAN_OTHERNAME_XMPP = 1000
1864 } gnutls_x509_subject_alt_name_t;
1865
1866 struct gnutls_openpgp_crt_int;
1867 typedef struct gnutls_openpgp_crt_int *gnutls_openpgp_crt_t;
1868
1869 struct gnutls_openpgp_privkey_int;
1870 typedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t;
1871
1872 struct gnutls_pkcs11_privkey_st;
1873 typedef struct gnutls_pkcs11_privkey_st *gnutls_pkcs11_privkey_t;
1874
1875 /**
1876  * gnutls_privkey_type_t:
1877  * @GNUTLS_PRIVKEY_X509: X.509 private key, #gnutls_x509_privkey_t.
1878  * @GNUTLS_PRIVKEY_OPENPGP: OpenPGP private key, #gnutls_openpgp_privkey_t.
1879  * @GNUTLS_PRIVKEY_PKCS11: PKCS11 private key, #gnutls_pkcs11_privkey_t.
1880  * @GNUTLS_PRIVKEY_EXT: External private key, operating using callbacks.
1881  *
1882  * Enumeration of different private key types.
1883  */
1884 typedef enum {
1885         GNUTLS_PRIVKEY_X509,
1886         GNUTLS_PRIVKEY_OPENPGP,
1887         GNUTLS_PRIVKEY_PKCS11,
1888         GNUTLS_PRIVKEY_EXT
1889 } gnutls_privkey_type_t;
1890
1891 typedef struct gnutls_retr2_st {
1892         gnutls_certificate_type_t cert_type;
1893         gnutls_privkey_type_t key_type;
1894
1895         union {
1896                 gnutls_x509_crt_t *x509;
1897                 gnutls_openpgp_crt_t pgp;
1898         } cert;
1899         unsigned int ncerts;    /* one for pgp keys */
1900
1901         union {
1902                 gnutls_x509_privkey_t x509;
1903                 gnutls_openpgp_privkey_t pgp;
1904                 gnutls_pkcs11_privkey_t pkcs11;
1905         } key;
1906
1907         unsigned int deinit_all;        /* if non zero all keys will be deinited */
1908 } gnutls_retr2_st;
1909
1910
1911   /* Functions that allow auth_info_t structures handling
1912    */
1913
1914 gnutls_credentials_type_t gnutls_auth_get_type(gnutls_session_t session);
1915 gnutls_credentials_type_t
1916 gnutls_auth_server_get_type(gnutls_session_t session);
1917 gnutls_credentials_type_t
1918 gnutls_auth_client_get_type(gnutls_session_t session);
1919
1920   /* DH */
1921
1922 void gnutls_dh_set_prime_bits(gnutls_session_t session, unsigned int bits);
1923 int gnutls_dh_get_secret_bits(gnutls_session_t session);
1924 int gnutls_dh_get_peers_public_bits(gnutls_session_t session);
1925 int gnutls_dh_get_prime_bits(gnutls_session_t session);
1926
1927 int gnutls_dh_get_group(gnutls_session_t session, gnutls_datum_t * raw_gen,
1928                         gnutls_datum_t * raw_prime);
1929 int gnutls_dh_get_pubkey(gnutls_session_t session,
1930                          gnutls_datum_t * raw_key);
1931
1932   /* X509PKI */
1933
1934
1935   /* These are set on the credentials structure.
1936    */
1937
1938   /* use gnutls_certificate_set_retrieve_function2() in abstract.h
1939    * instead. It's much more efficient.
1940    */
1941
1942 typedef int gnutls_certificate_retrieve_function(gnutls_session_t,
1943                                                  const
1944                                                  gnutls_datum_t *
1945                                                  req_ca_rdn,
1946                                                  int nreqs,
1947                                                  const
1948                                                  gnutls_pk_algorithm_t
1949                                                  * pk_algos,
1950                                                  int
1951                                                  pk_algos_length,
1952                                                  gnutls_retr2_st *);
1953
1954
1955 void
1956 gnutls_certificate_set_retrieve_function(gnutls_certificate_credentials_t
1957                                          cred,
1958                                          gnutls_certificate_retrieve_function
1959                                          * func);
1960
1961 typedef int gnutls_certificate_verify_function(gnutls_session_t);
1962 void
1963 gnutls_certificate_set_verify_function(gnutls_certificate_credentials_t
1964                                        cred,
1965                                        gnutls_certificate_verify_function
1966                                        * func);
1967
1968 void
1969 gnutls_certificate_server_set_request(gnutls_session_t session,
1970                                       gnutls_certificate_request_t req);
1971
1972   /* get data from the session
1973    */
1974 const gnutls_datum_t *gnutls_certificate_get_peers(gnutls_session_t
1975                                                    session, unsigned int
1976                                                    *list_size);
1977 const gnutls_datum_t *gnutls_certificate_get_ours(gnutls_session_t
1978                                                   session);
1979
1980 int gnutls_certificate_get_peers_subkey_id(gnutls_session_t session,
1981                                            gnutls_datum_t * id);
1982
1983 time_t gnutls_certificate_activation_time_peers(gnutls_session_t session);
1984 time_t gnutls_certificate_expiration_time_peers(gnutls_session_t session);
1985
1986 int gnutls_certificate_client_get_request_status(gnutls_session_t session);
1987 int gnutls_certificate_verify_peers2(gnutls_session_t session,
1988                                      unsigned int *status);
1989 int gnutls_certificate_verify_peers3(gnutls_session_t session,
1990                                      const char *hostname,
1991                                      unsigned int *status);
1992
1993 /**
1994  * gnutls_vdata_types_t:
1995  * @GNUTLS_DT_UNKNOWN: Unknown data type.
1996  * @GNUTLS_DT_DNS_HOSTNAME: The data contain a null-terminated DNS hostname.
1997  * @GNUTLS_DT_KEY_PURPOSE_OID: The data contain a null-terminated key purpose OID.
1998  *
1999  * Enumeration of different key exchange algorithms.
2000  */
2001 typedef enum {
2002         GNUTLS_DT_UNKNOWN = 0,
2003         GNUTLS_DT_DNS_HOSTNAME = 1,
2004         GNUTLS_DT_KEY_PURPOSE_OID = 2
2005 } gnutls_vdata_types_t;
2006
2007 typedef struct {
2008         gnutls_vdata_types_t type;
2009         unsigned char *data;
2010         unsigned int size;
2011 } gnutls_typed_vdata_st;
2012
2013 int
2014 gnutls_certificate_verify_peers(gnutls_session_t session,
2015                                 gnutls_typed_vdata_st * data,
2016                                 unsigned int elements,
2017                                 unsigned int *status);
2018
2019 int gnutls_certificate_verification_status_print(unsigned int status,
2020                                                  gnutls_certificate_type_t
2021                                                  type,
2022                                                  gnutls_datum_t * out,
2023                                                  unsigned int flags);
2024
2025 int gnutls_pem_base64_encode(const char *msg, const gnutls_datum_t * data,
2026                              char *result, size_t * result_size);
2027 int gnutls_pem_base64_decode(const char *header,
2028                              const gnutls_datum_t * b64_data,
2029                              unsigned char *result, size_t * result_size);
2030
2031 int gnutls_pem_base64_encode_alloc(const char *msg,
2032                                    const gnutls_datum_t * data,
2033                                    gnutls_datum_t * result);
2034 int gnutls_pem_base64_decode_alloc(const char *header,
2035                                    const gnutls_datum_t * b64_data,
2036                                    gnutls_datum_t * result);
2037
2038   /* key_usage will be an OR of the following values:
2039    */
2040
2041   /* when the key is to be used for signing: */
2042 #define GNUTLS_KEY_DIGITAL_SIGNATURE    128
2043 #define GNUTLS_KEY_NON_REPUDIATION      64
2044   /* when the key is to be used for encryption: */
2045 #define GNUTLS_KEY_KEY_ENCIPHERMENT     32
2046 #define GNUTLS_KEY_DATA_ENCIPHERMENT    16
2047 #define GNUTLS_KEY_KEY_AGREEMENT        8
2048 #define GNUTLS_KEY_KEY_CERT_SIGN        4
2049 #define GNUTLS_KEY_CRL_SIGN             2
2050 #define GNUTLS_KEY_ENCIPHER_ONLY        1
2051 #define GNUTLS_KEY_DECIPHER_ONLY        32768
2052
2053 void
2054 gnutls_certificate_set_params_function(gnutls_certificate_credentials_t
2055                                        res, gnutls_params_function * func);
2056 void gnutls_anon_set_params_function(gnutls_anon_server_credentials_t res,
2057                                      gnutls_params_function * func);
2058 void gnutls_psk_set_params_function(gnutls_psk_server_credentials_t res,
2059                                     gnutls_params_function * func);
2060
2061 int gnutls_hex2bin(const char *hex_data, size_t hex_size,
2062                    void *bin_data, size_t * bin_size);
2063
2064   /* Trust on first use (or ssh like) functions */
2065
2066   /* stores the provided information to a database
2067    */
2068 typedef int (*gnutls_tdb_store_func) (const char *db_name,
2069                                       const char *host,
2070                                       const char *service,
2071                                       time_t expiration,
2072                                       const gnutls_datum_t * pubkey);
2073
2074 typedef int (*gnutls_tdb_store_commitment_func) (const char *db_name,
2075                                                  const char *host,
2076                                                  const char *service,
2077                                                  time_t expiration,
2078                                                  gnutls_digest_algorithm_t
2079                                                  hash_algo,
2080                                                  const gnutls_datum_t *
2081                                                  hash);
2082
2083   /* searches for the provided host/service pair that match the
2084    * provided public key in the database. */
2085 typedef int (*gnutls_tdb_verify_func) (const char *db_name,
2086                                        const char *host,
2087                                        const char *service,
2088                                        const gnutls_datum_t * pubkey);
2089
2090
2091 struct gnutls_tdb_int;
2092 typedef struct gnutls_tdb_int *gnutls_tdb_t;
2093
2094 int gnutls_tdb_init(gnutls_tdb_t * tdb);
2095 void gnutls_tdb_set_store_func(gnutls_tdb_t tdb,
2096                                gnutls_tdb_store_func store);
2097 void gnutls_tdb_set_store_commitment_func(gnutls_tdb_t tdb,
2098                                           gnutls_tdb_store_commitment_func
2099                                           cstore);
2100 void gnutls_tdb_set_verify_func(gnutls_tdb_t tdb,
2101                                 gnutls_tdb_verify_func verify);
2102 void gnutls_tdb_deinit(gnutls_tdb_t tdb);
2103
2104 int gnutls_verify_stored_pubkey(const char *db_name,
2105                                 gnutls_tdb_t tdb,
2106                                 const char *host,
2107                                 const char *service,
2108                                 gnutls_certificate_type_t cert_type,
2109                                 const gnutls_datum_t * cert,
2110                                 unsigned int flags);
2111
2112 int gnutls_store_commitment(const char *db_name,
2113                             gnutls_tdb_t tdb,
2114                             const char *host,
2115                             const char *service,
2116                             gnutls_digest_algorithm_t hash_algo,
2117                             const gnutls_datum_t * hash,
2118                             time_t expiration, unsigned int flags);
2119
2120 int gnutls_store_pubkey(const char *db_name,
2121                         gnutls_tdb_t tdb,
2122                         const char *host,
2123                         const char *service,
2124                         gnutls_certificate_type_t cert_type,
2125                         const gnutls_datum_t * cert,
2126                         time_t expiration, unsigned int flags);
2127
2128   /* Other helper functions */
2129 int gnutls_load_file(const char *filename, gnutls_datum_t * data);
2130
2131 int gnutls_url_is_supported(const char *url);
2132
2133   /* PIN callback */
2134
2135 /**
2136  * gnutls_pin_flag_t:
2137  * @GNUTLS_PIN_USER: The PIN for the user.
2138  * @GNUTLS_PIN_SO: The PIN for the security officer (admin).
2139  * @GNUTLS_PIN_CONTEXT_SPECIFIC: The PIN is for a specific action and key like signing.
2140  * @GNUTLS_PIN_FINAL_TRY: This is the final try before blocking.
2141  * @GNUTLS_PIN_COUNT_LOW: Few tries remain before token blocks.
2142  * @GNUTLS_PIN_WRONG: Last given PIN was not correct.
2143  *
2144  * Enumeration of different flags that are input to the PIN function.
2145  */
2146 typedef enum {
2147         GNUTLS_PIN_USER = (1 << 0),
2148         GNUTLS_PIN_SO = (1 << 1),
2149         GNUTLS_PIN_FINAL_TRY = (1 << 2),
2150         GNUTLS_PIN_COUNT_LOW = (1 << 3),
2151         GNUTLS_PIN_CONTEXT_SPECIFIC = (1 << 4),
2152         GNUTLS_PIN_WRONG = (1 << 5)
2153 } gnutls_pin_flag_t;
2154
2155 #define GNUTLS_PKCS11_PIN_USER GNUTLS_PIN_USER
2156 #define GNUTLS_PKCS11_PIN_SO GNUTLS_PIN_SO
2157 #define GNUTLS_PKCS11_PIN_FINAL_TRY GNUTLS_PIN_FINAL_TRY
2158 #define GNUTLS_PKCS11_PIN_COUNT_LOW  GNUTLS_PIN_COUNT_LOW
2159 #define GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC GNUTLS_PIN_CONTEXT_SPECIFIC
2160 #define GNUTLS_PKCS11_PIN_WRONG GNUTLS_PIN_WRONG
2161
2162 /**
2163  * gnutls_pin_callback_t:
2164  * @userdata: user-controlled data from gnutls_pkcs11_set_pin_function().
2165  * @attempt: pin-attempt counter, initially 0.
2166  * @token_url: URL of token.
2167  * @token_label: label of token.
2168  * @flags: a #gnutls_pin_flag_t flag.
2169  * @pin: buffer to hold PIN, of size @pin_max.
2170  * @pin_max: size of @pin buffer.
2171  *
2172  * Callback function type for PKCS#11 or TPM PIN entry.  It is set by
2173  * functions like gnutls_pkcs11_set_pin_function().
2174  *
2175  * The callback should provides the PIN code to unlock the token with
2176  * label @token_label, specified by the URL @token_url.
2177  *
2178  * The PIN code, as a NUL-terminated ASCII string, should be copied
2179  * into the @pin buffer (of maximum size @pin_max), and return 0 to
2180  * indicate success.  Alternatively, the callback may return a
2181  * negative gnutls error code to indicate failure and cancel PIN entry
2182  * (in which case, the contents of the @pin parameter are ignored).
2183  *
2184  * When a PIN is required, the callback will be invoked repeatedly
2185  * (and indefinitely) until either the returned PIN code is correct,
2186  * the callback returns failure, or the token refuses login (e.g. when
2187  * the token is locked due to too many incorrect PINs!).  For the
2188  * first such invocation, the @attempt counter will have value zero;
2189  * it will increase by one for each subsequent attempt.
2190  *
2191  * Returns: %GNUTLS_E_SUCCESS (0) on success or a negative error code on error.
2192  *
2193  * Since: 2.12.0
2194  **/
2195 typedef int (*gnutls_pin_callback_t) (void *userdata, int attempt,
2196                                       const char *token_url,
2197                                       const char *token_label,
2198                                       unsigned int flags,
2199                                       char *pin, size_t pin_max);
2200
2201 void gnutls_certificate_set_pin_function(gnutls_certificate_credentials_t,
2202                                          gnutls_pin_callback_t fn,
2203                                          void *userdata);
2204
2205 /* FIPS140-2 related functions */
2206 int gnutls_fips140_mode_enabled(void);
2207
2208   /* Gnutls error codes. The mapping to a TLS alert is also shown in
2209    * comments.
2210    */
2211
2212 #define GNUTLS_E_SUCCESS 0
2213 #define GNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3
2214 #define GNUTLS_E_UNKNOWN_CIPHER_TYPE -6
2215 #define GNUTLS_E_LARGE_PACKET -7
2216 #define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8  /* GNUTLS_A_PROTOCOL_VERSION */
2217 #define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9    /* GNUTLS_A_RECORD_OVERFLOW */
2218 #define GNUTLS_E_INVALID_SESSION -10
2219 #define GNUTLS_E_FATAL_ALERT_RECEIVED -12
2220 #define GNUTLS_E_UNEXPECTED_PACKET -15  /* GNUTLS_A_UNEXPECTED_MESSAGE */
2221 #define GNUTLS_E_WARNING_ALERT_RECEIVED -16
2222 #define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18
2223 #define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19
2224 #define GNUTLS_E_UNKNOWN_CIPHER_SUITE -21       /* GNUTLS_A_HANDSHAKE_FAILURE */
2225 #define GNUTLS_E_UNWANTED_ALGORITHM -22
2226 #define GNUTLS_E_MPI_SCAN_FAILED -23
2227 #define GNUTLS_E_DECRYPTION_FAILED -24  /* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */
2228 #define GNUTLS_E_MEMORY_ERROR -25
2229 #define GNUTLS_E_DECOMPRESSION_FAILED -26       /* GNUTLS_A_DECOMPRESSION_FAILURE */
2230 #define GNUTLS_E_COMPRESSION_FAILED -27
2231 #define GNUTLS_E_AGAIN -28
2232 #define GNUTLS_E_EXPIRED -29
2233 #define GNUTLS_E_DB_ERROR -30
2234 #define GNUTLS_E_SRP_PWD_ERROR -31
2235 #define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32
2236 #define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS      /* for backwards compatibility only */
2237 #define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS
2238 #define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS     /* for backwards compatibility only */
2239
2240 #define GNUTLS_E_HASH_FAILED -33
2241 #define GNUTLS_E_BASE64_DECODING_ERROR -34
2242
2243 #define GNUTLS_E_MPI_PRINT_FAILED -35
2244 #define GNUTLS_E_REHANDSHAKE -37        /* GNUTLS_A_NO_RENEGOTIATION */
2245 #define GNUTLS_E_GOT_APPLICATION_DATA -38
2246 #define GNUTLS_E_RECORD_LIMIT_REACHED -39
2247 #define GNUTLS_E_ENCRYPTION_FAILED -40
2248
2249 #define GNUTLS_E_PK_ENCRYPTION_FAILED -44
2250 #define GNUTLS_E_PK_DECRYPTION_FAILED -45
2251 #define GNUTLS_E_PK_SIGN_FAILED -46
2252 #define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47
2253 #define GNUTLS_E_KEY_USAGE_VIOLATION -48
2254 #define GNUTLS_E_NO_CERTIFICATE_FOUND -49       /* GNUTLS_A_BAD_CERTIFICATE */
2255 #define GNUTLS_E_INVALID_REQUEST -50
2256 #define GNUTLS_E_SHORT_MEMORY_BUFFER -51
2257 #define GNUTLS_E_INTERRUPTED -52
2258 #define GNUTLS_E_PUSH_ERROR -53
2259 #define GNUTLS_E_PULL_ERROR -54
2260 #define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55 /* GNUTLS_A_ILLEGAL_PARAMETER */
2261 #define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56
2262 #define GNUTLS_E_PKCS1_WRONG_PAD -57
2263 #define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58
2264 #define GNUTLS_E_INTERNAL_ERROR -59
2265 #define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63
2266 #define GNUTLS_E_FILE_ERROR -64
2267 #define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78
2268 #define GNUTLS_E_UNKNOWN_PK_ALGORITHM -80
2269 #define GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS -81
2270
2271   /* returned if you need to generate temporary RSA
2272    * parameters. These are needed for export cipher suites.
2273    */
2274 #define GNUTLS_E_NO_TEMPORARY_RSA_PARAMS -84
2275
2276 #define GNUTLS_E_NO_COMPRESSION_ALGORITHMS -86
2277 #define GNUTLS_E_NO_CIPHER_SUITES -87
2278
2279 #define GNUTLS_E_OPENPGP_GETKEY_FAILED -88
2280 #define GNUTLS_E_PK_SIG_VERIFY_FAILED -89
2281
2282 #define GNUTLS_E_ILLEGAL_SRP_USERNAME -90
2283 #define GNUTLS_E_SRP_PWD_PARSING_ERROR -91
2284 #define GNUTLS_E_NO_TEMPORARY_DH_PARAMS -93
2285
2286   /* For certificate and key stuff
2287    */
2288 #define GNUTLS_E_ASN1_ELEMENT_NOT_FOUND -67
2289 #define GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND -68
2290 #define GNUTLS_E_ASN1_DER_ERROR -69
2291 #define GNUTLS_E_ASN1_VALUE_NOT_FOUND -70
2292 #define GNUTLS_E_ASN1_GENERIC_ERROR -71
2293 #define GNUTLS_E_ASN1_VALUE_NOT_VALID -72
2294 #define GNUTLS_E_ASN1_TAG_ERROR -73
2295 #define GNUTLS_E_ASN1_TAG_IMPLICIT -74
2296 #define GNUTLS_E_ASN1_TYPE_ANY_ERROR -75
2297 #define GNUTLS_E_ASN1_SYNTAX_ERROR -76
2298 #define GNUTLS_E_ASN1_DER_OVERFLOW -77
2299 #define GNUTLS_E_OPENPGP_UID_REVOKED -79
2300 #define GNUTLS_E_CERTIFICATE_ERROR -43
2301 #define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR
2302 #define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60
2303 #define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61       /* GNUTLS_A_UNSUPPORTED_CERTIFICATE */
2304 #define GNUTLS_E_X509_UNKNOWN_SAN -62
2305 #define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94
2306 #define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95
2307 #define GNUTLS_E_UNKNOWN_HASH_ALGORITHM -96
2308 #define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97
2309 #define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98
2310 #define GNUTLS_E_INVALID_PASSWORD -99
2311 #define GNUTLS_E_MAC_VERIFY_FAILED -100 /* for PKCS #12 MAC */
2312 #define GNUTLS_E_CONSTRAINT_ERROR -101
2313
2314 #define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102
2315 #define GNUTLS_E_WARNING_IA_FPHF_RECEIVED -103
2316
2317 #define GNUTLS_E_IA_VERIFY_FAILED -104
2318 #define GNUTLS_E_UNKNOWN_ALGORITHM -105
2319 #define GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM -106
2320 #define GNUTLS_E_SAFE_RENEGOTIATION_FAILED -107
2321 #define GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED -108
2322 #define GNUTLS_E_UNKNOWN_SRP_USERNAME -109
2323 #define GNUTLS_E_PREMATURE_TERMINATION -110
2324
2325 #define GNUTLS_E_BASE64_ENCODING_ERROR -201
2326 #define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202       /* obsolete */
2327 #define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202
2328 #define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203
2329
2330 #define GNUTLS_E_OPENPGP_KEYRING_ERROR -204
2331 #define GNUTLS_E_X509_UNSUPPORTED_OID -205
2332
2333 #define GNUTLS_E_RANDOM_FAILED -206
2334 #define GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR -207
2335
2336 #define GNUTLS_E_OPENPGP_SUBKEY_ERROR -208
2337
2338 #define GNUTLS_E_CRYPTO_ALREADY_REGISTERED -209
2339
2340 #define GNUTLS_E_HANDSHAKE_TOO_LARGE -210
2341
2342 #define GNUTLS_E_CRYPTODEV_IOCTL_ERROR -211
2343 #define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212
2344
2345 #define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213
2346 #define GNUTLS_E_BAD_COOKIE -214
2347 #define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215
2348 #define GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL -216
2349
2350 #define GNUTLS_E_HEARTBEAT_PONG_RECEIVED -292
2351 #define GNUTLS_E_HEARTBEAT_PING_RECEIVED -293
2352
2353 /* PKCS11 related */
2354 #define GNUTLS_E_PKCS11_ERROR -300
2355 #define GNUTLS_E_PKCS11_LOAD_ERROR -301
2356 #define GNUTLS_E_PARSING_ERROR -302
2357 #define GNUTLS_E_PKCS11_PIN_ERROR -303
2358
2359 #define GNUTLS_E_PKCS11_SLOT_ERROR -305
2360 #define GNUTLS_E_LOCKING_ERROR -306
2361 #define GNUTLS_E_PKCS11_ATTRIBUTE_ERROR -307
2362 #define GNUTLS_E_PKCS11_DEVICE_ERROR -308
2363 #define GNUTLS_E_PKCS11_DATA_ERROR -309
2364 #define GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR -310
2365 #define GNUTLS_E_PKCS11_KEY_ERROR -311
2366 #define GNUTLS_E_PKCS11_PIN_EXPIRED -312
2367 #define GNUTLS_E_PKCS11_PIN_LOCKED -313
2368 #define GNUTLS_E_PKCS11_SESSION_ERROR -314
2369 #define GNUTLS_E_PKCS11_SIGNATURE_ERROR -315
2370 #define GNUTLS_E_PKCS11_TOKEN_ERROR -316
2371 #define GNUTLS_E_PKCS11_USER_ERROR -317
2372
2373 #define GNUTLS_E_CRYPTO_INIT_FAILED -318
2374 #define GNUTLS_E_TIMEDOUT -319
2375 #define GNUTLS_E_USER_ERROR -320
2376 #define GNUTLS_E_ECC_NO_SUPPORTED_CURVES -321
2377 #define GNUTLS_E_ECC_UNSUPPORTED_CURVE -322
2378 #define GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE -323
2379 #define GNUTLS_E_CERTIFICATE_LIST_UNSORTED -324
2380 #define GNUTLS_E_ILLEGAL_PARAMETER -325
2381 #define GNUTLS_E_NO_PRIORITIES_WERE_SET -326
2382 #define GNUTLS_E_X509_UNSUPPORTED_EXTENSION -327
2383 #define GNUTLS_E_SESSION_EOF -328
2384
2385 #define GNUTLS_E_TPM_ERROR -329
2386 #define GNUTLS_E_TPM_KEY_PASSWORD_ERROR -330
2387 #define GNUTLS_E_TPM_SRK_PASSWORD_ERROR -331
2388 #define GNUTLS_E_TPM_SESSION_ERROR -332
2389 #define GNUTLS_E_TPM_KEY_NOT_FOUND -333
2390 #define GNUTLS_E_TPM_UNINITIALIZED -334
2391
2392 #define GNUTLS_E_NO_CERTIFICATE_STATUS -340
2393 #define GNUTLS_E_OCSP_RESPONSE_ERROR -341
2394 #define GNUTLS_E_RANDOM_DEVICE_ERROR -342
2395 #define GNUTLS_E_AUTH_ERROR -343
2396 #define GNUTLS_E_NO_APPLICATION_PROTOCOL -344
2397 #define GNUTLS_E_SOCKETS_INIT_ERROR -345
2398 #define GNUTLS_E_KEY_IMPORT_FAILED -346
2399
2400 #define GNUTLS_E_SELF_TEST_ERROR -400
2401 #define GNUTLS_E_NO_SELF_TEST -401
2402 #define GNUTLS_E_LIB_IN_ERROR_STATE -402
2403 #define GNUTLS_E_PK_GENERATION_ERROR -403
2404 #define GNUTLS_E_IDNA_ERROR -404
2405
2406 #define GNUTLS_E_UNIMPLEMENTED_FEATURE -1250
2407
2408
2409
2410 #define GNUTLS_E_APPLICATION_ERROR_MAX -65000
2411 #define GNUTLS_E_APPLICATION_ERROR_MIN -65500
2412
2413 /* *INDENT-OFF* */
2414 #ifdef __cplusplus
2415 }
2416 #endif
2417 /* *INDENT-ON* */
2418
2419 #include <gnutls/compat.h>
2420
2421 #endif                          /* GNUTLS_H */