removed gnutls_x509_crt_get_verify_algorithm()
[gnutls:gnutls.git] / lib / includes / gnutls / compat.h
1 /*
2  * Copyright (C) 2008-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 /* Typedefs for more compatibility with older GnuTLS. */
24
25 #ifndef _GNUTLS_COMPAT_H
26 #define _GNUTLS_COMPAT_H
27
28 /* *INDENT-OFF* */
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 /* *INDENT-ON* */
33
34 #ifdef __GNUC__
35
36 #define _GNUTLS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
37
38 #if !defined GNUTLS_INTERNAL_BUILD
39 #if _GNUTLS_GCC_VERSION >= 30100
40 #define _GNUTLS_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
41 #endif
42 #endif
43
44 #endif                          /* __GNUC__ */
45
46 #ifndef _GNUTLS_GCC_ATTR_DEPRECATED
47 #define _GNUTLS_GCC_ATTR_DEPRECATED
48 #endif
49
50 /* gnutls_connection_end_t was made redundant in 2.99.0 */
51 typedef unsigned int gnutls_connection_end_t _GNUTLS_GCC_ATTR_DEPRECATED;
52
53 /* Stuff deprected in 2.x */
54 typedef gnutls_cipher_algorithm_t gnutls_cipher_algorithm
55     _GNUTLS_GCC_ATTR_DEPRECATED;
56 typedef gnutls_kx_algorithm_t gnutls_kx_algorithm
57     _GNUTLS_GCC_ATTR_DEPRECATED;
58 typedef gnutls_mac_algorithm_t gnutls_mac_algorithm
59     _GNUTLS_GCC_ATTR_DEPRECATED;
60 typedef gnutls_digest_algorithm_t gnutls_digest_algorithm
61     _GNUTLS_GCC_ATTR_DEPRECATED;
62 typedef gnutls_compression_method_t gnutls_compression_method
63     _GNUTLS_GCC_ATTR_DEPRECATED;
64 typedef gnutls_connection_end_t gnutls_connection_end
65     _GNUTLS_GCC_ATTR_DEPRECATED;
66 typedef gnutls_x509_crt_fmt_t gnutls_x509_crt_fmt
67     _GNUTLS_GCC_ATTR_DEPRECATED;
68 typedef gnutls_pk_algorithm_t gnutls_pk_algorithm
69     _GNUTLS_GCC_ATTR_DEPRECATED;
70 typedef gnutls_sign_algorithm_t gnutls_sign_algorithm
71     _GNUTLS_GCC_ATTR_DEPRECATED;
72 typedef gnutls_close_request_t gnutls_close_request
73     _GNUTLS_GCC_ATTR_DEPRECATED;
74 typedef gnutls_certificate_request_t gnutls_certificate_request
75     _GNUTLS_GCC_ATTR_DEPRECATED;
76 typedef gnutls_certificate_status_t gnutls_certificate_status
77     _GNUTLS_GCC_ATTR_DEPRECATED;
78 typedef gnutls_session_t gnutls_session _GNUTLS_GCC_ATTR_DEPRECATED;
79 typedef gnutls_alert_level_t gnutls_alert_level
80     _GNUTLS_GCC_ATTR_DEPRECATED;
81 typedef gnutls_alert_description_t gnutls_alert_description
82     _GNUTLS_GCC_ATTR_DEPRECATED;
83 typedef gnutls_x509_subject_alt_name_t gnutls_x509_subject_alt_name
84     _GNUTLS_GCC_ATTR_DEPRECATED;
85 typedef gnutls_openpgp_privkey_t gnutls_openpgp_privkey
86     _GNUTLS_GCC_ATTR_DEPRECATED;
87 typedef gnutls_openpgp_keyring_t gnutls_openpgp_keyring
88     _GNUTLS_GCC_ATTR_DEPRECATED;
89 typedef gnutls_x509_crt_t gnutls_x509_crt _GNUTLS_GCC_ATTR_DEPRECATED;
90 typedef gnutls_x509_privkey_t gnutls_x509_privkey
91     _GNUTLS_GCC_ATTR_DEPRECATED;
92 typedef gnutls_x509_crl_t gnutls_x509_crl _GNUTLS_GCC_ATTR_DEPRECATED;
93 typedef gnutls_x509_crq_t gnutls_x509_crq _GNUTLS_GCC_ATTR_DEPRECATED;
94 typedef gnutls_certificate_credentials_t
95     gnutls_certificate_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
96 typedef gnutls_anon_server_credentials_t
97     gnutls_anon_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
98 typedef gnutls_anon_client_credentials_t
99     gnutls_anon_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
100 typedef gnutls_srp_client_credentials_t
101     gnutls_srp_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
102 typedef gnutls_srp_server_credentials_t
103     gnutls_srp_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;
104 typedef gnutls_dh_params_t gnutls_dh_params _GNUTLS_GCC_ATTR_DEPRECATED;
105 typedef gnutls_rsa_params_t gnutls_rsa_params _GNUTLS_GCC_ATTR_DEPRECATED;
106 typedef gnutls_params_type_t gnutls_params_type
107     _GNUTLS_GCC_ATTR_DEPRECATED;
108 typedef gnutls_credentials_type_t gnutls_credentials_type
109     _GNUTLS_GCC_ATTR_DEPRECATED;
110 typedef gnutls_certificate_type_t gnutls_certificate_type
111     _GNUTLS_GCC_ATTR_DEPRECATED;
112 typedef gnutls_datum_t gnutls_datum _GNUTLS_GCC_ATTR_DEPRECATED;
113 typedef gnutls_transport_ptr_t gnutls_transport_ptr
114     _GNUTLS_GCC_ATTR_DEPRECATED;
115
116 /* Old verification flags */
117 #define GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT  (0)
118
119 /* Old SRP alerts removed in 2.1.x because the TLS-SRP RFC was
120    modified to use the PSK alert. */
121 #define GNUTLS_A_MISSING_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY
122 #define GNUTLS_A_UNKNOWN_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY
123
124 /* OpenPGP stuff renamed in 2.1.x. */
125 #define GNUTLS_OPENPGP_KEY GNUTLS_OPENPGP_CERT
126 #define GNUTLS_OPENPGP_KEY_FINGERPRINT GNUTLS_OPENPGP_CERT_FINGERPRINT
127 #define gnutls_openpgp_send_key gnutls_openpgp_send_cert
128 typedef gnutls_openpgp_crt_status_t gnutls_openpgp_key_status_t
129     _GNUTLS_GCC_ATTR_DEPRECATED;
130 typedef gnutls_openpgp_crt_t gnutls_openpgp_key_t
131     _GNUTLS_GCC_ATTR_DEPRECATED;
132 #define gnutls_openpgp_key_init gnutls_openpgp_crt_init
133 #define gnutls_openpgp_key_deinit gnutls_openpgp_crt_deinit
134 #define gnutls_openpgp_key_import gnutls_openpgp_crt_import
135 #define gnutls_openpgp_key_export gnutls_openpgp_crt_export
136 #define gnutls_openpgp_key_get_key_usage gnutls_openpgp_crt_get_key_usage
137 #define gnutls_openpgp_key_get_fingerprint gnutls_openpgp_crt_get_fingerprint
138 #define gnutls_openpgp_key_get_pk_algorithm gnutls_openpgp_crt_get_pk_algorithm
139 #define gnutls_openpgp_key_get_name gnutls_openpgp_crt_get_name
140 #define gnutls_openpgp_key_get_version gnutls_openpgp_crt_get_version
141 #define gnutls_openpgp_key_get_creation_time gnutls_openpgp_crt_get_creation_time
142 #define gnutls_openpgp_key_get_expiration_time gnutls_openpgp_crt_get_expiration_time
143 #define gnutls_openpgp_key_get_id gnutls_openpgp_crt_get_id
144 #define gnutls_openpgp_key_check_hostname gnutls_openpgp_crt_check_hostname
145
146 /* OpenPGP stuff renamed in 2.3.x. */
147 #define gnutls_openpgp_crt_get_id gnutls_openpgp_crt_get_key_id
148
149 /* New better names renamed in 2.3.x, add these for backwards
150    compatibility with old poor names.*/
151 #define GNUTLS_X509_CRT_FULL GNUTLS_CRT_PRINT_FULL
152 #define GNUTLS_X509_CRT_ONELINE GNUTLS_CRT_PRINT_ONELINE
153 #define GNUTLS_X509_CRT_UNSIGNED_FULL GNUTLS_CRT_PRINT_UNSIGNED_FULL
154
155 /* Namespace problems. */
156 #define LIBGNUTLS_VERSION GNUTLS_VERSION
157 #define LIBGNUTLS_VERSION_MAJOR GNUTLS_VERSION_MAJOR
158 #define LIBGNUTLS_VERSION_MINOR GNUTLS_VERSION_MINOR
159 #define LIBGNUTLS_VERSION_PATCH GNUTLS_VERSION_PATCH
160 #define LIBGNUTLS_VERSION_NUMBER GNUTLS_VERSION_NUMBER
161 #define LIBGNUTLS_EXTRA_VERSION GNUTLS_VERSION
162
163 /* This is a very dangerous and error-prone function.
164  * Use gnutls_privkey_sign_hash() instead.
165  */
166 int gnutls_x509_privkey_sign_hash(gnutls_x509_privkey_t key,
167                                   const gnutls_datum_t * hash,
168                                   gnutls_datum_t * signature)
169     _GNUTLS_GCC_ATTR_DEPRECATED;
170
171 int gnutls_openpgp_privkey_sign_hash(gnutls_openpgp_privkey_t key,
172                                      const gnutls_datum_t * hash,
173                                      gnutls_datum_t * signature)
174     _GNUTLS_GCC_ATTR_DEPRECATED;
175
176 /* we support the gnutls_privkey_sign_data() instead.
177  */
178 int gnutls_x509_privkey_sign_data(gnutls_x509_privkey_t key,
179                                   gnutls_digest_algorithm_t digest,
180                                   unsigned int flags,
181                                   const gnutls_datum_t * data,
182                                   void *signature,
183                                   size_t * signature_size)
184     _GNUTLS_GCC_ATTR_DEPRECATED;
185
186         /* gnutls_pubkey_get_preferred_hash_algorithm() */
187 int gnutls_x509_crt_get_preferred_hash_algorithm(gnutls_x509_crt_t
188                                                  crt,
189                                                  gnutls_digest_algorithm_t
190                                                  * hash, unsigned int
191                                                  *mand)
192     _GNUTLS_GCC_ATTR_DEPRECATED;
193
194         /* gnutls_x509_crq_privkey_sign() */
195 int gnutls_x509_crq_sign(gnutls_x509_crq_t crq,
196                          gnutls_x509_privkey_t key)
197     _GNUTLS_GCC_ATTR_DEPRECATED;
198
199
200
201         /* gnutls_x509_crl_privkey_sign */
202 int gnutls_x509_crl_sign(gnutls_x509_crl_t crl,
203                          gnutls_x509_crt_t issuer,
204                          gnutls_x509_privkey_t issuer_key)
205     _GNUTLS_GCC_ATTR_DEPRECATED;
206
207         /* use gnutls_privkey_sign_hash() with the GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA flag */
208 int gnutls_privkey_sign_raw_data(gnutls_privkey_t key,
209                                  unsigned flags,
210                                  const gnutls_datum_t * data,
211                                  gnutls_datum_t *
212                                  signature) _GNUTLS_GCC_ATTR_DEPRECATED;
213
214 #ifdef _ISOC99_SOURCE
215 /* we provide older functions for compatibility as inline functions that
216  * depend on gnutls_session_get_random. */
217
218 static inline const void
219 *gnutls_session_get_server_random(gnutls_session_t session)
220     _GNUTLS_GCC_ATTR_DEPRECATED;
221 static inline const void
222 *gnutls_session_get_server_random(gnutls_session_t session)
223 {
224         gnutls_datum_t rnd;
225         gnutls_session_get_random(session, NULL, &rnd); /*doc-skip */
226         return rnd.data;
227 }
228
229 static inline const void
230 *gnutls_session_get_client_random(gnutls_session_t session)
231     _GNUTLS_GCC_ATTR_DEPRECATED;
232 static inline const void
233 *gnutls_session_get_client_random(gnutls_session_t session)
234 {
235         gnutls_datum_t rnd;
236         gnutls_session_get_random(session, &rnd, NULL); /*doc-skip */
237         return rnd.data;
238 }
239 #endif
240
241 void
242 gnutls_global_set_mem_functions(gnutls_alloc_function alloc_func,
243                                 gnutls_alloc_function secure_alloc_func,
244                                 gnutls_is_secure_function is_secure_func,
245                                 gnutls_realloc_function realloc_func,
246                                 gnutls_free_function free_func) _GNUTLS_GCC_ATTR_DEPRECATED;
247
248 /* *INDENT-OFF* */
249 #ifdef __cplusplus
250 }
251 #endif
252 /* *INDENT-ON* */
253
254 #endif                          /* _GNUTLS_COMPAT_H */