diff options
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 388 |
1 files changed, 349 insertions, 39 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 0f4b7a475b..31f6318357 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
| @@ -110,7 +110,11 @@ | |||
| 110 | * Hudson (tjh@cryptsoft.com). | 110 | * Hudson (tjh@cryptsoft.com). |
| 111 | * | 111 | * |
| 112 | */ | 112 | */ |
| 113 | 113 | /* ==================================================================== | |
| 114 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | ||
| 115 | * ECC cipher suite support in OpenSSL originally developed by | ||
| 116 | * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. | ||
| 117 | */ | ||
| 114 | 118 | ||
| 115 | #ifdef REF_CHECK | 119 | #ifdef REF_CHECK |
| 116 | # include <assert.h> | 120 | # include <assert.h> |
| @@ -121,7 +125,11 @@ | |||
| 121 | #include <openssl/objects.h> | 125 | #include <openssl/objects.h> |
| 122 | #include <openssl/lhash.h> | 126 | #include <openssl/lhash.h> |
| 123 | #include <openssl/x509v3.h> | 127 | #include <openssl/x509v3.h> |
| 124 | #include <openssl/fips.h> | 128 | #include <openssl/rand.h> |
| 129 | #include <openssl/ocsp.h> | ||
| 130 | #ifndef OPENSSL_NO_DH | ||
| 131 | #include <openssl/dh.h> | ||
| 132 | #endif | ||
| 125 | 133 | ||
| 126 | const char *SSL_version_str=OPENSSL_VERSION_TEXT; | 134 | const char *SSL_version_str=OPENSSL_VERSION_TEXT; |
| 127 | 135 | ||
| @@ -132,7 +140,14 @@ SSL3_ENC_METHOD ssl3_undef_enc_method={ | |||
| 132 | ssl_undefined_function, | 140 | ssl_undefined_function, |
| 133 | (int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function, | 141 | (int (*)(SSL *, unsigned char *, unsigned char *, int))ssl_undefined_function, |
| 134 | (int (*)(SSL*, int))ssl_undefined_function, | 142 | (int (*)(SSL*, int))ssl_undefined_function, |
| 135 | (int (*)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char*, int, unsigned char *))ssl_undefined_function | 143 | (int (*)(SSL *, EVP_MD_CTX *, EVP_MD_CTX *, const char*, int, unsigned char *))ssl_undefined_function, |
| 144 | 0, /* finish_mac_length */ | ||
| 145 | (int (*)(SSL *, EVP_MD_CTX *, unsigned char *))ssl_undefined_function, | ||
| 146 | NULL, /* client_finished_label */ | ||
| 147 | 0, /* client_finished_label_len */ | ||
| 148 | NULL, /* server_finished_label */ | ||
| 149 | 0, /* server_finished_label_len */ | ||
| 150 | (int (*)(int))ssl_undefined_function | ||
| 136 | }; | 151 | }; |
| 137 | 152 | ||
| 138 | int SSL_clear(SSL *s) | 153 | int SSL_clear(SSL *s) |
| @@ -272,19 +287,40 @@ SSL *SSL_new(SSL_CTX *ctx) | |||
| 272 | s->msg_callback=ctx->msg_callback; | 287 | s->msg_callback=ctx->msg_callback; |
| 273 | s->msg_callback_arg=ctx->msg_callback_arg; | 288 | s->msg_callback_arg=ctx->msg_callback_arg; |
| 274 | s->verify_mode=ctx->verify_mode; | 289 | s->verify_mode=ctx->verify_mode; |
| 290 | #if 0 | ||
| 275 | s->verify_depth=ctx->verify_depth; | 291 | s->verify_depth=ctx->verify_depth; |
| 292 | #endif | ||
| 276 | s->sid_ctx_length=ctx->sid_ctx_length; | 293 | s->sid_ctx_length=ctx->sid_ctx_length; |
| 277 | OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx); | 294 | OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx); |
| 278 | memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); | 295 | memcpy(&s->sid_ctx,&ctx->sid_ctx,sizeof(s->sid_ctx)); |
| 279 | s->verify_callback=ctx->default_verify_callback; | 296 | s->verify_callback=ctx->default_verify_callback; |
| 280 | s->generate_session_id=ctx->generate_session_id; | 297 | s->generate_session_id=ctx->generate_session_id; |
| 298 | |||
| 299 | s->param = X509_VERIFY_PARAM_new(); | ||
| 300 | if (!s->param) | ||
| 301 | goto err; | ||
| 302 | X509_VERIFY_PARAM_inherit(s->param, ctx->param); | ||
| 303 | #if 0 | ||
| 281 | s->purpose = ctx->purpose; | 304 | s->purpose = ctx->purpose; |
| 282 | s->trust = ctx->trust; | 305 | s->trust = ctx->trust; |
| 306 | #endif | ||
| 283 | s->quiet_shutdown=ctx->quiet_shutdown; | 307 | s->quiet_shutdown=ctx->quiet_shutdown; |
| 284 | 308 | ||
| 285 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); | 309 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); |
| 286 | s->ctx=ctx; | 310 | s->ctx=ctx; |
| 287 | 311 | #ifndef OPENSSL_NO_TLSEXT | |
| 312 | s->tlsext_debug_cb = 0; | ||
| 313 | s->tlsext_debug_arg = NULL; | ||
| 314 | s->tlsext_ticket_expected = 0; | ||
| 315 | s->tlsext_status_type = -1; | ||
| 316 | s->tlsext_status_expected = 0; | ||
| 317 | s->tlsext_ocsp_ids = NULL; | ||
| 318 | s->tlsext_ocsp_exts = NULL; | ||
| 319 | s->tlsext_ocsp_resp = NULL; | ||
| 320 | s->tlsext_ocsp_resplen = -1; | ||
| 321 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); | ||
| 322 | s->initial_ctx=ctx; | ||
| 323 | #endif | ||
| 288 | s->verify_result=X509_V_OK; | 324 | s->verify_result=X509_V_OK; |
| 289 | 325 | ||
| 290 | s->method=ctx->method; | 326 | s->method=ctx->method; |
| @@ -393,22 +429,22 @@ int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, | |||
| 393 | 429 | ||
| 394 | int SSL_CTX_set_purpose(SSL_CTX *s, int purpose) | 430 | int SSL_CTX_set_purpose(SSL_CTX *s, int purpose) |
| 395 | { | 431 | { |
| 396 | return X509_PURPOSE_set(&s->purpose, purpose); | 432 | return X509_VERIFY_PARAM_set_purpose(s->param, purpose); |
| 397 | } | 433 | } |
| 398 | 434 | ||
| 399 | int SSL_set_purpose(SSL *s, int purpose) | 435 | int SSL_set_purpose(SSL *s, int purpose) |
| 400 | { | 436 | { |
| 401 | return X509_PURPOSE_set(&s->purpose, purpose); | 437 | return X509_VERIFY_PARAM_set_purpose(s->param, purpose); |
| 402 | } | 438 | } |
| 403 | 439 | ||
| 404 | int SSL_CTX_set_trust(SSL_CTX *s, int trust) | 440 | int SSL_CTX_set_trust(SSL_CTX *s, int trust) |
| 405 | { | 441 | { |
| 406 | return X509_TRUST_set(&s->trust, trust); | 442 | return X509_VERIFY_PARAM_set_trust(s->param, trust); |
| 407 | } | 443 | } |
| 408 | 444 | ||
| 409 | int SSL_set_trust(SSL *s, int trust) | 445 | int SSL_set_trust(SSL *s, int trust) |
| 410 | { | 446 | { |
| 411 | return X509_TRUST_set(&s->trust, trust); | 447 | return X509_VERIFY_PARAM_set_trust(s->param, trust); |
| 412 | } | 448 | } |
| 413 | 449 | ||
| 414 | void SSL_free(SSL *s) | 450 | void SSL_free(SSL *s) |
| @@ -431,6 +467,9 @@ void SSL_free(SSL *s) | |||
| 431 | } | 467 | } |
| 432 | #endif | 468 | #endif |
| 433 | 469 | ||
| 470 | if (s->param) | ||
| 471 | X509_VERIFY_PARAM_free(s->param); | ||
| 472 | |||
| 434 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); | 473 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); |
| 435 | 474 | ||
| 436 | if (s->bbio != NULL) | 475 | if (s->bbio != NULL) |
| @@ -467,7 +506,16 @@ void SSL_free(SSL *s) | |||
| 467 | /* Free up if allocated */ | 506 | /* Free up if allocated */ |
| 468 | 507 | ||
| 469 | if (s->ctx) SSL_CTX_free(s->ctx); | 508 | if (s->ctx) SSL_CTX_free(s->ctx); |
| 470 | 509 | #ifndef OPENSSL_NO_TLSEXT | |
| 510 | if (s->initial_ctx) SSL_CTX_free(s->initial_ctx); | ||
| 511 | if (s->tlsext_ocsp_exts) | ||
| 512 | sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, | ||
| 513 | X509_EXTENSION_free); | ||
| 514 | if (s->tlsext_ocsp_ids) | ||
| 515 | sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free); | ||
| 516 | if (s->tlsext_ocsp_resp) | ||
| 517 | OPENSSL_free(s->tlsext_ocsp_resp); | ||
| 518 | #endif | ||
| 471 | if (s->client_CA != NULL) | 519 | if (s->client_CA != NULL) |
| 472 | sk_X509_NAME_pop_free(s->client_CA,X509_NAME_free); | 520 | sk_X509_NAME_pop_free(s->client_CA,X509_NAME_free); |
| 473 | 521 | ||
| @@ -643,7 +691,7 @@ int SSL_get_verify_mode(const SSL *s) | |||
| 643 | 691 | ||
| 644 | int SSL_get_verify_depth(const SSL *s) | 692 | int SSL_get_verify_depth(const SSL *s) |
| 645 | { | 693 | { |
| 646 | return(s->verify_depth); | 694 | return X509_VERIFY_PARAM_get_depth(s->param); |
| 647 | } | 695 | } |
| 648 | 696 | ||
| 649 | int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *) | 697 | int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *) |
| @@ -658,7 +706,7 @@ int SSL_CTX_get_verify_mode(const SSL_CTX *ctx) | |||
| 658 | 706 | ||
| 659 | int SSL_CTX_get_verify_depth(const SSL_CTX *ctx) | 707 | int SSL_CTX_get_verify_depth(const SSL_CTX *ctx) |
| 660 | { | 708 | { |
| 661 | return(ctx->verify_depth); | 709 | return X509_VERIFY_PARAM_get_depth(ctx->param); |
| 662 | } | 710 | } |
| 663 | 711 | ||
| 664 | int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *) | 712 | int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *) |
| @@ -676,7 +724,7 @@ void SSL_set_verify(SSL *s,int mode, | |||
| 676 | 724 | ||
| 677 | void SSL_set_verify_depth(SSL *s,int depth) | 725 | void SSL_set_verify_depth(SSL *s,int depth) |
| 678 | { | 726 | { |
| 679 | s->verify_depth=depth; | 727 | X509_VERIFY_PARAM_set_depth(s->param, depth); |
| 680 | } | 728 | } |
| 681 | 729 | ||
| 682 | void SSL_set_read_ahead(SSL *s,int yes) | 730 | void SSL_set_read_ahead(SSL *s,int yes) |
| @@ -850,7 +898,7 @@ int SSL_peek(SSL *s,void *buf,int num) | |||
| 850 | { | 898 | { |
| 851 | if (s->handshake_func == 0) | 899 | if (s->handshake_func == 0) |
| 852 | { | 900 | { |
| 853 | SSLerr(SSL_F_SSL_READ, SSL_R_UNINITIALIZED); | 901 | SSLerr(SSL_F_SSL_PEEK, SSL_R_UNINITIALIZED); |
| 854 | return -1; | 902 | return -1; |
| 855 | } | 903 | } |
| 856 | 904 | ||
| @@ -941,12 +989,19 @@ long SSL_ctrl(SSL *s,int cmd,long larg,void *parg) | |||
| 941 | l=s->max_cert_list; | 989 | l=s->max_cert_list; |
| 942 | s->max_cert_list=larg; | 990 | s->max_cert_list=larg; |
| 943 | return(l); | 991 | return(l); |
| 992 | case SSL_CTRL_SET_MTU: | ||
| 993 | if (SSL_version(s) == DTLS1_VERSION) | ||
| 994 | { | ||
| 995 | s->d1->mtu = larg; | ||
| 996 | return larg; | ||
| 997 | } | ||
| 998 | return 0; | ||
| 944 | default: | 999 | default: |
| 945 | return(s->method->ssl_ctrl(s,cmd,larg,parg)); | 1000 | return(s->method->ssl_ctrl(s,cmd,larg,parg)); |
| 946 | } | 1001 | } |
| 947 | } | 1002 | } |
| 948 | 1003 | ||
| 949 | long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)()) | 1004 | long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)(void)) |
| 950 | { | 1005 | { |
| 951 | switch(cmd) | 1006 | switch(cmd) |
| 952 | { | 1007 | { |
| @@ -1034,7 +1089,7 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,void *parg) | |||
| 1034 | } | 1089 | } |
| 1035 | } | 1090 | } |
| 1036 | 1091 | ||
| 1037 | long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)()) | 1092 | long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)(void)) |
| 1038 | { | 1093 | { |
| 1039 | switch(cmd) | 1094 | switch(cmd) |
| 1040 | { | 1095 | { |
| @@ -1269,6 +1324,29 @@ err: | |||
| 1269 | return(NULL); | 1324 | return(NULL); |
| 1270 | } | 1325 | } |
| 1271 | 1326 | ||
| 1327 | #ifndef OPENSSL_NO_TLSEXT | ||
| 1328 | /** return a servername extension value if provided in Client Hello, or NULL. | ||
| 1329 | * So far, only host_name types are defined (RFC 3546). | ||
| 1330 | */ | ||
| 1331 | |||
| 1332 | const char *SSL_get_servername(const SSL *s, const int type) | ||
| 1333 | { | ||
| 1334 | if (type != TLSEXT_NAMETYPE_host_name) | ||
| 1335 | return NULL; | ||
| 1336 | |||
| 1337 | return s->session && !s->tlsext_hostname ? | ||
| 1338 | s->session->tlsext_hostname : | ||
| 1339 | s->tlsext_hostname; | ||
| 1340 | } | ||
| 1341 | |||
| 1342 | int SSL_get_servername_type(const SSL *s) | ||
| 1343 | { | ||
| 1344 | if (s->session && (!s->tlsext_hostname ? s->session->tlsext_hostname : s->tlsext_hostname)) | ||
| 1345 | return TLSEXT_NAMETYPE_host_name; | ||
| 1346 | return -1; | ||
| 1347 | } | ||
| 1348 | #endif | ||
| 1349 | |||
| 1272 | unsigned long SSL_SESSION_hash(const SSL_SESSION *a) | 1350 | unsigned long SSL_SESSION_hash(const SSL_SESSION *a) |
| 1273 | { | 1351 | { |
| 1274 | unsigned long l; | 1352 | unsigned long l; |
| @@ -1312,14 +1390,6 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1312 | return(NULL); | 1390 | return(NULL); |
| 1313 | } | 1391 | } |
| 1314 | 1392 | ||
| 1315 | #ifdef OPENSSL_FIPS | ||
| 1316 | if (FIPS_mode() && (meth->version < TLS1_VERSION)) | ||
| 1317 | { | ||
| 1318 | SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE); | ||
| 1319 | return NULL; | ||
| 1320 | } | ||
| 1321 | #endif | ||
| 1322 | |||
| 1323 | if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) | 1393 | if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) |
| 1324 | { | 1394 | { |
| 1325 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); | 1395 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); |
| @@ -1368,7 +1438,9 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1368 | ret->msg_callback=0; | 1438 | ret->msg_callback=0; |
| 1369 | ret->msg_callback_arg=NULL; | 1439 | ret->msg_callback_arg=NULL; |
| 1370 | ret->verify_mode=SSL_VERIFY_NONE; | 1440 | ret->verify_mode=SSL_VERIFY_NONE; |
| 1441 | #if 0 | ||
| 1371 | ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ | 1442 | ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ |
| 1443 | #endif | ||
| 1372 | ret->sid_ctx_length=0; | 1444 | ret->sid_ctx_length=0; |
| 1373 | ret->default_verify_callback=NULL; | 1445 | ret->default_verify_callback=NULL; |
| 1374 | if ((ret->cert=ssl_cert_new()) == NULL) | 1446 | if ((ret->cert=ssl_cert_new()) == NULL) |
| @@ -1377,6 +1449,8 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1377 | ret->default_passwd_callback=0; | 1449 | ret->default_passwd_callback=0; |
| 1378 | ret->default_passwd_callback_userdata=NULL; | 1450 | ret->default_passwd_callback_userdata=NULL; |
| 1379 | ret->client_cert_cb=0; | 1451 | ret->client_cert_cb=0; |
| 1452 | ret->app_gen_cookie_cb=0; | ||
| 1453 | ret->app_verify_cookie_cb=0; | ||
| 1380 | 1454 | ||
| 1381 | ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash), | 1455 | ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash), |
| 1382 | LHASH_COMP_FN(SSL_SESSION_cmp)); | 1456 | LHASH_COMP_FN(SSL_SESSION_cmp)); |
| @@ -1394,6 +1468,10 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1394 | goto err2; | 1468 | goto err2; |
| 1395 | } | 1469 | } |
| 1396 | 1470 | ||
| 1471 | ret->param = X509_VERIFY_PARAM_new(); | ||
| 1472 | if (!ret->param) | ||
| 1473 | goto err; | ||
| 1474 | |||
| 1397 | if ((ret->rsa_md5=EVP_get_digestbyname("ssl2-md5")) == NULL) | 1475 | if ((ret->rsa_md5=EVP_get_digestbyname("ssl2-md5")) == NULL) |
| 1398 | { | 1476 | { |
| 1399 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES); | 1477 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES); |
| @@ -1418,6 +1496,20 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1418 | ret->extra_certs=NULL; | 1496 | ret->extra_certs=NULL; |
| 1419 | ret->comp_methods=SSL_COMP_get_compression_methods(); | 1497 | ret->comp_methods=SSL_COMP_get_compression_methods(); |
| 1420 | 1498 | ||
| 1499 | #ifndef OPENSSL_NO_TLSEXT | ||
| 1500 | ret->tlsext_servername_callback = 0; | ||
| 1501 | ret->tlsext_servername_arg = NULL; | ||
| 1502 | /* Setup RFC4507 ticket keys */ | ||
| 1503 | if ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0) | ||
| 1504 | || (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0) | ||
| 1505 | || (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0)) | ||
| 1506 | ret->options |= SSL_OP_NO_TICKET; | ||
| 1507 | |||
| 1508 | ret->tlsext_status_cb = 0; | ||
| 1509 | ret->tlsext_status_arg = NULL; | ||
| 1510 | |||
| 1511 | #endif | ||
| 1512 | |||
| 1421 | return(ret); | 1513 | return(ret); |
| 1422 | err: | 1514 | err: |
| 1423 | SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE); | 1515 | SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE); |
| @@ -1450,6 +1542,9 @@ void SSL_CTX_free(SSL_CTX *a) | |||
| 1450 | } | 1542 | } |
| 1451 | #endif | 1543 | #endif |
| 1452 | 1544 | ||
| 1545 | if (a->param) | ||
| 1546 | X509_VERIFY_PARAM_free(a->param); | ||
| 1547 | |||
| 1453 | /* | 1548 | /* |
| 1454 | * Free internal session cache. However: the remove_cb() may reference | 1549 | * Free internal session cache. However: the remove_cb() may reference |
| 1455 | * the ex_data of SSL_CTX, thus the ex_data store can only be removed | 1550 | * the ex_data of SSL_CTX, thus the ex_data store can only be removed |
| @@ -1512,7 +1607,7 @@ void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *)) | |||
| 1512 | 1607 | ||
| 1513 | void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) | 1608 | void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) |
| 1514 | { | 1609 | { |
| 1515 | ctx->verify_depth=depth; | 1610 | X509_VERIFY_PARAM_set_depth(ctx->param, depth); |
| 1516 | } | 1611 | } |
| 1517 | 1612 | ||
| 1518 | void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | 1613 | void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) |
| @@ -1522,6 +1617,13 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1522 | int rsa_enc_export,dh_rsa_export,dh_dsa_export; | 1617 | int rsa_enc_export,dh_rsa_export,dh_dsa_export; |
| 1523 | int rsa_tmp_export,dh_tmp_export,kl; | 1618 | int rsa_tmp_export,dh_tmp_export,kl; |
| 1524 | unsigned long mask,emask; | 1619 | unsigned long mask,emask; |
| 1620 | int have_ecc_cert, ecdh_ok, ecdsa_ok, ecc_pkey_size; | ||
| 1621 | #ifndef OPENSSL_NO_ECDH | ||
| 1622 | int have_ecdh_tmp; | ||
| 1623 | #endif | ||
| 1624 | X509 *x = NULL; | ||
| 1625 | EVP_PKEY *ecc_pkey = NULL; | ||
| 1626 | int signature_nid = 0; | ||
| 1525 | 1627 | ||
| 1526 | if (c == NULL) return; | 1628 | if (c == NULL) return; |
| 1527 | 1629 | ||
| @@ -1542,6 +1644,9 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1542 | dh_tmp=dh_tmp_export=0; | 1644 | dh_tmp=dh_tmp_export=0; |
| 1543 | #endif | 1645 | #endif |
| 1544 | 1646 | ||
| 1647 | #ifndef OPENSSL_NO_ECDH | ||
| 1648 | have_ecdh_tmp=(c->ecdh_tmp != NULL || c->ecdh_tmp_cb != NULL); | ||
| 1649 | #endif | ||
| 1545 | cpk= &(c->pkeys[SSL_PKEY_RSA_ENC]); | 1650 | cpk= &(c->pkeys[SSL_PKEY_RSA_ENC]); |
| 1546 | rsa_enc= (cpk->x509 != NULL && cpk->privatekey != NULL); | 1651 | rsa_enc= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1547 | rsa_enc_export=(rsa_enc && EVP_PKEY_size(cpk->privatekey)*8 <= kl); | 1652 | rsa_enc_export=(rsa_enc && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| @@ -1556,7 +1661,8 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1556 | /* FIX THIS EAY EAY EAY */ | 1661 | /* FIX THIS EAY EAY EAY */ |
| 1557 | dh_dsa= (cpk->x509 != NULL && cpk->privatekey != NULL); | 1662 | dh_dsa= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1558 | dh_dsa_export=(dh_dsa && EVP_PKEY_size(cpk->privatekey)*8 <= kl); | 1663 | dh_dsa_export=(dh_dsa && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| 1559 | 1664 | cpk= &(c->pkeys[SSL_PKEY_ECC]); | |
| 1665 | have_ecc_cert= (cpk->x509 != NULL && cpk->privatekey != NULL); | ||
| 1560 | mask=0; | 1666 | mask=0; |
| 1561 | emask=0; | 1667 | emask=0; |
| 1562 | 1668 | ||
| @@ -1613,11 +1719,127 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1613 | emask|=SSL_kKRB5|SSL_aKRB5; | 1719 | emask|=SSL_kKRB5|SSL_aKRB5; |
| 1614 | #endif | 1720 | #endif |
| 1615 | 1721 | ||
| 1722 | /* An ECC certificate may be usable for ECDH and/or | ||
| 1723 | * ECDSA cipher suites depending on the key usage extension. | ||
| 1724 | */ | ||
| 1725 | if (have_ecc_cert) | ||
| 1726 | { | ||
| 1727 | /* This call populates extension flags (ex_flags) */ | ||
| 1728 | x = (c->pkeys[SSL_PKEY_ECC]).x509; | ||
| 1729 | X509_check_purpose(x, -1, 0); | ||
| 1730 | ecdh_ok = (x->ex_flags & EXFLAG_KUSAGE) ? | ||
| 1731 | (x->ex_kusage & X509v3_KU_KEY_AGREEMENT) : 1; | ||
| 1732 | ecdsa_ok = (x->ex_flags & EXFLAG_KUSAGE) ? | ||
| 1733 | (x->ex_kusage & X509v3_KU_DIGITAL_SIGNATURE) : 1; | ||
| 1734 | ecc_pkey = X509_get_pubkey(x); | ||
| 1735 | ecc_pkey_size = (ecc_pkey != NULL) ? | ||
| 1736 | EVP_PKEY_bits(ecc_pkey) : 0; | ||
| 1737 | EVP_PKEY_free(ecc_pkey); | ||
| 1738 | if ((x->sig_alg) && (x->sig_alg->algorithm)) | ||
| 1739 | signature_nid = OBJ_obj2nid(x->sig_alg->algorithm); | ||
| 1740 | #ifndef OPENSSL_NO_ECDH | ||
| 1741 | if (ecdh_ok) | ||
| 1742 | { | ||
| 1743 | if ((signature_nid == NID_md5WithRSAEncryption) || | ||
| 1744 | (signature_nid == NID_md4WithRSAEncryption) || | ||
| 1745 | (signature_nid == NID_md2WithRSAEncryption)) | ||
| 1746 | { | ||
| 1747 | mask|=SSL_kECDH|SSL_aRSA; | ||
| 1748 | if (ecc_pkey_size <= 163) | ||
| 1749 | emask|=SSL_kECDH|SSL_aRSA; | ||
| 1750 | } | ||
| 1751 | if (signature_nid == NID_ecdsa_with_SHA1) | ||
| 1752 | { | ||
| 1753 | mask|=SSL_kECDH|SSL_aECDSA; | ||
| 1754 | if (ecc_pkey_size <= 163) | ||
| 1755 | emask|=SSL_kECDH|SSL_aECDSA; | ||
| 1756 | } | ||
| 1757 | } | ||
| 1758 | #endif | ||
| 1759 | #ifndef OPENSSL_NO_ECDSA | ||
| 1760 | if (ecdsa_ok) | ||
| 1761 | { | ||
| 1762 | mask|=SSL_aECDSA; | ||
| 1763 | emask|=SSL_aECDSA; | ||
| 1764 | } | ||
| 1765 | #endif | ||
| 1766 | } | ||
| 1767 | |||
| 1768 | #ifndef OPENSSL_NO_ECDH | ||
| 1769 | if (have_ecdh_tmp) | ||
| 1770 | { | ||
| 1771 | mask|=SSL_kECDHE; | ||
| 1772 | emask|=SSL_kECDHE; | ||
| 1773 | } | ||
| 1774 | #endif | ||
| 1616 | c->mask=mask; | 1775 | c->mask=mask; |
| 1617 | c->export_mask=emask; | 1776 | c->export_mask=emask; |
| 1618 | c->valid=1; | 1777 | c->valid=1; |
| 1619 | } | 1778 | } |
| 1620 | 1779 | ||
| 1780 | /* This handy macro borrowed from crypto/x509v3/v3_purp.c */ | ||
| 1781 | #define ku_reject(x, usage) \ | ||
| 1782 | (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) | ||
| 1783 | |||
| 1784 | int check_srvr_ecc_cert_and_alg(X509 *x, SSL_CIPHER *cs) | ||
| 1785 | { | ||
| 1786 | unsigned long alg = cs->algorithms; | ||
| 1787 | EVP_PKEY *pkey = NULL; | ||
| 1788 | int keysize = 0; | ||
| 1789 | int signature_nid = 0; | ||
| 1790 | |||
| 1791 | if (SSL_C_IS_EXPORT(cs)) | ||
| 1792 | { | ||
| 1793 | /* ECDH key length in export ciphers must be <= 163 bits */ | ||
| 1794 | pkey = X509_get_pubkey(x); | ||
| 1795 | if (pkey == NULL) return 0; | ||
| 1796 | keysize = EVP_PKEY_bits(pkey); | ||
| 1797 | EVP_PKEY_free(pkey); | ||
| 1798 | if (keysize > 163) return 0; | ||
| 1799 | } | ||
| 1800 | |||
| 1801 | /* This call populates the ex_flags field correctly */ | ||
| 1802 | X509_check_purpose(x, -1, 0); | ||
| 1803 | if ((x->sig_alg) && (x->sig_alg->algorithm)) | ||
| 1804 | signature_nid = OBJ_obj2nid(x->sig_alg->algorithm); | ||
| 1805 | if (alg & SSL_kECDH) | ||
| 1806 | { | ||
| 1807 | /* key usage, if present, must allow key agreement */ | ||
| 1808 | if (ku_reject(x, X509v3_KU_KEY_AGREEMENT)) | ||
| 1809 | { | ||
| 1810 | return 0; | ||
| 1811 | } | ||
| 1812 | if (alg & SSL_aECDSA) | ||
| 1813 | { | ||
| 1814 | /* signature alg must be ECDSA */ | ||
| 1815 | if (signature_nid != NID_ecdsa_with_SHA1) | ||
| 1816 | { | ||
| 1817 | return 0; | ||
| 1818 | } | ||
| 1819 | } | ||
| 1820 | if (alg & SSL_aRSA) | ||
| 1821 | { | ||
| 1822 | /* signature alg must be RSA */ | ||
| 1823 | if ((signature_nid != NID_md5WithRSAEncryption) && | ||
| 1824 | (signature_nid != NID_md4WithRSAEncryption) && | ||
| 1825 | (signature_nid != NID_md2WithRSAEncryption)) | ||
| 1826 | { | ||
| 1827 | return 0; | ||
| 1828 | } | ||
| 1829 | } | ||
| 1830 | } | ||
| 1831 | else if (alg & SSL_aECDSA) | ||
| 1832 | { | ||
| 1833 | /* key usage, if present, must allow signing */ | ||
| 1834 | if (ku_reject(x, X509v3_KU_DIGITAL_SIGNATURE)) | ||
| 1835 | { | ||
| 1836 | return 0; | ||
| 1837 | } | ||
| 1838 | } | ||
| 1839 | |||
| 1840 | return 1; /* all checks are ok */ | ||
| 1841 | } | ||
| 1842 | |||
| 1621 | /* THIS NEEDS CLEANING UP */ | 1843 | /* THIS NEEDS CLEANING UP */ |
| 1622 | X509 *ssl_get_server_send_cert(SSL *s) | 1844 | X509 *ssl_get_server_send_cert(SSL *s) |
| 1623 | { | 1845 | { |
| @@ -1632,7 +1854,26 @@ X509 *ssl_get_server_send_cert(SSL *s) | |||
| 1632 | mask=is_export?c->export_mask:c->mask; | 1854 | mask=is_export?c->export_mask:c->mask; |
| 1633 | kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); | 1855 | kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); |
| 1634 | 1856 | ||
| 1635 | if (kalg & SSL_kDHr) | 1857 | if (kalg & SSL_kECDH) |
| 1858 | { | ||
| 1859 | /* we don't need to look at SSL_kECDHE | ||
| 1860 | * since no certificate is needed for | ||
| 1861 | * anon ECDH and for authenticated | ||
| 1862 | * ECDHE, the check for the auth | ||
| 1863 | * algorithm will set i correctly | ||
| 1864 | * NOTE: For ECDH-RSA, we need an ECC | ||
| 1865 | * not an RSA cert but for ECDHE-RSA | ||
| 1866 | * we need an RSA cert. Placing the | ||
| 1867 | * checks for SSL_kECDH before RSA | ||
| 1868 | * checks ensures the correct cert is chosen. | ||
| 1869 | */ | ||
| 1870 | i=SSL_PKEY_ECC; | ||
| 1871 | } | ||
| 1872 | else if (kalg & SSL_aECDSA) | ||
| 1873 | { | ||
| 1874 | i=SSL_PKEY_ECC; | ||
| 1875 | } | ||
| 1876 | else if (kalg & SSL_kDHr) | ||
| 1636 | i=SSL_PKEY_DH_RSA; | 1877 | i=SSL_PKEY_DH_RSA; |
| 1637 | else if (kalg & SSL_kDHd) | 1878 | else if (kalg & SSL_kDHd) |
| 1638 | i=SSL_PKEY_DH_DSA; | 1879 | i=SSL_PKEY_DH_DSA; |
| @@ -1656,6 +1897,7 @@ X509 *ssl_get_server_send_cert(SSL *s) | |||
| 1656 | return(NULL); | 1897 | return(NULL); |
| 1657 | } | 1898 | } |
| 1658 | if (c->pkeys[i].x509 == NULL) return(NULL); | 1899 | if (c->pkeys[i].x509 == NULL) return(NULL); |
| 1900 | |||
| 1659 | return(c->pkeys[i].x509); | 1901 | return(c->pkeys[i].x509); |
| 1660 | } | 1902 | } |
| 1661 | 1903 | ||
| @@ -1679,6 +1921,9 @@ EVP_PKEY *ssl_get_sign_pkey(SSL *s,SSL_CIPHER *cipher) | |||
| 1679 | else | 1921 | else |
| 1680 | return(NULL); | 1922 | return(NULL); |
| 1681 | } | 1923 | } |
| 1924 | else if ((alg & SSL_aECDSA) && | ||
| 1925 | (c->pkeys[SSL_PKEY_ECC].privatekey != NULL)) | ||
| 1926 | return(c->pkeys[SSL_PKEY_ECC].privatekey); | ||
| 1682 | else /* if (alg & SSL_aNULL) */ | 1927 | else /* if (alg & SSL_aNULL) */ |
| 1683 | { | 1928 | { |
| 1684 | SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR); | 1929 | SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR); |
| @@ -1884,6 +2129,12 @@ int ssl_undefined_function(SSL *s) | |||
| 1884 | return(0); | 2129 | return(0); |
| 1885 | } | 2130 | } |
| 1886 | 2131 | ||
| 2132 | int ssl_undefined_void_function(void) | ||
| 2133 | { | ||
| 2134 | SSLerr(SSL_F_SSL_UNDEFINED_VOID_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 2135 | return(0); | ||
| 2136 | } | ||
| 2137 | |||
| 1887 | int ssl_undefined_const_function(const SSL *s) | 2138 | int ssl_undefined_const_function(const SSL *s) |
| 1888 | { | 2139 | { |
| 1889 | SSLerr(SSL_F_SSL_UNDEFINED_CONST_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 2140 | SSLerr(SSL_F_SSL_UNDEFINED_CONST_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| @@ -1999,8 +2250,8 @@ SSL *SSL_dup(SSL *s) | |||
| 1999 | ret->rstate=s->rstate; | 2250 | ret->rstate=s->rstate; |
| 2000 | ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */ | 2251 | ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */ |
| 2001 | ret->hit=s->hit; | 2252 | ret->hit=s->hit; |
| 2002 | ret->purpose=s->purpose; | 2253 | |
| 2003 | ret->trust=s->trust; | 2254 | X509_VERIFY_PARAM_inherit(ret->param, s->param); |
| 2004 | 2255 | ||
| 2005 | /* dup the cipher_list and cipher_list_by_id stacks */ | 2256 | /* dup the cipher_list and cipher_list_by_id stacks */ |
| 2006 | if (s->cipher_list != NULL) | 2257 | if (s->cipher_list != NULL) |
| @@ -2052,6 +2303,7 @@ void ssl_clear_cipher_ctx(SSL *s) | |||
| 2052 | OPENSSL_free(s->enc_write_ctx); | 2303 | OPENSSL_free(s->enc_write_ctx); |
| 2053 | s->enc_write_ctx=NULL; | 2304 | s->enc_write_ctx=NULL; |
| 2054 | } | 2305 | } |
| 2306 | #ifndef OPENSSL_NO_COMP | ||
| 2055 | if (s->expand != NULL) | 2307 | if (s->expand != NULL) |
| 2056 | { | 2308 | { |
| 2057 | COMP_CTX_free(s->expand); | 2309 | COMP_CTX_free(s->expand); |
| @@ -2062,6 +2314,7 @@ void ssl_clear_cipher_ctx(SSL *s) | |||
| 2062 | COMP_CTX_free(s->compress); | 2314 | COMP_CTX_free(s->compress); |
| 2063 | s->compress=NULL; | 2315 | s->compress=NULL; |
| 2064 | } | 2316 | } |
| 2317 | #endif | ||
| 2065 | } | 2318 | } |
| 2066 | 2319 | ||
| 2067 | /* Fix this function so that it takes an optional type parameter */ | 2320 | /* Fix this function so that it takes an optional type parameter */ |
| @@ -2088,6 +2341,31 @@ SSL_CIPHER *SSL_get_current_cipher(const SSL *s) | |||
| 2088 | return(s->session->cipher); | 2341 | return(s->session->cipher); |
| 2089 | return(NULL); | 2342 | return(NULL); |
| 2090 | } | 2343 | } |
| 2344 | #ifdef OPENSSL_NO_COMP | ||
| 2345 | const void *SSL_get_current_compression(SSL *s) | ||
| 2346 | { | ||
| 2347 | return NULL; | ||
| 2348 | } | ||
| 2349 | const void *SSL_get_current_expansion(SSL *s) | ||
| 2350 | { | ||
| 2351 | return NULL; | ||
| 2352 | } | ||
| 2353 | #else | ||
| 2354 | |||
| 2355 | const COMP_METHOD *SSL_get_current_compression(SSL *s) | ||
| 2356 | { | ||
| 2357 | if (s->compress != NULL) | ||
| 2358 | return(s->compress->meth); | ||
| 2359 | return(NULL); | ||
| 2360 | } | ||
| 2361 | |||
| 2362 | const COMP_METHOD *SSL_get_current_expansion(SSL *s) | ||
| 2363 | { | ||
| 2364 | if (s->expand != NULL) | ||
| 2365 | return(s->expand->meth); | ||
| 2366 | return(NULL); | ||
| 2367 | } | ||
| 2368 | #endif | ||
| 2091 | 2369 | ||
| 2092 | int ssl_init_wbio_buffer(SSL *s,int push) | 2370 | int ssl_init_wbio_buffer(SSL *s,int push) |
| 2093 | { | 2371 | { |
| @@ -2181,6 +2459,24 @@ SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) | |||
| 2181 | return(ssl->ctx); | 2459 | return(ssl->ctx); |
| 2182 | } | 2460 | } |
| 2183 | 2461 | ||
| 2462 | SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) | ||
| 2463 | { | ||
| 2464 | if (ssl->ctx == ctx) | ||
| 2465 | return ssl->ctx; | ||
| 2466 | #ifndef OPENSSL_NO_TLSEXT | ||
| 2467 | if (ctx == NULL) | ||
| 2468 | ctx = ssl->initial_ctx; | ||
| 2469 | #endif | ||
| 2470 | if (ssl->cert != NULL) | ||
| 2471 | ssl_cert_free(ssl->cert); | ||
| 2472 | ssl->cert = ssl_cert_dup(ctx->cert); | ||
| 2473 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); | ||
| 2474 | if (ssl->ctx != NULL) | ||
| 2475 | SSL_CTX_free(ssl->ctx); /* decrement reference count */ | ||
| 2476 | ssl->ctx = ctx; | ||
| 2477 | return(ssl->ctx); | ||
| 2478 | } | ||
| 2479 | |||
| 2184 | #ifndef OPENSSL_NO_STDIO | 2480 | #ifndef OPENSSL_NO_STDIO |
| 2185 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) | 2481 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) |
| 2186 | { | 2482 | { |
| @@ -2190,19 +2486,19 @@ int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) | |||
| 2190 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, | 2486 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, |
| 2191 | const char *CApath) | 2487 | const char *CApath) |
| 2192 | { | 2488 | { |
| 2193 | int r; | 2489 | return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath)); |
| 2194 | r=X509_STORE_load_locations(ctx->cert_store,CAfile,CApath); | ||
| 2195 | return r; | ||
| 2196 | } | 2490 | } |
| 2197 | #endif | 2491 | #endif |
| 2198 | 2492 | ||
| 2199 | void SSL_set_info_callback(SSL *ssl, | 2493 | void SSL_set_info_callback(SSL *ssl, |
| 2200 | void (*cb)(const SSL *ssl,int type,int val)) | 2494 | void (*cb)(const SSL *ssl,int type,int val)) |
| 2201 | { | 2495 | { |
| 2202 | ssl->info_callback=cb; | 2496 | ssl->info_callback=cb; |
| 2203 | } | 2497 | } |
| 2204 | 2498 | ||
| 2205 | void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val) | 2499 | /* One compiler (Diab DCC) doesn't like argument names in returned |
| 2500 | function pointer. */ | ||
| 2501 | void (*SSL_get_info_callback(const SSL *ssl))(const SSL * /*ssl*/,int /*type*/,int /*val*/) | ||
| 2206 | { | 2502 | { |
| 2207 | return ssl->info_callback; | 2503 | return ssl->info_callback; |
| 2208 | } | 2504 | } |
| @@ -2289,14 +2585,14 @@ void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, | |||
| 2289 | int is_export, | 2585 | int is_export, |
| 2290 | int keylength)) | 2586 | int keylength)) |
| 2291 | { | 2587 | { |
| 2292 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); | 2588 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb); |
| 2293 | } | 2589 | } |
| 2294 | 2590 | ||
| 2295 | void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl, | 2591 | void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl, |
| 2296 | int is_export, | 2592 | int is_export, |
| 2297 | int keylength)) | 2593 | int keylength)) |
| 2298 | { | 2594 | { |
| 2299 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); | 2595 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb); |
| 2300 | } | 2596 | } |
| 2301 | #endif | 2597 | #endif |
| 2302 | 2598 | ||
| @@ -2325,24 +2621,38 @@ RSA *cb(SSL *ssl,int is_export,int keylength) | |||
| 2325 | void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, | 2621 | void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, |
| 2326 | int keylength)) | 2622 | int keylength)) |
| 2327 | { | 2623 | { |
| 2328 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); | 2624 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)(void))dh); |
| 2329 | } | 2625 | } |
| 2330 | 2626 | ||
| 2331 | void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, | 2627 | void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, |
| 2332 | int keylength)) | 2628 | int keylength)) |
| 2333 | { | 2629 | { |
| 2334 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); | 2630 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)(void))dh); |
| 2631 | } | ||
| 2632 | #endif | ||
| 2633 | |||
| 2634 | #ifndef OPENSSL_NO_ECDH | ||
| 2635 | void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,EC_KEY *(*ecdh)(SSL *ssl,int is_export, | ||
| 2636 | int keylength)) | ||
| 2637 | { | ||
| 2638 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); | ||
| 2639 | } | ||
| 2640 | |||
| 2641 | void SSL_set_tmp_ecdh_callback(SSL *ssl,EC_KEY *(*ecdh)(SSL *ssl,int is_export, | ||
| 2642 | int keylength)) | ||
| 2643 | { | ||
| 2644 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); | ||
| 2335 | } | 2645 | } |
| 2336 | #endif | 2646 | #endif |
| 2337 | 2647 | ||
| 2338 | 2648 | ||
| 2339 | void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) | 2649 | void SSL_CTX_set_msg_callback(SSL_CTX *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) |
| 2340 | { | 2650 | { |
| 2341 | SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb); | 2651 | SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb); |
| 2342 | } | 2652 | } |
| 2343 | void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) | 2653 | void SSL_set_msg_callback(SSL *ssl, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg)) |
| 2344 | { | 2654 | { |
| 2345 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb); | 2655 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb); |
| 2346 | } | 2656 | } |
| 2347 | 2657 | ||
| 2348 | 2658 | ||
