| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
INCLUDES = """ |
| 7 |
#include <openssl/ssl.h> |
| 8 |
|
| 9 |
typedef STACK_OF(SSL_CIPHER) Cryptography_STACK_OF_SSL_CIPHER; |
| 10 |
""" |
| 11 |
|
| 12 |
TYPES = """ |
| 13 |
static const long Cryptography_HAS_SSL_ST; |
| 14 |
static const long Cryptography_HAS_TLS_ST; |
| 15 |
static const long Cryptography_HAS_SSL2; |
| 16 |
static const long Cryptography_HAS_SSL3_METHOD; |
| 17 |
static const long Cryptography_HAS_TLSv1_1; |
| 18 |
static const long Cryptography_HAS_TLSv1_2; |
| 19 |
static const long Cryptography_HAS_TLSv1_3; |
| 20 |
static const long Cryptography_HAS_SECURE_RENEGOTIATION; |
| 21 |
static const long Cryptography_HAS_COMPRESSION; |
| 22 |
static const long Cryptography_HAS_TLSEXT_STATUS_REQ_CB; |
| 23 |
static const long Cryptography_HAS_STATUS_REQ_OCSP_RESP; |
| 24 |
static const long Cryptography_HAS_TLSEXT_STATUS_REQ_TYPE; |
| 25 |
static const long Cryptography_HAS_SSL_CTX_SET_CLIENT_CERT_ENGINE; |
| 26 |
static const long Cryptography_HAS_SSL_CTX_CLEAR_OPTIONS; |
| 27 |
static const long Cryptography_HAS_DTLS; |
| 28 |
static const long Cryptography_HAS_GENERIC_DTLS_METHOD; |
| 29 |
static const long Cryptography_HAS_SIGALGS; |
| 30 |
static const long Cryptography_HAS_PSK; |
| 31 |
static const long Cryptography_HAS_CIPHER_DETAILS; |
| 32 |
static const long Cryptography_HAS_CTRL_GET_MAX_PROTO_VERSION; |
| 33 |
static const long Crytpography_HAS_OP_IGNORE_UNEXPECTED_EOF; |
| 34 |
|
| 35 |
/* Internally invented symbol to tell us if SNI is supported */ |
| 36 |
static const long Cryptography_HAS_TLSEXT_HOSTNAME; |
| 37 |
|
| 38 |
/* Internally invented symbol to tell us if SSL_MODE_RELEASE_BUFFERS is |
| 39 |
* supported |
| 40 |
*/ |
| 41 |
static const long Cryptography_HAS_RELEASE_BUFFERS; |
| 42 |
|
| 43 |
/* Internally invented symbol to tell us if SSL_OP_NO_COMPRESSION is |
| 44 |
* supported |
| 45 |
*/ |
| 46 |
static const long Cryptography_HAS_OP_NO_COMPRESSION; |
| 47 |
static const long Cryptography_HAS_SSL_OP_MSIE_SSLV2_RSA_PADDING; |
| 48 |
static const long Cryptography_HAS_SSL_SET_SSL_CTX; |
| 49 |
static const long Cryptography_HAS_SSL_OP_NO_TICKET; |
| 50 |
static const long Cryptography_HAS_ALPN; |
| 51 |
static const long Cryptography_HAS_NEXTPROTONEG; |
| 52 |
static const long Cryptography_HAS_SET_CERT_CB; |
| 53 |
static const long Cryptography_HAS_CUSTOM_EXT; |
| 54 |
|
| 55 |
static const long SSL_FILETYPE_PEM; |
| 56 |
static const long SSL_FILETYPE_ASN1; |
| 57 |
static const long SSL_ERROR_NONE; |
| 58 |
static const long SSL_ERROR_ZERO_RETURN; |
| 59 |
static const long SSL_ERROR_WANT_READ; |
| 60 |
static const long SSL_ERROR_WANT_WRITE; |
| 61 |
static const long SSL_ERROR_WANT_X509_LOOKUP; |
| 62 |
static const long SSL_ERROR_WANT_CONNECT; |
| 63 |
static const long SSL_ERROR_SYSCALL; |
| 64 |
static const long SSL_ERROR_SSL; |
| 65 |
static const long SSL_SENT_SHUTDOWN; |
| 66 |
static const long SSL_RECEIVED_SHUTDOWN; |
| 67 |
static const long SSL_OP_NO_SSLv2; |
| 68 |
static const long SSL_OP_NO_SSLv3; |
| 69 |
static const long SSL_OP_NO_TLSv1; |
| 70 |
static const long SSL_OP_NO_TLSv1_1; |
| 71 |
static const long SSL_OP_NO_TLSv1_2; |
| 72 |
static const long SSL_OP_NO_TLSv1_3; |
| 73 |
static const long SSL_OP_NO_DTLSv1; |
| 74 |
static const long SSL_OP_NO_DTLSv1_2; |
| 75 |
static const long SSL_OP_NO_COMPRESSION; |
| 76 |
static const long SSL_OP_SINGLE_DH_USE; |
| 77 |
static const long SSL_OP_EPHEMERAL_RSA; |
| 78 |
static const long SSL_OP_MICROSOFT_SESS_ID_BUG; |
| 79 |
static const long SSL_OP_NETSCAPE_CHALLENGE_BUG; |
| 80 |
static const long SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG; |
| 81 |
static const long SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG; |
| 82 |
static const long SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER; |
| 83 |
static const long SSL_OP_MSIE_SSLV2_RSA_PADDING; |
| 84 |
static const long SSL_OP_SSLEAY_080_CLIENT_DH_BUG; |
| 85 |
static const long SSL_OP_TLS_D5_BUG; |
| 86 |
static const long SSL_OP_TLS_BLOCK_PADDING_BUG; |
| 87 |
static const long SSL_OP_IGNORE_UNEXPECTED_EOF; |
| 88 |
static const long SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS; |
| 89 |
static const long SSL_OP_CIPHER_SERVER_PREFERENCE; |
| 90 |
static const long SSL_OP_TLS_ROLLBACK_BUG; |
| 91 |
static const long SSL_OP_PKCS1_CHECK_1; |
| 92 |
static const long SSL_OP_PKCS1_CHECK_2; |
| 93 |
static const long SSL_OP_NETSCAPE_CA_DN_BUG; |
| 94 |
static const long SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG; |
| 95 |
static const long SSL_OP_NO_QUERY_MTU; |
| 96 |
static const long SSL_OP_COOKIE_EXCHANGE; |
| 97 |
static const long SSL_OP_NO_TICKET; |
| 98 |
static const long SSL_OP_ALL; |
| 99 |
static const long SSL_OP_SINGLE_ECDH_USE; |
| 100 |
static const long SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION; |
| 101 |
static const long SSL_OP_LEGACY_SERVER_CONNECT; |
| 102 |
static const long SSL_VERIFY_PEER; |
| 103 |
static const long SSL_VERIFY_FAIL_IF_NO_PEER_CERT; |
| 104 |
static const long SSL_VERIFY_CLIENT_ONCE; |
| 105 |
static const long SSL_VERIFY_NONE; |
| 106 |
static const long SSL_VERIFY_POST_HANDSHAKE; |
| 107 |
static const long SSL_SESS_CACHE_OFF; |
| 108 |
static const long SSL_SESS_CACHE_CLIENT; |
| 109 |
static const long SSL_SESS_CACHE_SERVER; |
| 110 |
static const long SSL_SESS_CACHE_BOTH; |
| 111 |
static const long SSL_SESS_CACHE_NO_AUTO_CLEAR; |
| 112 |
static const long SSL_SESS_CACHE_NO_INTERNAL_LOOKUP; |
| 113 |
static const long SSL_SESS_CACHE_NO_INTERNAL_STORE; |
| 114 |
static const long SSL_SESS_CACHE_NO_INTERNAL; |
| 115 |
static const long SSL_ST_CONNECT; |
| 116 |
static const long SSL_ST_ACCEPT; |
| 117 |
static const long SSL_ST_MASK; |
| 118 |
static const long SSL_ST_INIT; |
| 119 |
static const long SSL_ST_BEFORE; |
| 120 |
static const long SSL_ST_OK; |
| 121 |
static const long SSL_ST_RENEGOTIATE; |
| 122 |
static const long SSL_CB_LOOP; |
| 123 |
static const long SSL_CB_EXIT; |
| 124 |
static const long SSL_CB_READ; |
| 125 |
static const long SSL_CB_WRITE; |
| 126 |
static const long SSL_CB_ALERT; |
| 127 |
static const long SSL_CB_READ_ALERT; |
| 128 |
static const long SSL_CB_WRITE_ALERT; |
| 129 |
static const long SSL_CB_ACCEPT_LOOP; |
| 130 |
static const long SSL_CB_ACCEPT_EXIT; |
| 131 |
static const long SSL_CB_CONNECT_LOOP; |
| 132 |
static const long SSL_CB_CONNECT_EXIT; |
| 133 |
static const long SSL_CB_HANDSHAKE_START; |
| 134 |
static const long SSL_CB_HANDSHAKE_DONE; |
| 135 |
static const long SSL_MODE_RELEASE_BUFFERS; |
| 136 |
static const long SSL_MODE_ENABLE_PARTIAL_WRITE; |
| 137 |
static const long SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER; |
| 138 |
static const long SSL_MODE_AUTO_RETRY; |
| 139 |
static const long SSL3_RANDOM_SIZE; |
| 140 |
static const long TLS_ST_BEFORE; |
| 141 |
static const long TLS_ST_OK; |
| 142 |
|
| 143 |
static const long OPENSSL_NPN_NEGOTIATED; |
| 144 |
|
| 145 |
static const long SSL3_VERSION; |
| 146 |
static const long TLS1_VERSION; |
| 147 |
static const long TLS1_1_VERSION; |
| 148 |
static const long TLS1_2_VERSION; |
| 149 |
|
| 150 |
static const long SSL3_RT_CHANGE_CIPHER_SPEC; |
| 151 |
static const long SSL3_RT_ALERT; |
| 152 |
static const long SSL3_RT_HANDSHAKE; |
| 153 |
static const long SSL3_RT_APPLICATION_DATA; |
| 154 |
|
| 155 |
static const long SSL3_RT_HEADER; |
| 156 |
static const long SSL3_RT_INNER_CONTENT_TYPE; |
| 157 |
|
| 158 |
static const long SSL3_MT_CHANGE_CIPHER_SPEC; |
| 159 |
|
| 160 |
typedef ... SSL_METHOD; |
| 161 |
typedef ... SSL_CTX; |
| 162 |
|
| 163 |
typedef ... SSL_SESSION; |
| 164 |
|
| 165 |
typedef ... SSL; |
| 166 |
|
| 167 |
static const long TLSEXT_NAMETYPE_host_name; |
| 168 |
static const long TLSEXT_STATUSTYPE_ocsp; |
| 169 |
|
| 170 |
typedef ... SSL_CIPHER; |
| 171 |
typedef ... Cryptography_STACK_OF_SSL_CIPHER; |
| 172 |
typedef ... COMP_METHOD; |
| 173 |
|
| 174 |
typedef struct { |
| 175 |
const char *name; |
| 176 |
unsigned long id; |
| 177 |
} SRTP_PROTECTION_PROFILE; |
| 178 |
static const long Cryptography_HAS_X509_CHECK_FLAG_NEVER_CHECK_SUBJECT; |
| 179 |
""" |
| 180 |
|
| 181 |
FUNCTIONS = """ |
| 182 |
/* SSL */ |
| 183 |
const char *SSL_state_string_long(const SSL *); |
| 184 |
SSL_SESSION *SSL_get1_session(SSL *); |
| 185 |
int SSL_set_session(SSL *, SSL_SESSION *); |
| 186 |
int (*SSL_get_verify_callback(const SSL *))(int, X509_STORE_CTX *); |
| 187 |
SSL *SSL_new(SSL_CTX *); |
| 188 |
void SSL_free(SSL *); |
| 189 |
int SSL_set_fd(SSL *, int); |
| 190 |
SSL_CTX *SSL_set_SSL_CTX(SSL *, SSL_CTX *); |
| 191 |
BIO *SSL_get_rbio(const SSL *); |
| 192 |
BIO *SSL_get_wbio(const SSL *); |
| 193 |
void SSL_set_bio(SSL *, BIO *, BIO *); |
| 194 |
void SSL_set_connect_state(SSL *); |
| 195 |
void SSL_set_accept_state(SSL *); |
| 196 |
void SSL_set_shutdown(SSL *, int); |
| 197 |
int SSL_get_shutdown(const SSL *); |
| 198 |
int SSL_pending(const SSL *); |
| 199 |
int SSL_write(SSL *, const void *, int); |
| 200 |
int SSL_write_ex(SSL *, const void *, size_t, size_t *); |
| 201 |
int SSL_read(SSL *, void *, int); |
| 202 |
int SSL_read_ex(SSL *, void *, size_t, size_t *); |
| 203 |
int SSL_peek(SSL *, void *, int); |
| 204 |
X509 *SSL_get_certificate(const SSL *); |
| 205 |
X509 *SSL_get_peer_certificate(const SSL *); |
| 206 |
int SSL_get_ex_data_X509_STORE_CTX_idx(void); |
| 207 |
void SSL_set_verify(SSL *, int, int (*)(int, X509_STORE_CTX *)); |
| 208 |
int SSL_get_verify_mode(const SSL *); |
| 209 |
|
| 210 |
/* Added in 1.0.2 */ |
| 211 |
X509_VERIFY_PARAM *SSL_get0_param(SSL *); |
| 212 |
X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *); |
| 213 |
|
| 214 |
int SSL_use_certificate(SSL *, X509 *); |
| 215 |
int SSL_use_certificate_ASN1(SSL *, const unsigned char *, int); |
| 216 |
int SSL_use_certificate_file(SSL *, const char *, int); |
| 217 |
int SSL_use_PrivateKey(SSL *, EVP_PKEY *); |
| 218 |
int SSL_use_PrivateKey_ASN1(int, SSL *, const unsigned char *, long); |
| 219 |
int SSL_use_PrivateKey_file(SSL *, const char *, int); |
| 220 |
int SSL_check_private_key(const SSL *); |
| 221 |
|
| 222 |
int SSL_get_sigalgs(SSL *, int, int *, int *, int *, unsigned char *, |
| 223 |
unsigned char *); |
| 224 |
|
| 225 |
Cryptography_STACK_OF_X509 *SSL_get_peer_cert_chain(const SSL *); |
| 226 |
Cryptography_STACK_OF_X509 *SSL_get0_verified_chain(const SSL *); |
| 227 |
Cryptography_STACK_OF_X509_NAME *SSL_get_client_CA_list(const SSL *); |
| 228 |
|
| 229 |
int SSL_get_error(const SSL *, int); |
| 230 |
long SSL_get_verify_result(const SSL *ssl); |
| 231 |
int SSL_do_handshake(SSL *); |
| 232 |
int SSL_shutdown(SSL *); |
| 233 |
int SSL_renegotiate(SSL *); |
| 234 |
int SSL_renegotiate_pending(SSL *); |
| 235 |
int SSL_is_init_finished(SSL *s); |
| 236 |
const char *SSL_get_cipher_list(const SSL *, int); |
| 237 |
Cryptography_STACK_OF_SSL_CIPHER *SSL_get_ciphers(const SSL *); |
| 238 |
Cryptography_STACK_OF_SSL_CIPHER *SSL_get_client_ciphers(const SSL *); |
| 239 |
|
| 240 |
/* context */ |
| 241 |
void SSL_CTX_free(SSL_CTX *); |
| 242 |
long SSL_CTX_set_timeout(SSL_CTX *, long); |
| 243 |
int SSL_CTX_set_default_verify_paths(SSL_CTX *); |
| 244 |
void SSL_CTX_set_verify(SSL_CTX *, int, int (*)(int, X509_STORE_CTX *)); |
| 245 |
void SSL_CTX_set_verify_depth(SSL_CTX *, int); |
| 246 |
int (*SSL_CTX_get_verify_callback(const SSL_CTX *))(int, X509_STORE_CTX *); |
| 247 |
int SSL_CTX_get_verify_mode(const SSL_CTX *); |
| 248 |
int SSL_CTX_get_verify_depth(const SSL_CTX *); |
| 249 |
int SSL_CTX_set_cipher_list(SSL_CTX *, const char *); |
| 250 |
int SSL_CTX_load_verify_locations(SSL_CTX *, const char *, const char *); |
| 251 |
void SSL_CTX_set_default_passwd_cb(SSL_CTX *, pem_password_cb *); |
| 252 |
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *, void *); |
| 253 |
pem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx); |
| 254 |
void *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx); |
| 255 |
int SSL_CTX_use_certificate(SSL_CTX *, X509 *); |
| 256 |
int SSL_CTX_use_certificate_ASN1(SSL_CTX *, int, const unsigned char *); |
| 257 |
int SSL_CTX_use_certificate_file(SSL_CTX *, const char *, int); |
| 258 |
int SSL_CTX_use_certificate_chain_file(SSL_CTX *, const char *); |
| 259 |
int SSL_CTX_use_PrivateKey(SSL_CTX *, EVP_PKEY *); |
| 260 |
int SSL_CTX_use_PrivateKey_ASN1(int, SSL_CTX *, const unsigned char *, long); |
| 261 |
int SSL_CTX_use_PrivateKey_file(SSL_CTX *, const char *, int); |
| 262 |
int SSL_CTX_check_private_key(const SSL_CTX *); |
| 263 |
void SSL_CTX_set_cert_verify_callback(SSL_CTX *, |
| 264 |
int (*)(X509_STORE_CTX *, void *), |
| 265 |
void *); |
| 266 |
|
| 267 |
void SSL_CTX_set_cookie_generate_cb(SSL_CTX *, |
| 268 |
int (*)( |
| 269 |
SSL *, |
| 270 |
unsigned char *, |
| 271 |
unsigned int * |
| 272 |
)); |
| 273 |
long SSL_CTX_get_read_ahead(SSL_CTX *); |
| 274 |
long SSL_CTX_set_read_ahead(SSL_CTX *, long); |
| 275 |
|
| 276 |
int SSL_CTX_use_psk_identity_hint(SSL_CTX *, const char *); |
| 277 |
void SSL_CTX_set_psk_server_callback(SSL_CTX *, |
| 278 |
unsigned int (*)( |
| 279 |
SSL *, |
| 280 |
const char *, |
| 281 |
unsigned char *, |
| 282 |
unsigned int |
| 283 |
)); |
| 284 |
void SSL_CTX_set_psk_client_callback(SSL_CTX *, |
| 285 |
unsigned int (*)( |
| 286 |
SSL *, |
| 287 |
const char *, |
| 288 |
char *, |
| 289 |
unsigned int, |
| 290 |
unsigned char *, |
| 291 |
unsigned int |
| 292 |
)); |
| 293 |
|
| 294 |
int SSL_CTX_set_session_id_context(SSL_CTX *, const unsigned char *, |
| 295 |
unsigned int); |
| 296 |
|
| 297 |
void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *); |
| 298 |
X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); |
| 299 |
int SSL_CTX_add_client_CA(SSL_CTX *, X509 *); |
| 300 |
|
| 301 |
void SSL_CTX_set_client_CA_list(SSL_CTX *, Cryptography_STACK_OF_X509_NAME *); |
| 302 |
|
| 303 |
void SSL_CTX_set_info_callback(SSL_CTX *, void (*)(const SSL *, int, int)); |
| 304 |
void (*SSL_CTX_get_info_callback(SSL_CTX *))(const SSL *, int, int); |
| 305 |
|
| 306 |
long SSL_CTX_set1_sigalgs_list(SSL_CTX *, const char *); |
| 307 |
typedef void (*SSL_CTX_keylog_cb_func)(const SSL *ssl, const char *line); |
| 308 |
void SSL_CTX_set_keylog_callback(SSL_CTX *ctx, SSL_CTX_keylog_cb_func cb); |
| 309 |
|
| 310 |
|
| 311 |
/* SSL_SESSION */ |
| 312 |
void SSL_SESSION_free(SSL_SESSION *); |
| 313 |
|
| 314 |
/* Information about actually used cipher */ |
| 315 |
const char *SSL_CIPHER_get_name(const SSL_CIPHER *); |
| 316 |
int SSL_CIPHER_get_bits(const SSL_CIPHER *, int *); |
| 317 |
/* the modern signature of this is uint32_t, but older openssl declared it |
| 318 |
as unsigned long. To make our compiler flags happy we'll declare it as a |
| 319 |
64-bit wide value, which should always be safe */ |
| 320 |
uint64_t SSL_CIPHER_get_id(const SSL_CIPHER *); |
| 321 |
int SSL_CIPHER_is_aead(const SSL_CIPHER *); |
| 322 |
int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *); |
| 323 |
int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *); |
| 324 |
int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *); |
| 325 |
int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *); |
| 326 |
|
| 327 |
size_t SSL_get_finished(const SSL *, void *, size_t); |
| 328 |
size_t SSL_get_peer_finished(const SSL *, void *, size_t); |
| 329 |
Cryptography_STACK_OF_X509_NAME *SSL_load_client_CA_file(const char *); |
| 330 |
|
| 331 |
const char *SSL_get_servername(const SSL *, const int); |
| 332 |
/* Function signature changed to const char * in 1.1.0 */ |
| 333 |
const char *SSL_CIPHER_get_version(const SSL_CIPHER *); |
| 334 |
/* These became macros in 1.1.0 */ |
| 335 |
int SSL_library_init(void); |
| 336 |
void SSL_load_error_strings(void); |
| 337 |
|
| 338 |
/* these CRYPTO_EX_DATA functions became macros in 1.1.0 */ |
| 339 |
int SSL_get_ex_new_index(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup *, |
| 340 |
CRYPTO_EX_free *); |
| 341 |
int SSL_set_ex_data(SSL *, int, void *); |
| 342 |
int SSL_CTX_get_ex_new_index(long, void *, CRYPTO_EX_new *, CRYPTO_EX_dup *, |
| 343 |
CRYPTO_EX_free *); |
| 344 |
int SSL_CTX_set_ex_data(SSL_CTX *, int, void *); |
| 345 |
|
| 346 |
SSL_SESSION *SSL_get_session(const SSL *); |
| 347 |
const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *, unsigned int *); |
| 348 |
long SSL_SESSION_get_time(const SSL_SESSION *); |
| 349 |
long SSL_SESSION_get_timeout(const SSL_SESSION *); |
| 350 |
int SSL_SESSION_has_ticket(const SSL_SESSION *); |
| 351 |
long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *); |
| 352 |
|
| 353 |
/* not a macro, but older OpenSSLs don't pass the args as const */ |
| 354 |
char *SSL_CIPHER_description(const SSL_CIPHER *, char *, int); |
| 355 |
int SSL_SESSION_print(BIO *, const SSL_SESSION *); |
| 356 |
|
| 357 |
/* not macros, but will be conditionally bound so can't live in functions */ |
| 358 |
const COMP_METHOD *SSL_get_current_compression(SSL *); |
| 359 |
const COMP_METHOD *SSL_get_current_expansion(SSL *); |
| 360 |
const char *SSL_COMP_get_name(const COMP_METHOD *); |
| 361 |
|
| 362 |
unsigned long SSL_set_mode(SSL *, unsigned long); |
| 363 |
unsigned long SSL_clear_mode(SSL *, unsigned long); |
| 364 |
unsigned long SSL_get_mode(SSL *); |
| 365 |
|
| 366 |
unsigned long SSL_set_options(SSL *, unsigned long); |
| 367 |
unsigned long SSL_get_options(SSL *); |
| 368 |
|
| 369 |
void SSL_set_app_data(SSL *, char *); |
| 370 |
char * SSL_get_app_data(SSL *); |
| 371 |
void SSL_set_read_ahead(SSL *, int); |
| 372 |
|
| 373 |
int SSL_want_read(const SSL *); |
| 374 |
int SSL_want_write(const SSL *); |
| 375 |
|
| 376 |
long SSL_total_renegotiations(SSL *); |
| 377 |
long SSL_get_secure_renegotiation_support(SSL *); |
| 378 |
|
| 379 |
/* Defined as unsigned long because SSL_OP_ALL is greater than signed 32-bit |
| 380 |
and Windows defines long as 32-bit. */ |
| 381 |
unsigned long SSL_CTX_set_options(SSL_CTX *, unsigned long); |
| 382 |
unsigned long SSL_CTX_clear_options(SSL_CTX *, unsigned long); |
| 383 |
unsigned long SSL_CTX_get_options(SSL_CTX *); |
| 384 |
unsigned long SSL_CTX_set_mode(SSL_CTX *, unsigned long); |
| 385 |
unsigned long SSL_CTX_get_mode(SSL_CTX *); |
| 386 |
unsigned long SSL_CTX_set_session_cache_mode(SSL_CTX *, unsigned long); |
| 387 |
unsigned long SSL_CTX_get_session_cache_mode(SSL_CTX *); |
| 388 |
unsigned long SSL_CTX_set_tmp_dh(SSL_CTX *, DH *); |
| 389 |
unsigned long SSL_CTX_set_tmp_ecdh(SSL_CTX *, EC_KEY *); |
| 390 |
unsigned long SSL_CTX_add_extra_chain_cert(SSL_CTX *, X509 *); |
| 391 |
|
| 392 |
/*- These aren't macros these functions are all const X on openssl > 1.0.x -*/ |
| 393 |
|
| 394 |
/* methods */ |
| 395 |
|
| 396 |
/* |
| 397 |
* TLSv1_1 and TLSv1_2 are recent additions. Only sufficiently new versions of |
| 398 |
* OpenSSL support them. |
| 399 |
*/ |
| 400 |
const SSL_METHOD *TLSv1_method(void); |
| 401 |
const SSL_METHOD *TLSv1_1_method(void); |
| 402 |
const SSL_METHOD *TLSv1_2_method(void); |
| 403 |
|
| 404 |
const SSL_METHOD *SSLv3_method(void); |
| 405 |
const SSL_METHOD *SSLv3_server_method(void); |
| 406 |
const SSL_METHOD *SSLv3_client_method(void); |
| 407 |
|
| 408 |
|
| 409 |
/* Added in 1.0.2 */ |
| 410 |
const SSL_METHOD *DTLS_method(void); |
| 411 |
const SSL_METHOD *DTLS_server_method(void); |
| 412 |
const SSL_METHOD *DTLS_client_method(void); |
| 413 |
|
| 414 |
const SSL_METHOD *SSLv23_method(void); |
| 415 |
const SSL_METHOD *SSLv23_server_method(void); |
| 416 |
const SSL_METHOD *SSLv23_client_method(void); |
| 417 |
|
| 418 |
const SSL_METHOD *TLS_method(void); |
| 419 |
const SSL_METHOD *TLS_server_method(void); |
| 420 |
const SSL_METHOD *TLS_client_method(void); |
| 421 |
|
| 422 |
/*- These aren't macros these arguments are all const X on openssl > 1.0.x -*/ |
| 423 |
SSL_CTX *SSL_CTX_new(SSL_METHOD *); |
| 424 |
long SSL_CTX_get_timeout(const SSL_CTX *); |
| 425 |
|
| 426 |
const SSL_CIPHER *SSL_get_current_cipher(const SSL *); |
| 427 |
const char *SSL_get_version(const SSL *); |
| 428 |
int SSL_version(const SSL *); |
| 429 |
|
| 430 |
void *SSL_CTX_get_ex_data(const SSL_CTX *, int); |
| 431 |
void *SSL_get_ex_data(const SSL *, int); |
| 432 |
|
| 433 |
int SSL_set_tlsext_host_name(SSL *, char *); |
| 434 |
void SSL_CTX_set_tlsext_servername_callback( |
| 435 |
SSL_CTX *, |
| 436 |
int (*)(SSL *, int *, void *)); |
| 437 |
void SSL_CTX_set_tlsext_servername_arg( |
| 438 |
SSL_CTX *, void *); |
| 439 |
|
| 440 |
long SSL_set_tlsext_status_ocsp_resp(SSL *, unsigned char *, int); |
| 441 |
long SSL_get_tlsext_status_ocsp_resp(SSL *, const unsigned char **); |
| 442 |
long SSL_set_tlsext_status_type(SSL *, long); |
| 443 |
long SSL_CTX_set_tlsext_status_cb(SSL_CTX *, int(*)(SSL *, void *)); |
| 444 |
long SSL_CTX_set_tlsext_status_arg(SSL_CTX *, void *); |
| 445 |
|
| 446 |
int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *, const char *); |
| 447 |
int SSL_set_tlsext_use_srtp(SSL *, const char *); |
| 448 |
SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *); |
| 449 |
|
| 450 |
long SSL_session_reused(SSL *); |
| 451 |
|
| 452 |
void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *, |
| 453 |
int (*)(SSL *, |
| 454 |
const unsigned char **, |
| 455 |
unsigned int *, |
| 456 |
void *), |
| 457 |
void *); |
| 458 |
void SSL_CTX_set_next_proto_select_cb(SSL_CTX *, |
| 459 |
int (*)(SSL *, |
| 460 |
unsigned char **, |
| 461 |
unsigned char *, |
| 462 |
const unsigned char *, |
| 463 |
unsigned int, |
| 464 |
void *), |
| 465 |
void *); |
| 466 |
int SSL_select_next_proto(unsigned char **, unsigned char *, |
| 467 |
const unsigned char *, unsigned int, |
| 468 |
const unsigned char *, unsigned int); |
| 469 |
void SSL_get0_next_proto_negotiated(const SSL *, |
| 470 |
const unsigned char **, unsigned *); |
| 471 |
|
| 472 |
int sk_SSL_CIPHER_num(Cryptography_STACK_OF_SSL_CIPHER *); |
| 473 |
const SSL_CIPHER *sk_SSL_CIPHER_value(Cryptography_STACK_OF_SSL_CIPHER *, int); |
| 474 |
int sk_SSL_CIPHER_find(Cryptography_STACK_OF_SSL_CIPHER *, const SSL_CIPHER *); |
| 475 |
|
| 476 |
/* ALPN APIs were introduced in OpenSSL 1.0.2. To continue to support earlier |
| 477 |
* versions some special handling of these is necessary. |
| 478 |
*/ |
| 479 |
int SSL_CTX_set_alpn_protos(SSL_CTX *, const unsigned char *, unsigned); |
| 480 |
int SSL_set_alpn_protos(SSL *, const unsigned char *, unsigned); |
| 481 |
void SSL_CTX_set_alpn_select_cb(SSL_CTX *, |
| 482 |
int (*) (SSL *, |
| 483 |
const unsigned char **, |
| 484 |
unsigned char *, |
| 485 |
const unsigned char *, |
| 486 |
unsigned int, |
| 487 |
void *), |
| 488 |
void *); |
| 489 |
void SSL_get0_alpn_selected(const SSL *, const unsigned char **, unsigned *); |
| 490 |
|
| 491 |
long SSL_get_server_tmp_key(SSL *, EVP_PKEY **); |
| 492 |
|
| 493 |
/* SSL_CTX_set_cert_cb is introduced in OpenSSL 1.0.2. To continue to support |
| 494 |
* earlier versions some special handling of these is necessary. |
| 495 |
*/ |
| 496 |
void SSL_CTX_set_cert_cb(SSL_CTX *, int (*)(SSL *, void *), void *); |
| 497 |
void SSL_set_cert_cb(SSL *, int (*)(SSL *, void *), void *); |
| 498 |
|
| 499 |
/* Added in 1.0.2 */ |
| 500 |
const SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *); |
| 501 |
|
| 502 |
int SSL_SESSION_set1_id_context(SSL_SESSION *, const unsigned char *, |
| 503 |
unsigned int); |
| 504 |
/* Added in 1.1.0 for the great opaquing of structs */ |
| 505 |
size_t SSL_SESSION_get_master_key(const SSL_SESSION *, unsigned char *, |
| 506 |
size_t); |
| 507 |
size_t SSL_get_client_random(const SSL *, unsigned char *, size_t); |
| 508 |
size_t SSL_get_server_random(const SSL *, unsigned char *, size_t); |
| 509 |
int SSL_export_keying_material(SSL *, unsigned char *, size_t, const char *, |
| 510 |
size_t, const unsigned char *, size_t, int); |
| 511 |
|
| 512 |
long SSL_CTX_sess_number(SSL_CTX *); |
| 513 |
long SSL_CTX_sess_connect(SSL_CTX *); |
| 514 |
long SSL_CTX_sess_connect_good(SSL_CTX *); |
| 515 |
long SSL_CTX_sess_connect_renegotiate(SSL_CTX *); |
| 516 |
long SSL_CTX_sess_accept(SSL_CTX *); |
| 517 |
long SSL_CTX_sess_accept_good(SSL_CTX *); |
| 518 |
long SSL_CTX_sess_accept_renegotiate(SSL_CTX *); |
| 519 |
long SSL_CTX_sess_hits(SSL_CTX *); |
| 520 |
long SSL_CTX_sess_cb_hits(SSL_CTX *); |
| 521 |
long SSL_CTX_sess_misses(SSL_CTX *); |
| 522 |
long SSL_CTX_sess_timeouts(SSL_CTX *); |
| 523 |
long SSL_CTX_sess_cache_full(SSL_CTX *); |
| 524 |
|
| 525 |
/* DTLS support */ |
| 526 |
long Cryptography_DTLSv1_get_timeout(SSL *, time_t *, long *); |
| 527 |
long DTLSv1_handle_timeout(SSL *); |
| 528 |
long DTLS_set_link_mtu(SSL *, long); |
| 529 |
long DTLS_get_link_min_mtu(SSL *); |
| 530 |
|
| 531 |
/* Custom extensions. */ |
| 532 |
typedef int (*custom_ext_add_cb)(SSL *, unsigned int, |
| 533 |
const unsigned char **, |
| 534 |
size_t *, int *, |
| 535 |
void *); |
| 536 |
|
| 537 |
typedef void (*custom_ext_free_cb)(SSL *, unsigned int, |
| 538 |
const unsigned char *, |
| 539 |
void *); |
| 540 |
|
| 541 |
typedef int (*custom_ext_parse_cb)(SSL *, unsigned int, |
| 542 |
const unsigned char *, |
| 543 |
size_t, int *, |
| 544 |
void *); |
| 545 |
|
| 546 |
int SSL_CTX_add_client_custom_ext(SSL_CTX *, unsigned int, |
| 547 |
custom_ext_add_cb, |
| 548 |
custom_ext_free_cb, void *, |
| 549 |
custom_ext_parse_cb, |
| 550 |
void *); |
| 551 |
|
| 552 |
int SSL_CTX_add_server_custom_ext(SSL_CTX *, unsigned int, |
| 553 |
custom_ext_add_cb, |
| 554 |
custom_ext_free_cb, void *, |
| 555 |
custom_ext_parse_cb, |
| 556 |
void *); |
| 557 |
|
| 558 |
int SSL_extension_supported(unsigned int); |
| 559 |
|
| 560 |
int SSL_CTX_set_ciphersuites(SSL_CTX *, const char *); |
| 561 |
int SSL_verify_client_post_handshake(SSL *); |
| 562 |
void SSL_CTX_set_post_handshake_auth(SSL_CTX *, int); |
| 563 |
void SSL_set_post_handshake_auth(SSL *, int); |
| 564 |
|
| 565 |
|
| 566 |
uint32_t SSL_SESSION_get_max_early_data(const SSL_SESSION *); |
| 567 |
int SSL_write_early_data(SSL *, const void *, size_t, size_t *); |
| 568 |
int SSL_read_early_data(SSL *, void *, size_t, size_t *); |
| 569 |
int SSL_CTX_set_max_early_data(SSL_CTX *, uint32_t); |
| 570 |
|
| 571 |
|
| 572 |
int SSL_CTX_set_min_proto_version(SSL_CTX *ctx, int version); |
| 573 |
int SSL_CTX_set_max_proto_version(SSL_CTX *ctx, int version); |
| 574 |
int SSL_CTX_get_min_proto_version(SSL_CTX *ctx); |
| 575 |
int SSL_CTX_get_max_proto_version(SSL_CTX *ctx); |
| 576 |
|
| 577 |
int SSL_set_min_proto_version(SSL *ssl, int version); |
| 578 |
int SSL_set_max_proto_version(SSL *ssl, int version); |
| 579 |
int SSL_get_min_proto_version(SSL *ssl); |
| 580 |
int SSL_get_max_proto_version(SSL *ssl); |
| 581 |
|
| 582 |
ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); |
| 583 |
|
| 584 |
int SSL_set_num_tickets(SSL *s, size_t num_tickets); |
| 585 |
size_t SSL_get_num_tickets(const SSL *s); |
| 586 |
int SSL_CTX_set_num_tickets(SSL_CTX *ctx, size_t num_tickets); |
| 587 |
size_t SSL_CTX_get_num_tickets(const SSL_CTX *ctx); |
| 588 |
void SSL_CTX_set_msg_callback(SSL_CTX *ctx, |
| 589 |
void (*cb) (int write_p, int version, |
| 590 |
int content_type, const void *buf, |
| 591 |
size_t len, SSL *ssl, void *arg)); |
| 592 |
void SSL_set_msg_callback(SSL *ssl, |
| 593 |
void (*cb) (int write_p, int version, |
| 594 |
int content_type, const void *buf, |
| 595 |
size_t len, SSL *ssl, void *arg)); |
| 596 |
""" |
| 597 |
|
| 598 |
CUSTOMIZATIONS = """ |
| 599 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 |
| 600 |
#error Python 3.7 requires OpenSSL >= 1.0.2 |
| 601 |
#endif |
| 602 |
|
| 603 |
/* Added in 1.0.2 but we need it in all versions now due to the great |
| 604 |
opaquing. */ |
| 605 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 |
| 606 |
/* from ssl/ssl_lib.c */ |
| 607 |
const SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx) { |
| 608 |
return ctx->method; |
| 609 |
} |
| 610 |
#endif |
| 611 |
|
| 612 |
/* Added in 1.1.0 in the great opaquing, but we need to define it for older |
| 613 |
OpenSSLs. Such is our burden. */ |
| 614 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 && !CRYPTOGRAPHY_LIBRESSL_27_OR_GREATER |
| 615 |
/* from ssl/ssl_lib.c */ |
| 616 |
size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, size_t outlen) |
| 617 |
{ |
| 618 |
if (outlen == 0) |
| 619 |
return sizeof(ssl->s3->client_random); |
| 620 |
if (outlen > sizeof(ssl->s3->client_random)) |
| 621 |
outlen = sizeof(ssl->s3->client_random); |
| 622 |
memcpy(out, ssl->s3->client_random, outlen); |
| 623 |
return outlen; |
| 624 |
} |
| 625 |
/* Added in 1.1.0 as well */ |
| 626 |
/* from ssl/ssl_lib.c */ |
| 627 |
size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, size_t outlen) |
| 628 |
{ |
| 629 |
if (outlen == 0) |
| 630 |
return sizeof(ssl->s3->server_random); |
| 631 |
if (outlen > sizeof(ssl->s3->server_random)) |
| 632 |
outlen = sizeof(ssl->s3->server_random); |
| 633 |
memcpy(out, ssl->s3->server_random, outlen); |
| 634 |
return outlen; |
| 635 |
} |
| 636 |
/* Added in 1.1.0 as well */ |
| 637 |
/* from ssl/ssl_lib.c */ |
| 638 |
size_t SSL_SESSION_get_master_key(const SSL_SESSION *session, |
| 639 |
unsigned char *out, size_t outlen) |
| 640 |
{ |
| 641 |
if (session->master_key_length < 0) { |
| 642 |
/* Should never happen */ |
| 643 |
return 0; |
| 644 |
} |
| 645 |
if (outlen == 0) |
| 646 |
return session->master_key_length; |
| 647 |
if (outlen > (size_t)session->master_key_length) |
| 648 |
outlen = session->master_key_length; |
| 649 |
memcpy(out, session->master_key, outlen); |
| 650 |
return outlen; |
| 651 |
} |
| 652 |
/* from ssl/ssl_sess.c */ |
| 653 |
int SSL_SESSION_has_ticket(const SSL_SESSION *s) |
| 654 |
{ |
| 655 |
return (s->tlsext_ticklen > 0) ? 1 : 0; |
| 656 |
} |
| 657 |
/* from ssl/ssl_sess.c */ |
| 658 |
unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s) |
| 659 |
{ |
| 660 |
return s->tlsext_tick_lifetime_hint; |
| 661 |
} |
| 662 |
#endif |
| 663 |
|
| 664 |
static const long Cryptography_HAS_SECURE_RENEGOTIATION = 1; |
| 665 |
|
| 666 |
/* Cryptography now compiles out all SSLv2 bindings. This exists to allow |
| 667 |
* clients that use it to check for SSLv2 support to keep functioning as |
| 668 |
* expected. |
| 669 |
*/ |
| 670 |
static const long Cryptography_HAS_SSL2 = 0; |
| 671 |
|
| 672 |
#ifdef OPENSSL_NO_SSL3_METHOD |
| 673 |
static const long Cryptography_HAS_SSL3_METHOD = 0; |
| 674 |
const SSL_METHOD* (*SSLv3_method)(void) = NULL; |
| 675 |
const SSL_METHOD* (*SSLv3_client_method)(void) = NULL; |
| 676 |
const SSL_METHOD* (*SSLv3_server_method)(void) = NULL; |
| 677 |
#else |
| 678 |
static const long Cryptography_HAS_SSL3_METHOD = 1; |
| 679 |
#endif |
| 680 |
|
| 681 |
static const long Cryptography_HAS_TLSEXT_HOSTNAME = 1; |
| 682 |
static const long Cryptography_HAS_TLSEXT_STATUS_REQ_CB = 1; |
| 683 |
static const long Cryptography_HAS_STATUS_REQ_OCSP_RESP = 1; |
| 684 |
static const long Cryptography_HAS_TLSEXT_STATUS_REQ_TYPE = 1; |
| 685 |
static const long Cryptography_HAS_RELEASE_BUFFERS = 1; |
| 686 |
static const long Cryptography_HAS_OP_NO_COMPRESSION = 1; |
| 687 |
static const long Cryptography_HAS_TLSv1_1 = 1; |
| 688 |
static const long Cryptography_HAS_TLSv1_2 = 1; |
| 689 |
static const long Cryptography_HAS_SSL_OP_MSIE_SSLV2_RSA_PADDING = 1; |
| 690 |
static const long Cryptography_HAS_SSL_OP_NO_TICKET = 1; |
| 691 |
static const long Cryptography_HAS_SSL_SET_SSL_CTX = 1; |
| 692 |
static const long Cryptography_HAS_NEXTPROTONEG = 1; |
| 693 |
|
| 694 |
/* SSL_get0_param was added in OpenSSL 1.0.2. */ |
| 695 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 && !CRYPTOGRAPHY_LIBRESSL_27_OR_GREATER |
| 696 |
X509_VERIFY_PARAM *(*SSL_get0_param)(SSL *) = NULL; |
| 697 |
X509_VERIFY_PARAM *(*SSL_CTX_get0_param)(SSL_CTX *ctx) = NULL; |
| 698 |
#else |
| 699 |
#endif |
| 700 |
|
| 701 |
/* ALPN was added in OpenSSL 1.0.2. */ |
| 702 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 && !CRYPTOGRAPHY_IS_LIBRESSL |
| 703 |
int (*SSL_CTX_set_alpn_protos)(SSL_CTX *, |
| 704 |
const unsigned char *, |
| 705 |
unsigned) = NULL; |
| 706 |
int (*SSL_set_alpn_protos)(SSL *, const unsigned char *, unsigned) = NULL; |
| 707 |
void (*SSL_CTX_set_alpn_select_cb)(SSL_CTX *, |
| 708 |
int (*) (SSL *, |
| 709 |
const unsigned char **, |
| 710 |
unsigned char *, |
| 711 |
const unsigned char *, |
| 712 |
unsigned int, |
| 713 |
void *), |
| 714 |
void *) = NULL; |
| 715 |
void (*SSL_get0_alpn_selected)(const SSL *, |
| 716 |
const unsigned char **, |
| 717 |
unsigned *) = NULL; |
| 718 |
static const long Cryptography_HAS_ALPN = 0; |
| 719 |
#else |
| 720 |
static const long Cryptography_HAS_ALPN = 1; |
| 721 |
#endif |
| 722 |
|
| 723 |
/* SSL_CTX_set_cert_cb was added in OpenSSL 1.0.2. */ |
| 724 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 |
| 725 |
void (*SSL_CTX_set_cert_cb)(SSL_CTX *, int (*)(SSL *, void *), void *) = NULL; |
| 726 |
void (*SSL_set_cert_cb)(SSL *, int (*)(SSL *, void *), void *) = NULL; |
| 727 |
static const long Cryptography_HAS_SET_CERT_CB = 0; |
| 728 |
#else |
| 729 |
static const long Cryptography_HAS_SET_CERT_CB = 1; |
| 730 |
#endif |
| 731 |
|
| 732 |
static const long Cryptography_HAS_COMPRESSION = 1; |
| 733 |
|
| 734 |
/* The setter functions were added in OpenSSL 1.1.0. The getter functions were |
| 735 |
added in OpenSSL 1.1.1. */ |
| 736 |
#if defined(SSL_CTRL_GET_MAX_PROTO_VERSION) |
| 737 |
static const long Cryptography_HAS_CTRL_GET_MAX_PROTO_VERSION = 1; |
| 738 |
#else |
| 739 |
static const long Cryptography_HAS_CTRL_GET_MAX_PROTO_VERSION = 0; |
| 740 |
int (*SSL_CTX_get_min_proto_version)(SSL_CTX *ctx) = NULL; |
| 741 |
int (*SSL_CTX_get_max_proto_version)(SSL_CTX *ctx) = NULL; |
| 742 |
int (*SSL_get_min_proto_version)(SSL *ssl) = NULL; |
| 743 |
int (*SSL_get_max_proto_version)(SSL *ssl) = NULL; |
| 744 |
#endif |
| 745 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 |
| 746 |
int (*SSL_CTX_set_min_proto_version)(SSL_CTX *ctx, int version) = NULL; |
| 747 |
int (*SSL_CTX_set_max_proto_version)(SSL_CTX *ctx, int version) = NULL; |
| 748 |
int (*SSL_set_min_proto_version)(SSL *ssl, int version) = NULL; |
| 749 |
int (*SSL_set_max_proto_version)(SSL *ssl, int version) = NULL; |
| 750 |
#endif |
| 751 |
|
| 752 |
static const long Cryptography_HAS_SSL_CTX_SET_CLIENT_CERT_ENGINE = 1; |
| 753 |
|
| 754 |
static const long Cryptography_HAS_SSL_CTX_CLEAR_OPTIONS = 1; |
| 755 |
|
| 756 |
/* in OpenSSL 1.1.0 the SSL_ST values were renamed to TLS_ST and several were |
| 757 |
removed */ |
| 758 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 |
| 759 |
static const long Cryptography_HAS_SSL_ST = 1; |
| 760 |
#else |
| 761 |
static const long Cryptography_HAS_SSL_ST = 0; |
| 762 |
static const long SSL_ST_BEFORE = 0; |
| 763 |
static const long SSL_ST_OK = 0; |
| 764 |
static const long SSL_ST_INIT = 0; |
| 765 |
static const long SSL_ST_RENEGOTIATE = 0; |
| 766 |
#endif |
| 767 |
#if CRYPTOGRAPHY_OPENSSL_110_OR_GREATER |
| 768 |
static const long Cryptography_HAS_TLS_ST = 1; |
| 769 |
#else |
| 770 |
static const long Cryptography_HAS_TLS_ST = 0; |
| 771 |
static const long TLS_ST_BEFORE = 0; |
| 772 |
static const long TLS_ST_OK = 0; |
| 773 |
#endif |
| 774 |
|
| 775 |
/* SSLv23_method(), SSLv23_server_method() and SSLv23_client_method() were |
| 776 |
deprecated and the preferred TLS_method(), TLS_server_method() and |
| 777 |
TLS_client_method() functions were introduced in OpenSSL 1.1.0. */ |
| 778 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 |
| 779 |
#define TLS_method SSLv23_method |
| 780 |
#define TLS_server_method SSLv23_server_method |
| 781 |
#define TLS_client_method SSLv23_client_method |
| 782 |
#endif |
| 783 |
|
| 784 |
/* LibreSSL 2.9.1 added only the DTLS_*_method functions */ |
| 785 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 && !CRYPTOGRAPHY_LIBRESSL_291_OR_GREATER |
| 786 |
static const long Cryptography_HAS_GENERIC_DTLS_METHOD = 0; |
| 787 |
const SSL_METHOD *(*DTLS_method)(void) = NULL; |
| 788 |
const SSL_METHOD *(*DTLS_server_method)(void) = NULL; |
| 789 |
const SSL_METHOD *(*DTLS_client_method)(void) = NULL; |
| 790 |
#else |
| 791 |
static const long Cryptography_HAS_GENERIC_DTLS_METHOD = 1; |
| 792 |
#endif |
| 793 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 |
| 794 |
static const long SSL_OP_NO_DTLSv1 = 0; |
| 795 |
static const long SSL_OP_NO_DTLSv1_2 = 0; |
| 796 |
long (*DTLS_set_link_mtu)(SSL *, long) = NULL; |
| 797 |
long (*DTLS_get_link_min_mtu)(SSL *) = NULL; |
| 798 |
#endif |
| 799 |
|
| 800 |
static const long Cryptography_HAS_DTLS = 1; |
| 801 |
/* Wrap DTLSv1_get_timeout to avoid cffi to handle a 'struct timeval'. */ |
| 802 |
long Cryptography_DTLSv1_get_timeout(SSL *ssl, time_t *ptv_sec, |
| 803 |
long *ptv_usec) { |
| 804 |
struct timeval tv = { 0 }; |
| 805 |
long r = DTLSv1_get_timeout(ssl, &tv); |
| 806 |
|
| 807 |
if (r == 1) { |
| 808 |
if (ptv_sec) { |
| 809 |
*ptv_sec = tv.tv_sec; |
| 810 |
} |
| 811 |
|
| 812 |
if (ptv_usec) { |
| 813 |
*ptv_usec = tv.tv_usec; |
| 814 |
} |
| 815 |
} |
| 816 |
|
| 817 |
return r; |
| 818 |
} |
| 819 |
|
| 820 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_102 |
| 821 |
static const long Cryptography_HAS_SIGALGS = 0; |
| 822 |
const int (*SSL_get_sigalgs)(SSL *, int, int *, int *, int *, unsigned char *, |
| 823 |
unsigned char *) = NULL; |
| 824 |
const long (*SSL_CTX_set1_sigalgs_list)(SSL_CTX *, const char *) = NULL; |
| 825 |
#else |
| 826 |
static const long Cryptography_HAS_SIGALGS = 1; |
| 827 |
#endif |
| 828 |
|
| 829 |
#if CRYPTOGRAPHY_IS_LIBRESSL || defined(OPENSSL_NO_PSK) |
| 830 |
static const long Cryptography_HAS_PSK = 0; |
| 831 |
int (*SSL_CTX_use_psk_identity_hint)(SSL_CTX *, const char *) = NULL; |
| 832 |
void (*SSL_CTX_set_psk_server_callback)(SSL_CTX *, |
| 833 |
unsigned int (*)( |
| 834 |
SSL *, |
| 835 |
const char *, |
| 836 |
unsigned char *, |
| 837 |
unsigned int |
| 838 |
)) = NULL; |
| 839 |
void (*SSL_CTX_set_psk_client_callback)(SSL_CTX *, |
| 840 |
unsigned int (*)( |
| 841 |
SSL *, |
| 842 |
const char *, |
| 843 |
char *, |
| 844 |
unsigned int, |
| 845 |
unsigned char *, |
| 846 |
unsigned int |
| 847 |
)) = NULL; |
| 848 |
#else |
| 849 |
static const long Cryptography_HAS_PSK = 1; |
| 850 |
#endif |
| 851 |
|
| 852 |
/* |
| 853 |
* Custom extensions were added in 1.0.2. 1.1.1 is adding a more general |
| 854 |
* SSL_CTX_add_custom_ext function, but we're not binding that yet. |
| 855 |
*/ |
| 856 |
#if CRYPTOGRAPHY_OPENSSL_102_OR_GREATER |
| 857 |
static const long Cryptography_HAS_CUSTOM_EXT = 1; |
| 858 |
#else |
| 859 |
static const long Cryptography_HAS_CUSTOM_EXT = 0; |
| 860 |
|
| 861 |
typedef int (*custom_ext_add_cb)(SSL *, unsigned int, |
| 862 |
const unsigned char **, |
| 863 |
size_t *, int *, |
| 864 |
void *); |
| 865 |
|
| 866 |
typedef void (*custom_ext_free_cb)(SSL *, unsigned int, |
| 867 |
const unsigned char *, |
| 868 |
void *); |
| 869 |
|
| 870 |
typedef int (*custom_ext_parse_cb)(SSL *, unsigned int, |
| 871 |
const unsigned char *, |
| 872 |
size_t, int *, |
| 873 |
void *); |
| 874 |
|
| 875 |
int (*SSL_CTX_add_client_custom_ext)(SSL_CTX *, unsigned int, |
| 876 |
custom_ext_add_cb, |
| 877 |
custom_ext_free_cb, void *, |
| 878 |
custom_ext_parse_cb, |
| 879 |
void *) = NULL; |
| 880 |
|
| 881 |
int (*SSL_CTX_add_server_custom_ext)(SSL_CTX *, unsigned int, |
| 882 |
custom_ext_add_cb, |
| 883 |
custom_ext_free_cb, void *, |
| 884 |
custom_ext_parse_cb, |
| 885 |
void *) = NULL; |
| 886 |
|
| 887 |
int (*SSL_extension_supported)(unsigned int) = NULL; |
| 888 |
#endif |
| 889 |
|
| 890 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_110 && !CRYPTOGRAPHY_LIBRESSL_27_OR_GREATER |
| 891 |
int (*SSL_CIPHER_is_aead)(const SSL_CIPHER *) = NULL; |
| 892 |
int (*SSL_CIPHER_get_cipher_nid)(const SSL_CIPHER *) = NULL; |
| 893 |
int (*SSL_CIPHER_get_digest_nid)(const SSL_CIPHER *) = NULL; |
| 894 |
int (*SSL_CIPHER_get_kx_nid)(const SSL_CIPHER *) = NULL; |
| 895 |
int (*SSL_CIPHER_get_auth_nid)(const SSL_CIPHER *) = NULL; |
| 896 |
static const long Cryptography_HAS_CIPHER_DETAILS = 0; |
| 897 |
#else |
| 898 |
static const long Cryptography_HAS_CIPHER_DETAILS = 1; |
| 899 |
#endif |
| 900 |
|
| 901 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_111 |
| 902 |
static const long Cryptography_HAS_TLSv1_3 = 0; |
| 903 |
static const long SSL_OP_NO_TLSv1_3 = 0; |
| 904 |
static const long SSL_VERIFY_POST_HANDSHAKE = 0; |
| 905 |
int (*SSL_CTX_set_ciphersuites)(SSL_CTX *, const char *) = NULL; |
| 906 |
int (*SSL_verify_client_post_handshake)(SSL *) = NULL; |
| 907 |
void (*SSL_CTX_set_post_handshake_auth)(SSL_CTX *, int) = NULL; |
| 908 |
void (*SSL_set_post_handshake_auth)(SSL *, int) = NULL; |
| 909 |
uint32_t (*SSL_SESSION_get_max_early_data)(const SSL_SESSION *) = NULL; |
| 910 |
int (*SSL_write_early_data)(SSL *, const void *, size_t, size_t *) = NULL; |
| 911 |
int (*SSL_read_early_data)(SSL *, void *, size_t, size_t *) = NULL; |
| 912 |
int (*SSL_CTX_set_max_early_data)(SSL_CTX *, uint32_t) = NULL; |
| 913 |
#else |
| 914 |
static const long Cryptography_HAS_TLSv1_3 = 1; |
| 915 |
#endif |
| 916 |
|
| 917 |
#if CRYPTOGRAPHY_OPENSSL_LESS_THAN_300 |
| 918 |
static const long SSL_OP_IGNORE_UNEXPECTED_EOF = 0; |
| 919 |
static const long Crytpography_HAS_OP_IGNORE_UNEXPECTED_EOF = 0; |
| 920 |
#else |
| 921 |
static const long Crytpography_HAS_OP_IGNORE_UNEXPECTED_EOF = 1; |
| 922 |
#endif |
| 923 |
#ifdef X509_CHECK_FLAG_NEVER_CHECK_SUBJECT |
| 924 |
static const long Cryptography_HAS_X509_CHECK_FLAG_NEVER_CHECK_SUBJECT = 1; |
| 925 |
#else |
| 926 |
static const long Cryptography_HAS_X509_CHECK_FLAG_NEVER_CHECK_SUBJECT = 0; |
| 927 |
#endif |
| 928 |
""" |