Added doc-skip to skip certain functions from documentation.
[gnutls.git] / lib / includes / gnutls / compat.h
blob29bff39cb088f507327a47c922febce6a086c2ca
1 /*
2 * Copyright (C) 2008-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 /* Typedefs for more compatibility with older GnuTLS. */
25 #ifndef _GNUTLS_COMPAT_H
26 #define _GNUTLS_COMPAT_H
28 #ifdef __cplusplus
29 extern "C"
31 #endif
33 #ifdef __GNUC__
35 #define _GNUTLS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
37 #if !defined GNUTLS_INTERNAL_BUILD
38 #if _GNUTLS_GCC_VERSION >= 30100
39 #define _GNUTLS_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
40 #endif
41 #endif
43 #endif /* __GNUC__ */
45 #ifndef _GNUTLS_GCC_ATTR_DEPRECATED
46 #define _GNUTLS_GCC_ATTR_DEPRECATED
47 #endif
49 /* gnutls_connection_end_t was made redundant in 2.99.0 */
50 typedef unsigned int gnutls_connection_end_t _GNUTLS_GCC_ATTR_DEPRECATED;
52 /* Stuff deprected in 2.x */
53 typedef gnutls_cipher_algorithm_t gnutls_cipher_algorithm _GNUTLS_GCC_ATTR_DEPRECATED;
54 typedef gnutls_kx_algorithm_t gnutls_kx_algorithm _GNUTLS_GCC_ATTR_DEPRECATED;
55 typedef gnutls_mac_algorithm_t gnutls_mac_algorithm _GNUTLS_GCC_ATTR_DEPRECATED;
56 typedef gnutls_digest_algorithm_t gnutls_digest_algorithm _GNUTLS_GCC_ATTR_DEPRECATED;
57 typedef gnutls_compression_method_t gnutls_compression_method _GNUTLS_GCC_ATTR_DEPRECATED;
58 typedef gnutls_connection_end_t gnutls_connection_end _GNUTLS_GCC_ATTR_DEPRECATED;
59 typedef gnutls_x509_crt_fmt_t gnutls_x509_crt_fmt _GNUTLS_GCC_ATTR_DEPRECATED;
60 typedef gnutls_pk_algorithm_t gnutls_pk_algorithm _GNUTLS_GCC_ATTR_DEPRECATED;
61 typedef gnutls_sign_algorithm_t gnutls_sign_algorithm _GNUTLS_GCC_ATTR_DEPRECATED;
62 typedef gnutls_close_request_t gnutls_close_request _GNUTLS_GCC_ATTR_DEPRECATED;
63 typedef gnutls_certificate_request_t gnutls_certificate_request _GNUTLS_GCC_ATTR_DEPRECATED;
64 typedef gnutls_certificate_status_t gnutls_certificate_status _GNUTLS_GCC_ATTR_DEPRECATED;
65 typedef gnutls_session_t gnutls_session _GNUTLS_GCC_ATTR_DEPRECATED;
66 typedef gnutls_alert_level_t gnutls_alert_level _GNUTLS_GCC_ATTR_DEPRECATED;
67 typedef gnutls_alert_description_t gnutls_alert_description _GNUTLS_GCC_ATTR_DEPRECATED;
68 typedef gnutls_x509_subject_alt_name_t gnutls_x509_subject_alt_name _GNUTLS_GCC_ATTR_DEPRECATED;
69 typedef gnutls_openpgp_privkey_t gnutls_openpgp_privkey _GNUTLS_GCC_ATTR_DEPRECATED;
70 typedef gnutls_openpgp_keyring_t gnutls_openpgp_keyring _GNUTLS_GCC_ATTR_DEPRECATED;
71 typedef gnutls_x509_crt_t gnutls_x509_crt _GNUTLS_GCC_ATTR_DEPRECATED;
72 typedef gnutls_x509_privkey_t gnutls_x509_privkey _GNUTLS_GCC_ATTR_DEPRECATED;
73 typedef gnutls_x509_crl_t gnutls_x509_crl _GNUTLS_GCC_ATTR_DEPRECATED;
74 typedef gnutls_x509_crq_t gnutls_x509_crq _GNUTLS_GCC_ATTR_DEPRECATED;
75 typedef gnutls_certificate_credentials_t gnutls_certificate_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
76 typedef gnutls_anon_server_credentials_t gnutls_anon_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
77 typedef gnutls_anon_client_credentials_t gnutls_anon_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
78 typedef gnutls_srp_client_credentials_t gnutls_srp_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
79 typedef gnutls_srp_server_credentials_t gnutls_srp_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
80 typedef gnutls_dh_params_t gnutls_dh_params _GNUTLS_GCC_ATTR_DEPRECATED;
81 typedef gnutls_rsa_params_t gnutls_rsa_params _GNUTLS_GCC_ATTR_DEPRECATED;
82 typedef gnutls_params_type_t gnutls_params_type _GNUTLS_GCC_ATTR_DEPRECATED;
83 typedef gnutls_credentials_type_t gnutls_credentials_type _GNUTLS_GCC_ATTR_DEPRECATED;
84 typedef gnutls_certificate_type_t gnutls_certificate_type _GNUTLS_GCC_ATTR_DEPRECATED;
85 typedef gnutls_datum_t gnutls_datum _GNUTLS_GCC_ATTR_DEPRECATED;
86 typedef gnutls_transport_ptr_t gnutls_transport_ptr _GNUTLS_GCC_ATTR_DEPRECATED;
88 /* Old SRP alerts removed in 2.1.x because the TLS-SRP RFC was
89 modified to use the PSK alert. */
90 #define GNUTLS_A_MISSING_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY
91 #define GNUTLS_A_UNKNOWN_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY
93 /* OpenPGP stuff renamed in 2.1.x. */
94 #define GNUTLS_OPENPGP_KEY GNUTLS_OPENPGP_CERT
95 #define GNUTLS_OPENPGP_KEY_FINGERPRINT GNUTLS_OPENPGP_CERT_FINGERPRINT
96 #define gnutls_openpgp_send_key gnutls_openpgp_send_cert
97 typedef gnutls_openpgp_crt_status_t gnutls_openpgp_key_status_t _GNUTLS_GCC_ATTR_DEPRECATED;
98 typedef gnutls_openpgp_crt_t gnutls_openpgp_key_t _GNUTLS_GCC_ATTR_DEPRECATED;
99 #define gnutls_openpgp_key_init gnutls_openpgp_crt_init
100 #define gnutls_openpgp_key_deinit gnutls_openpgp_crt_deinit
101 #define gnutls_openpgp_key_import gnutls_openpgp_crt_import
102 #define gnutls_openpgp_key_export gnutls_openpgp_crt_export
103 #define gnutls_openpgp_key_get_key_usage gnutls_openpgp_crt_get_key_usage
104 #define gnutls_openpgp_key_get_fingerprint gnutls_openpgp_crt_get_fingerprint
105 #define gnutls_openpgp_key_get_pk_algorithm gnutls_openpgp_crt_get_pk_algorithm
106 #define gnutls_openpgp_key_get_name gnutls_openpgp_crt_get_name
107 #define gnutls_openpgp_key_get_version gnutls_openpgp_crt_get_version
108 #define gnutls_openpgp_key_get_creation_time gnutls_openpgp_crt_get_creation_time
109 #define gnutls_openpgp_key_get_expiration_time gnutls_openpgp_crt_get_expiration_time
110 #define gnutls_openpgp_key_get_id gnutls_openpgp_crt_get_id
111 #define gnutls_openpgp_key_check_hostname gnutls_openpgp_crt_check_hostname
113 /* OpenPGP stuff renamed in 2.3.x. */
114 #define gnutls_openpgp_crt_get_id gnutls_openpgp_crt_get_key_id
116 /* New better names renamed in 2.3.x, add these for backwards
117 compatibility with old poor names.*/
118 #define GNUTLS_X509_CRT_FULL GNUTLS_CRT_PRINT_FULL
119 #define GNUTLS_X509_CRT_ONELINE GNUTLS_CRT_PRINT_ONELINE
120 #define GNUTLS_X509_CRT_UNSIGNED_FULL GNUTLS_CRT_PRINT_UNSIGNED_FULL
122 /* Namespace problems. */
123 #define LIBGNUTLS_VERSION GNUTLS_VERSION
124 #define LIBGNUTLS_VERSION_MAJOR GNUTLS_VERSION_MAJOR
125 #define LIBGNUTLS_VERSION_MINOR GNUTLS_VERSION_MINOR
126 #define LIBGNUTLS_VERSION_PATCH GNUTLS_VERSION_PATCH
127 #define LIBGNUTLS_VERSION_NUMBER GNUTLS_VERSION_NUMBER
128 #define LIBGNUTLS_EXTRA_VERSION GNUTLS_VERSION
130 /* The gnutls_retr_st was deprecated by gnutls_certificate_retrieve_function()
131 * and gnutls_retr2_st.
133 typedef struct gnutls_retr_st
135 gnutls_certificate_type_t type;
136 union
138 gnutls_x509_crt_t *x509;
139 gnutls_openpgp_crt_t pgp;
140 } cert;
141 unsigned int ncerts; /* one for pgp keys */
143 union
145 gnutls_x509_privkey_t x509;
146 gnutls_openpgp_privkey_t pgp;
147 } key;
149 unsigned int deinit_all; /* if non zero all keys will be deinited */
150 } gnutls_retr_st;
152 typedef int gnutls_certificate_client_retrieve_function (gnutls_session_t,
153 const
154 gnutls_datum_t *
155 req_ca_rdn,
156 int nreqs,
157 const
158 gnutls_pk_algorithm_t
159 * pk_algos,
161 pk_algos_length,
162 gnutls_retr_st *);
163 typedef int gnutls_certificate_server_retrieve_function (gnutls_session_t,
164 gnutls_retr_st *);
166 void gnutls_certificate_client_set_retrieve_function
167 (gnutls_certificate_credentials_t cred,
168 gnutls_certificate_client_retrieve_function *
169 func) _GNUTLS_GCC_ATTR_DEPRECATED;
170 void
171 gnutls_certificate_server_set_retrieve_function
172 (gnutls_certificate_credentials_t cred,
173 gnutls_certificate_server_retrieve_function *
174 func) _GNUTLS_GCC_ATTR_DEPRECATED;
176 /* External signing callback. No longer supported because it
177 * was deprecated by the PKCS #11 API or gnutls_privkey_import_ext. */
178 typedef int (*gnutls_sign_func) (gnutls_session_t session,
179 void *userdata,
180 gnutls_certificate_type_t cert_type,
181 const gnutls_datum_t * cert,
182 const gnutls_datum_t * hash,
183 gnutls_datum_t * signature);
185 void
186 gnutls_sign_callback_set (gnutls_session_t session,
187 gnutls_sign_func sign_func, void *userdata)
188 _GNUTLS_GCC_ATTR_DEPRECATED;
189 gnutls_sign_func
190 gnutls_sign_callback_get (gnutls_session_t session, void **userdata)
191 _GNUTLS_GCC_ATTR_DEPRECATED;
193 /* This is a very dangerous and error-prone function.
194 * Use gnutls_privkey_sign_hash() instead.
196 int gnutls_x509_privkey_sign_hash (gnutls_x509_privkey_t key,
197 const gnutls_datum_t * hash,
198 gnutls_datum_t * signature)
199 _GNUTLS_GCC_ATTR_DEPRECATED;
201 int gnutls_openpgp_privkey_sign_hash (gnutls_openpgp_privkey_t key,
202 const gnutls_datum_t * hash,
203 gnutls_datum_t * signature)
204 _GNUTLS_GCC_ATTR_DEPRECATED;
206 /* we support the gnutls_privkey_sign_data() instead.
208 int gnutls_x509_privkey_sign_data (gnutls_x509_privkey_t key,
209 gnutls_digest_algorithm_t digest,
210 unsigned int flags,
211 const gnutls_datum_t * data,
212 void *signature,
213 size_t * signature_size)
214 _GNUTLS_GCC_ATTR_DEPRECATED;
216 /* gnutls_pubkey_verify_data() */
217 int gnutls_x509_crt_verify_data (gnutls_x509_crt_t crt,
218 unsigned int flags,
219 const gnutls_datum_t * data,
220 const gnutls_datum_t * signature)
221 _GNUTLS_GCC_ATTR_DEPRECATED;
224 /* gnutls_pubkey_verify_hash() */
225 int gnutls_x509_crt_verify_hash (gnutls_x509_crt_t crt,
226 unsigned int flags,
227 const gnutls_datum_t * hash,
228 const gnutls_datum_t * signature)
229 _GNUTLS_GCC_ATTR_DEPRECATED;
231 /* gnutls_pubkey_get_verify_algorithm() */
232 int gnutls_x509_crt_get_verify_algorithm (gnutls_x509_crt_t crt,
233 const gnutls_datum_t * signature,
234 gnutls_digest_algorithm_t * hash)
235 _GNUTLS_GCC_ATTR_DEPRECATED;
237 /* gnutls_pubkey_get_preferred_hash_algorithm() */
238 int gnutls_x509_crt_get_preferred_hash_algorithm (gnutls_x509_crt_t crt,
239 gnutls_digest_algorithm_t
240 * hash,
241 unsigned int *mand)
242 _GNUTLS_GCC_ATTR_DEPRECATED;
244 /* gnutls_x509_crq_privkey_sign() */
245 int gnutls_x509_crq_sign (gnutls_x509_crq_t crq, gnutls_x509_privkey_t key)
246 _GNUTLS_GCC_ATTR_DEPRECATED;
250 /* gnutls_x509_crl_privkey_sign */
251 int gnutls_x509_crl_sign (gnutls_x509_crl_t crl,
252 gnutls_x509_crt_t issuer,
253 gnutls_x509_privkey_t issuer_key)
254 _GNUTLS_GCC_ATTR_DEPRECATED;
256 /* functions to set priority of cipher suites
258 int gnutls_cipher_set_priority (gnutls_session_t session, const int *list)
259 _GNUTLS_GCC_ATTR_DEPRECATED;
260 int gnutls_mac_set_priority (gnutls_session_t session, const int *list)
261 _GNUTLS_GCC_ATTR_DEPRECATED;
262 int gnutls_compression_set_priority (gnutls_session_t session,
263 const int *list)
264 _GNUTLS_GCC_ATTR_DEPRECATED;
265 int gnutls_kx_set_priority (gnutls_session_t session, const int *list)
266 _GNUTLS_GCC_ATTR_DEPRECATED;
267 int gnutls_protocol_set_priority (gnutls_session_t session,
268 const int *list)
269 _GNUTLS_GCC_ATTR_DEPRECATED;
270 int gnutls_certificate_type_set_priority (gnutls_session_t session,
271 const int *list)
272 _GNUTLS_GCC_ATTR_DEPRECATED;
274 /* RSA params
276 int gnutls_rsa_params_init (gnutls_rsa_params_t * rsa_params) _GNUTLS_GCC_ATTR_DEPRECATED;
277 void gnutls_rsa_params_deinit (gnutls_rsa_params_t rsa_params) _GNUTLS_GCC_ATTR_DEPRECATED;
278 int gnutls_rsa_params_cpy (gnutls_rsa_params_t dst,
279 gnutls_rsa_params_t src) _GNUTLS_GCC_ATTR_DEPRECATED;
280 int gnutls_rsa_params_import_raw (gnutls_rsa_params_t rsa_params,
281 const gnutls_datum_t * m,
282 const gnutls_datum_t * e,
283 const gnutls_datum_t * d,
284 const gnutls_datum_t * p,
285 const gnutls_datum_t * q,
286 const gnutls_datum_t * u);
287 int gnutls_rsa_params_generate2 (gnutls_rsa_params_t params,
288 unsigned int bits) _GNUTLS_GCC_ATTR_DEPRECATED;
289 int gnutls_rsa_params_export_raw (gnutls_rsa_params_t rsa,
290 gnutls_datum_t * m, gnutls_datum_t * e,
291 gnutls_datum_t * d, gnutls_datum_t * p,
292 gnutls_datum_t * q, gnutls_datum_t * u,
293 unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;
294 int gnutls_rsa_params_export_pkcs1 (gnutls_rsa_params_t params,
295 gnutls_x509_crt_fmt_t format,
296 unsigned char *params_data,
297 size_t * params_data_size) _GNUTLS_GCC_ATTR_DEPRECATED;
298 int gnutls_rsa_params_import_pkcs1 (gnutls_rsa_params_t params,
299 const gnutls_datum_t * pkcs1_params,
300 gnutls_x509_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;
302 int gnutls_rsa_export_get_pubkey (gnutls_session_t session,
303 gnutls_datum_t * exponent,
304 gnutls_datum_t * modulus) _GNUTLS_GCC_ATTR_DEPRECATED;
305 int gnutls_rsa_export_get_modulus_bits (gnutls_session_t session) _GNUTLS_GCC_ATTR_DEPRECATED;
306 int gnutls_set_default_export_priority (gnutls_session_t session) _GNUTLS_GCC_ATTR_DEPRECATED;
308 void
309 gnutls_certificate_set_rsa_export_params (gnutls_certificate_credentials_t
310 res,
311 gnutls_rsa_params_t rsa_params) _GNUTLS_GCC_ATTR_DEPRECATED;
313 #ifdef _ISOC99_SOURCE
314 /* we provide older functions for compatibility as inline functions that
315 * depend on gnutls_session_get_random. */
317 static inline const void *gnutls_session_get_server_random (gnutls_session_t session) _GNUTLS_GCC_ATTR_DEPRECATED
319 gnutls_datum_t rnd;
320 gnutls_session_get_random(session, NULL, &rnd);/*doc-skip*/
321 return rnd.data;
324 static inline const void *gnutls_session_get_client_random (gnutls_session_t session) _GNUTLS_GCC_ATTR_DEPRECATED
326 gnutls_datum_t rnd;
327 gnutls_session_get_random(session, &rnd, NULL);/*doc-skip*/
328 return rnd.data;
330 #endif
333 #ifdef __cplusplus
335 #endif
337 #endif /* _GNUTLS_COMPAT_H */