diff options
| author | djm <> | 2008-09-06 12:15:56 +0000 |
|---|---|---|
| committer | djm <> | 2008-09-06 12:15:56 +0000 |
| commit | 5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 (patch) | |
| tree | aba68249883aa9d2361d92eef69a81d0c4961732 /src/lib/libssl/ssl_lib.c | |
| parent | f6198d4d0ab97685dc56be2d48715ed39fcc74b9 (diff) | |
| download | openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.gz openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.bz2 openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.zip | |
import of OpenSSL 0.9.8h
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/ssl_lib.c | 410 |
1 files changed, 360 insertions, 50 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 2bd9a5af86..065411aea8 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 | { |
| @@ -1169,7 +1224,6 @@ int SSL_set_cipher_list(SSL *s,const char *str) | |||
| 1169 | char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len) | 1224 | char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len) |
| 1170 | { | 1225 | { |
| 1171 | char *p; | 1226 | char *p; |
| 1172 | const char *cp; | ||
| 1173 | STACK_OF(SSL_CIPHER) *sk; | 1227 | STACK_OF(SSL_CIPHER) *sk; |
| 1174 | SSL_CIPHER *c; | 1228 | SSL_CIPHER *c; |
| 1175 | int i; | 1229 | int i; |
| @@ -1182,20 +1236,21 @@ char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len) | |||
| 1182 | sk=s->session->ciphers; | 1236 | sk=s->session->ciphers; |
| 1183 | for (i=0; i<sk_SSL_CIPHER_num(sk); i++) | 1237 | for (i=0; i<sk_SSL_CIPHER_num(sk); i++) |
| 1184 | { | 1238 | { |
| 1185 | /* Decrement for either the ':' or a '\0' */ | 1239 | int n; |
| 1186 | len--; | 1240 | |
| 1187 | c=sk_SSL_CIPHER_value(sk,i); | 1241 | c=sk_SSL_CIPHER_value(sk,i); |
| 1188 | for (cp=c->name; *cp; ) | 1242 | n=strlen(c->name); |
| 1243 | if (n+1 > len) | ||
| 1189 | { | 1244 | { |
| 1190 | if (len-- == 0) | 1245 | if (p != buf) |
| 1191 | { | 1246 | --p; |
| 1192 | *p='\0'; | 1247 | *p='\0'; |
| 1193 | return(buf); | 1248 | return buf; |
| 1194 | } | ||
| 1195 | else | ||
| 1196 | *(p++)= *(cp++); | ||
| 1197 | } | 1249 | } |
| 1250 | strcpy(p,c->name); | ||
| 1251 | p+=n; | ||
| 1198 | *(p++)=':'; | 1252 | *(p++)=':'; |
| 1253 | len-=n+1; | ||
| 1199 | } | 1254 | } |
| 1200 | p[-1]='\0'; | 1255 | p[-1]='\0'; |
| 1201 | return(buf); | 1256 | return(buf); |
| @@ -1272,6 +1327,29 @@ err: | |||
| 1272 | return(NULL); | 1327 | return(NULL); |
| 1273 | } | 1328 | } |
| 1274 | 1329 | ||
| 1330 | #ifndef OPENSSL_NO_TLSEXT | ||
| 1331 | /** return a servername extension value if provided in Client Hello, or NULL. | ||
| 1332 | * So far, only host_name types are defined (RFC 3546). | ||
| 1333 | */ | ||
| 1334 | |||
| 1335 | const char *SSL_get_servername(const SSL *s, const int type) | ||
| 1336 | { | ||
| 1337 | if (type != TLSEXT_NAMETYPE_host_name) | ||
| 1338 | return NULL; | ||
| 1339 | |||
| 1340 | return s->session && !s->tlsext_hostname ? | ||
| 1341 | s->session->tlsext_hostname : | ||
| 1342 | s->tlsext_hostname; | ||
| 1343 | } | ||
| 1344 | |||
| 1345 | int SSL_get_servername_type(const SSL *s) | ||
| 1346 | { | ||
| 1347 | if (s->session && (!s->tlsext_hostname ? s->session->tlsext_hostname : s->tlsext_hostname)) | ||
| 1348 | return TLSEXT_NAMETYPE_host_name; | ||
| 1349 | return -1; | ||
| 1350 | } | ||
| 1351 | #endif | ||
| 1352 | |||
| 1275 | unsigned long SSL_SESSION_hash(const SSL_SESSION *a) | 1353 | unsigned long SSL_SESSION_hash(const SSL_SESSION *a) |
| 1276 | { | 1354 | { |
| 1277 | unsigned long l; | 1355 | unsigned long l; |
| @@ -1315,14 +1393,6 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1315 | return(NULL); | 1393 | return(NULL); |
| 1316 | } | 1394 | } |
| 1317 | 1395 | ||
| 1318 | #ifdef OPENSSL_FIPS | ||
| 1319 | if (FIPS_mode() && (meth->version < TLS1_VERSION)) | ||
| 1320 | { | ||
| 1321 | SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE); | ||
| 1322 | return NULL; | ||
| 1323 | } | ||
| 1324 | #endif | ||
| 1325 | |||
| 1326 | if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) | 1396 | if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) |
| 1327 | { | 1397 | { |
| 1328 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); | 1398 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); |
| @@ -1371,7 +1441,9 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1371 | ret->msg_callback=0; | 1441 | ret->msg_callback=0; |
| 1372 | ret->msg_callback_arg=NULL; | 1442 | ret->msg_callback_arg=NULL; |
| 1373 | ret->verify_mode=SSL_VERIFY_NONE; | 1443 | ret->verify_mode=SSL_VERIFY_NONE; |
| 1444 | #if 0 | ||
| 1374 | ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ | 1445 | ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ |
| 1446 | #endif | ||
| 1375 | ret->sid_ctx_length=0; | 1447 | ret->sid_ctx_length=0; |
| 1376 | ret->default_verify_callback=NULL; | 1448 | ret->default_verify_callback=NULL; |
| 1377 | if ((ret->cert=ssl_cert_new()) == NULL) | 1449 | if ((ret->cert=ssl_cert_new()) == NULL) |
| @@ -1380,6 +1452,8 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1380 | ret->default_passwd_callback=0; | 1452 | ret->default_passwd_callback=0; |
| 1381 | ret->default_passwd_callback_userdata=NULL; | 1453 | ret->default_passwd_callback_userdata=NULL; |
| 1382 | ret->client_cert_cb=0; | 1454 | ret->client_cert_cb=0; |
| 1455 | ret->app_gen_cookie_cb=0; | ||
| 1456 | ret->app_verify_cookie_cb=0; | ||
| 1383 | 1457 | ||
| 1384 | ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash), | 1458 | ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash), |
| 1385 | LHASH_COMP_FN(SSL_SESSION_cmp)); | 1459 | LHASH_COMP_FN(SSL_SESSION_cmp)); |
| @@ -1397,6 +1471,10 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1397 | goto err2; | 1471 | goto err2; |
| 1398 | } | 1472 | } |
| 1399 | 1473 | ||
| 1474 | ret->param = X509_VERIFY_PARAM_new(); | ||
| 1475 | if (!ret->param) | ||
| 1476 | goto err; | ||
| 1477 | |||
| 1400 | if ((ret->rsa_md5=EVP_get_digestbyname("ssl2-md5")) == NULL) | 1478 | if ((ret->rsa_md5=EVP_get_digestbyname("ssl2-md5")) == NULL) |
| 1401 | { | 1479 | { |
| 1402 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES); | 1480 | SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES); |
| @@ -1421,6 +1499,20 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) | |||
| 1421 | ret->extra_certs=NULL; | 1499 | ret->extra_certs=NULL; |
| 1422 | ret->comp_methods=SSL_COMP_get_compression_methods(); | 1500 | ret->comp_methods=SSL_COMP_get_compression_methods(); |
| 1423 | 1501 | ||
| 1502 | #ifndef OPENSSL_NO_TLSEXT | ||
| 1503 | ret->tlsext_servername_callback = 0; | ||
| 1504 | ret->tlsext_servername_arg = NULL; | ||
| 1505 | /* Setup RFC4507 ticket keys */ | ||
| 1506 | if ((RAND_pseudo_bytes(ret->tlsext_tick_key_name, 16) <= 0) | ||
| 1507 | || (RAND_bytes(ret->tlsext_tick_hmac_key, 16) <= 0) | ||
| 1508 | || (RAND_bytes(ret->tlsext_tick_aes_key, 16) <= 0)) | ||
| 1509 | ret->options |= SSL_OP_NO_TICKET; | ||
| 1510 | |||
| 1511 | ret->tlsext_status_cb = 0; | ||
| 1512 | ret->tlsext_status_arg = NULL; | ||
| 1513 | |||
| 1514 | #endif | ||
| 1515 | |||
| 1424 | return(ret); | 1516 | return(ret); |
| 1425 | err: | 1517 | err: |
| 1426 | SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE); | 1518 | SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE); |
| @@ -1453,6 +1545,9 @@ void SSL_CTX_free(SSL_CTX *a) | |||
| 1453 | } | 1545 | } |
| 1454 | #endif | 1546 | #endif |
| 1455 | 1547 | ||
| 1548 | if (a->param) | ||
| 1549 | X509_VERIFY_PARAM_free(a->param); | ||
| 1550 | |||
| 1456 | /* | 1551 | /* |
| 1457 | * Free internal session cache. However: the remove_cb() may reference | 1552 | * Free internal session cache. However: the remove_cb() may reference |
| 1458 | * the ex_data of SSL_CTX, thus the ex_data store can only be removed | 1553 | * the ex_data of SSL_CTX, thus the ex_data store can only be removed |
| @@ -1515,7 +1610,7 @@ void SSL_CTX_set_verify(SSL_CTX *ctx,int mode,int (*cb)(int, X509_STORE_CTX *)) | |||
| 1515 | 1610 | ||
| 1516 | void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) | 1611 | void SSL_CTX_set_verify_depth(SSL_CTX *ctx,int depth) |
| 1517 | { | 1612 | { |
| 1518 | ctx->verify_depth=depth; | 1613 | X509_VERIFY_PARAM_set_depth(ctx->param, depth); |
| 1519 | } | 1614 | } |
| 1520 | 1615 | ||
| 1521 | void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | 1616 | void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) |
| @@ -1525,6 +1620,13 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1525 | int rsa_enc_export,dh_rsa_export,dh_dsa_export; | 1620 | int rsa_enc_export,dh_rsa_export,dh_dsa_export; |
| 1526 | int rsa_tmp_export,dh_tmp_export,kl; | 1621 | int rsa_tmp_export,dh_tmp_export,kl; |
| 1527 | unsigned long mask,emask; | 1622 | unsigned long mask,emask; |
| 1623 | int have_ecc_cert, ecdh_ok, ecdsa_ok, ecc_pkey_size; | ||
| 1624 | #ifndef OPENSSL_NO_ECDH | ||
| 1625 | int have_ecdh_tmp; | ||
| 1626 | #endif | ||
| 1627 | X509 *x = NULL; | ||
| 1628 | EVP_PKEY *ecc_pkey = NULL; | ||
| 1629 | int signature_nid = 0; | ||
| 1528 | 1630 | ||
| 1529 | if (c == NULL) return; | 1631 | if (c == NULL) return; |
| 1530 | 1632 | ||
| @@ -1545,6 +1647,9 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1545 | dh_tmp=dh_tmp_export=0; | 1647 | dh_tmp=dh_tmp_export=0; |
| 1546 | #endif | 1648 | #endif |
| 1547 | 1649 | ||
| 1650 | #ifndef OPENSSL_NO_ECDH | ||
| 1651 | have_ecdh_tmp=(c->ecdh_tmp != NULL || c->ecdh_tmp_cb != NULL); | ||
| 1652 | #endif | ||
| 1548 | cpk= &(c->pkeys[SSL_PKEY_RSA_ENC]); | 1653 | cpk= &(c->pkeys[SSL_PKEY_RSA_ENC]); |
| 1549 | rsa_enc= (cpk->x509 != NULL && cpk->privatekey != NULL); | 1654 | rsa_enc= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1550 | rsa_enc_export=(rsa_enc && EVP_PKEY_size(cpk->privatekey)*8 <= kl); | 1655 | rsa_enc_export=(rsa_enc && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| @@ -1559,7 +1664,8 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1559 | /* FIX THIS EAY EAY EAY */ | 1664 | /* FIX THIS EAY EAY EAY */ |
| 1560 | dh_dsa= (cpk->x509 != NULL && cpk->privatekey != NULL); | 1665 | dh_dsa= (cpk->x509 != NULL && cpk->privatekey != NULL); |
| 1561 | dh_dsa_export=(dh_dsa && EVP_PKEY_size(cpk->privatekey)*8 <= kl); | 1666 | dh_dsa_export=(dh_dsa && EVP_PKEY_size(cpk->privatekey)*8 <= kl); |
| 1562 | 1667 | cpk= &(c->pkeys[SSL_PKEY_ECC]); | |
| 1668 | have_ecc_cert= (cpk->x509 != NULL && cpk->privatekey != NULL); | ||
| 1563 | mask=0; | 1669 | mask=0; |
| 1564 | emask=0; | 1670 | emask=0; |
| 1565 | 1671 | ||
| @@ -1616,11 +1722,127 @@ void ssl_set_cert_masks(CERT *c, SSL_CIPHER *cipher) | |||
| 1616 | emask|=SSL_kKRB5|SSL_aKRB5; | 1722 | emask|=SSL_kKRB5|SSL_aKRB5; |
| 1617 | #endif | 1723 | #endif |
| 1618 | 1724 | ||
| 1725 | /* An ECC certificate may be usable for ECDH and/or | ||
| 1726 | * ECDSA cipher suites depending on the key usage extension. | ||
| 1727 | */ | ||
| 1728 | if (have_ecc_cert) | ||
| 1729 | { | ||
| 1730 | /* This call populates extension flags (ex_flags) */ | ||
| 1731 | x = (c->pkeys[SSL_PKEY_ECC]).x509; | ||
| 1732 | X509_check_purpose(x, -1, 0); | ||
| 1733 | ecdh_ok = (x->ex_flags & EXFLAG_KUSAGE) ? | ||
| 1734 | (x->ex_kusage & X509v3_KU_KEY_AGREEMENT) : 1; | ||
| 1735 | ecdsa_ok = (x->ex_flags & EXFLAG_KUSAGE) ? | ||
| 1736 | (x->ex_kusage & X509v3_KU_DIGITAL_SIGNATURE) : 1; | ||
| 1737 | ecc_pkey = X509_get_pubkey(x); | ||
| 1738 | ecc_pkey_size = (ecc_pkey != NULL) ? | ||
| 1739 | EVP_PKEY_bits(ecc_pkey) : 0; | ||
| 1740 | EVP_PKEY_free(ecc_pkey); | ||
| 1741 | if ((x->sig_alg) && (x->sig_alg->algorithm)) | ||
| 1742 | signature_nid = OBJ_obj2nid(x->sig_alg->algorithm); | ||
| 1743 | #ifndef OPENSSL_NO_ECDH | ||
| 1744 | if (ecdh_ok) | ||
| 1745 | { | ||
| 1746 | if ((signature_nid == NID_md5WithRSAEncryption) || | ||
| 1747 | (signature_nid == NID_md4WithRSAEncryption) || | ||
| 1748 | (signature_nid == NID_md2WithRSAEncryption)) | ||
| 1749 | { | ||
| 1750 | mask|=SSL_kECDH|SSL_aRSA; | ||
| 1751 | if (ecc_pkey_size <= 163) | ||
| 1752 | emask|=SSL_kECDH|SSL_aRSA; | ||
| 1753 | } | ||
| 1754 | if (signature_nid == NID_ecdsa_with_SHA1) | ||
| 1755 | { | ||
| 1756 | mask|=SSL_kECDH|SSL_aECDSA; | ||
| 1757 | if (ecc_pkey_size <= 163) | ||
| 1758 | emask|=SSL_kECDH|SSL_aECDSA; | ||
| 1759 | } | ||
| 1760 | } | ||
| 1761 | #endif | ||
| 1762 | #ifndef OPENSSL_NO_ECDSA | ||
| 1763 | if (ecdsa_ok) | ||
| 1764 | { | ||
| 1765 | mask|=SSL_aECDSA; | ||
| 1766 | emask|=SSL_aECDSA; | ||
| 1767 | } | ||
| 1768 | #endif | ||
| 1769 | } | ||
| 1770 | |||
| 1771 | #ifndef OPENSSL_NO_ECDH | ||
| 1772 | if (have_ecdh_tmp) | ||
| 1773 | { | ||
| 1774 | mask|=SSL_kECDHE; | ||
| 1775 | emask|=SSL_kECDHE; | ||
| 1776 | } | ||
| 1777 | #endif | ||
| 1619 | c->mask=mask; | 1778 | c->mask=mask; |
| 1620 | c->export_mask=emask; | 1779 | c->export_mask=emask; |
| 1621 | c->valid=1; | 1780 | c->valid=1; |
| 1622 | } | 1781 | } |
| 1623 | 1782 | ||
| 1783 | /* This handy macro borrowed from crypto/x509v3/v3_purp.c */ | ||
| 1784 | #define ku_reject(x, usage) \ | ||
| 1785 | (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage))) | ||
| 1786 | |||
| 1787 | int check_srvr_ecc_cert_and_alg(X509 *x, SSL_CIPHER *cs) | ||
| 1788 | { | ||
| 1789 | unsigned long alg = cs->algorithms; | ||
| 1790 | EVP_PKEY *pkey = NULL; | ||
| 1791 | int keysize = 0; | ||
| 1792 | int signature_nid = 0; | ||
| 1793 | |||
| 1794 | if (SSL_C_IS_EXPORT(cs)) | ||
| 1795 | { | ||
| 1796 | /* ECDH key length in export ciphers must be <= 163 bits */ | ||
| 1797 | pkey = X509_get_pubkey(x); | ||
| 1798 | if (pkey == NULL) return 0; | ||
| 1799 | keysize = EVP_PKEY_bits(pkey); | ||
| 1800 | EVP_PKEY_free(pkey); | ||
| 1801 | if (keysize > 163) return 0; | ||
| 1802 | } | ||
| 1803 | |||
| 1804 | /* This call populates the ex_flags field correctly */ | ||
| 1805 | X509_check_purpose(x, -1, 0); | ||
| 1806 | if ((x->sig_alg) && (x->sig_alg->algorithm)) | ||
| 1807 | signature_nid = OBJ_obj2nid(x->sig_alg->algorithm); | ||
| 1808 | if (alg & SSL_kECDH) | ||
| 1809 | { | ||
| 1810 | /* key usage, if present, must allow key agreement */ | ||
| 1811 | if (ku_reject(x, X509v3_KU_KEY_AGREEMENT)) | ||
| 1812 | { | ||
| 1813 | return 0; | ||
| 1814 | } | ||
| 1815 | if (alg & SSL_aECDSA) | ||
| 1816 | { | ||
| 1817 | /* signature alg must be ECDSA */ | ||
| 1818 | if (signature_nid != NID_ecdsa_with_SHA1) | ||
| 1819 | { | ||
| 1820 | return 0; | ||
| 1821 | } | ||
| 1822 | } | ||
| 1823 | if (alg & SSL_aRSA) | ||
| 1824 | { | ||
| 1825 | /* signature alg must be RSA */ | ||
| 1826 | if ((signature_nid != NID_md5WithRSAEncryption) && | ||
| 1827 | (signature_nid != NID_md4WithRSAEncryption) && | ||
| 1828 | (signature_nid != NID_md2WithRSAEncryption)) | ||
| 1829 | { | ||
| 1830 | return 0; | ||
| 1831 | } | ||
| 1832 | } | ||
| 1833 | } | ||
| 1834 | else if (alg & SSL_aECDSA) | ||
| 1835 | { | ||
| 1836 | /* key usage, if present, must allow signing */ | ||
| 1837 | if (ku_reject(x, X509v3_KU_DIGITAL_SIGNATURE)) | ||
| 1838 | { | ||
| 1839 | return 0; | ||
| 1840 | } | ||
| 1841 | } | ||
| 1842 | |||
| 1843 | return 1; /* all checks are ok */ | ||
| 1844 | } | ||
| 1845 | |||
| 1624 | /* THIS NEEDS CLEANING UP */ | 1846 | /* THIS NEEDS CLEANING UP */ |
| 1625 | X509 *ssl_get_server_send_cert(SSL *s) | 1847 | X509 *ssl_get_server_send_cert(SSL *s) |
| 1626 | { | 1848 | { |
| @@ -1635,7 +1857,26 @@ X509 *ssl_get_server_send_cert(SSL *s) | |||
| 1635 | mask=is_export?c->export_mask:c->mask; | 1857 | mask=is_export?c->export_mask:c->mask; |
| 1636 | kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); | 1858 | kalg=alg&(SSL_MKEY_MASK|SSL_AUTH_MASK); |
| 1637 | 1859 | ||
| 1638 | if (kalg & SSL_kDHr) | 1860 | if (kalg & SSL_kECDH) |
| 1861 | { | ||
| 1862 | /* we don't need to look at SSL_kECDHE | ||
| 1863 | * since no certificate is needed for | ||
| 1864 | * anon ECDH and for authenticated | ||
| 1865 | * ECDHE, the check for the auth | ||
| 1866 | * algorithm will set i correctly | ||
| 1867 | * NOTE: For ECDH-RSA, we need an ECC | ||
| 1868 | * not an RSA cert but for ECDHE-RSA | ||
| 1869 | * we need an RSA cert. Placing the | ||
| 1870 | * checks for SSL_kECDH before RSA | ||
| 1871 | * checks ensures the correct cert is chosen. | ||
| 1872 | */ | ||
| 1873 | i=SSL_PKEY_ECC; | ||
| 1874 | } | ||
| 1875 | else if (kalg & SSL_aECDSA) | ||
| 1876 | { | ||
| 1877 | i=SSL_PKEY_ECC; | ||
| 1878 | } | ||
| 1879 | else if (kalg & SSL_kDHr) | ||
| 1639 | i=SSL_PKEY_DH_RSA; | 1880 | i=SSL_PKEY_DH_RSA; |
| 1640 | else if (kalg & SSL_kDHd) | 1881 | else if (kalg & SSL_kDHd) |
| 1641 | i=SSL_PKEY_DH_DSA; | 1882 | i=SSL_PKEY_DH_DSA; |
| @@ -1659,6 +1900,7 @@ X509 *ssl_get_server_send_cert(SSL *s) | |||
| 1659 | return(NULL); | 1900 | return(NULL); |
| 1660 | } | 1901 | } |
| 1661 | if (c->pkeys[i].x509 == NULL) return(NULL); | 1902 | if (c->pkeys[i].x509 == NULL) return(NULL); |
| 1903 | |||
| 1662 | return(c->pkeys[i].x509); | 1904 | return(c->pkeys[i].x509); |
| 1663 | } | 1905 | } |
| 1664 | 1906 | ||
| @@ -1682,6 +1924,9 @@ EVP_PKEY *ssl_get_sign_pkey(SSL *s,SSL_CIPHER *cipher) | |||
| 1682 | else | 1924 | else |
| 1683 | return(NULL); | 1925 | return(NULL); |
| 1684 | } | 1926 | } |
| 1927 | else if ((alg & SSL_aECDSA) && | ||
| 1928 | (c->pkeys[SSL_PKEY_ECC].privatekey != NULL)) | ||
| 1929 | return(c->pkeys[SSL_PKEY_ECC].privatekey); | ||
| 1685 | else /* if (alg & SSL_aNULL) */ | 1930 | else /* if (alg & SSL_aNULL) */ |
| 1686 | { | 1931 | { |
| 1687 | SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR); | 1932 | SSLerr(SSL_F_SSL_GET_SIGN_PKEY,ERR_R_INTERNAL_ERROR); |
| @@ -1887,6 +2132,12 @@ int ssl_undefined_function(SSL *s) | |||
| 1887 | return(0); | 2132 | return(0); |
| 1888 | } | 2133 | } |
| 1889 | 2134 | ||
| 2135 | int ssl_undefined_void_function(void) | ||
| 2136 | { | ||
| 2137 | SSLerr(SSL_F_SSL_UNDEFINED_VOID_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | ||
| 2138 | return(0); | ||
| 2139 | } | ||
| 2140 | |||
| 1890 | int ssl_undefined_const_function(const SSL *s) | 2141 | int ssl_undefined_const_function(const SSL *s) |
| 1891 | { | 2142 | { |
| 1892 | SSLerr(SSL_F_SSL_UNDEFINED_CONST_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 2143 | SSLerr(SSL_F_SSL_UNDEFINED_CONST_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); |
| @@ -2002,8 +2253,8 @@ SSL *SSL_dup(SSL *s) | |||
| 2002 | ret->rstate=s->rstate; | 2253 | ret->rstate=s->rstate; |
| 2003 | ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */ | 2254 | ret->init_num = 0; /* would have to copy ret->init_buf, ret->init_msg, ret->init_num, ret->init_off */ |
| 2004 | ret->hit=s->hit; | 2255 | ret->hit=s->hit; |
| 2005 | ret->purpose=s->purpose; | 2256 | |
| 2006 | ret->trust=s->trust; | 2257 | X509_VERIFY_PARAM_inherit(ret->param, s->param); |
| 2007 | 2258 | ||
| 2008 | /* dup the cipher_list and cipher_list_by_id stacks */ | 2259 | /* dup the cipher_list and cipher_list_by_id stacks */ |
| 2009 | if (s->cipher_list != NULL) | 2260 | if (s->cipher_list != NULL) |
| @@ -2055,6 +2306,7 @@ void ssl_clear_cipher_ctx(SSL *s) | |||
| 2055 | OPENSSL_free(s->enc_write_ctx); | 2306 | OPENSSL_free(s->enc_write_ctx); |
| 2056 | s->enc_write_ctx=NULL; | 2307 | s->enc_write_ctx=NULL; |
| 2057 | } | 2308 | } |
| 2309 | #ifndef OPENSSL_NO_COMP | ||
| 2058 | if (s->expand != NULL) | 2310 | if (s->expand != NULL) |
| 2059 | { | 2311 | { |
| 2060 | COMP_CTX_free(s->expand); | 2312 | COMP_CTX_free(s->expand); |
| @@ -2065,6 +2317,7 @@ void ssl_clear_cipher_ctx(SSL *s) | |||
| 2065 | COMP_CTX_free(s->compress); | 2317 | COMP_CTX_free(s->compress); |
| 2066 | s->compress=NULL; | 2318 | s->compress=NULL; |
| 2067 | } | 2319 | } |
| 2320 | #endif | ||
| 2068 | } | 2321 | } |
| 2069 | 2322 | ||
| 2070 | /* Fix this function so that it takes an optional type parameter */ | 2323 | /* Fix this function so that it takes an optional type parameter */ |
| @@ -2091,6 +2344,31 @@ SSL_CIPHER *SSL_get_current_cipher(const SSL *s) | |||
| 2091 | return(s->session->cipher); | 2344 | return(s->session->cipher); |
| 2092 | return(NULL); | 2345 | return(NULL); |
| 2093 | } | 2346 | } |
| 2347 | #ifdef OPENSSL_NO_COMP | ||
| 2348 | const void *SSL_get_current_compression(SSL *s) | ||
| 2349 | { | ||
| 2350 | return NULL; | ||
| 2351 | } | ||
| 2352 | const void *SSL_get_current_expansion(SSL *s) | ||
| 2353 | { | ||
| 2354 | return NULL; | ||
| 2355 | } | ||
| 2356 | #else | ||
| 2357 | |||
| 2358 | const COMP_METHOD *SSL_get_current_compression(SSL *s) | ||
| 2359 | { | ||
| 2360 | if (s->compress != NULL) | ||
| 2361 | return(s->compress->meth); | ||
| 2362 | return(NULL); | ||
| 2363 | } | ||
| 2364 | |||
| 2365 | const COMP_METHOD *SSL_get_current_expansion(SSL *s) | ||
| 2366 | { | ||
| 2367 | if (s->expand != NULL) | ||
| 2368 | return(s->expand->meth); | ||
| 2369 | return(NULL); | ||
| 2370 | } | ||
| 2371 | #endif | ||
| 2094 | 2372 | ||
| 2095 | int ssl_init_wbio_buffer(SSL *s,int push) | 2373 | int ssl_init_wbio_buffer(SSL *s,int push) |
| 2096 | { | 2374 | { |
| @@ -2184,6 +2462,24 @@ SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) | |||
| 2184 | return(ssl->ctx); | 2462 | return(ssl->ctx); |
| 2185 | } | 2463 | } |
| 2186 | 2464 | ||
| 2465 | SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) | ||
| 2466 | { | ||
| 2467 | if (ssl->ctx == ctx) | ||
| 2468 | return ssl->ctx; | ||
| 2469 | #ifndef OPENSSL_NO_TLSEXT | ||
| 2470 | if (ctx == NULL) | ||
| 2471 | ctx = ssl->initial_ctx; | ||
| 2472 | #endif | ||
| 2473 | if (ssl->cert != NULL) | ||
| 2474 | ssl_cert_free(ssl->cert); | ||
| 2475 | ssl->cert = ssl_cert_dup(ctx->cert); | ||
| 2476 | CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX); | ||
| 2477 | if (ssl->ctx != NULL) | ||
| 2478 | SSL_CTX_free(ssl->ctx); /* decrement reference count */ | ||
| 2479 | ssl->ctx = ctx; | ||
| 2480 | return(ssl->ctx); | ||
| 2481 | } | ||
| 2482 | |||
| 2187 | #ifndef OPENSSL_NO_STDIO | 2483 | #ifndef OPENSSL_NO_STDIO |
| 2188 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) | 2484 | int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) |
| 2189 | { | 2485 | { |
| @@ -2193,19 +2489,19 @@ int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx) | |||
| 2193 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, | 2489 | int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, |
| 2194 | const char *CApath) | 2490 | const char *CApath) |
| 2195 | { | 2491 | { |
| 2196 | int r; | 2492 | return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath)); |
| 2197 | r=X509_STORE_load_locations(ctx->cert_store,CAfile,CApath); | ||
| 2198 | return r; | ||
| 2199 | } | 2493 | } |
| 2200 | #endif | 2494 | #endif |
| 2201 | 2495 | ||
| 2202 | void SSL_set_info_callback(SSL *ssl, | 2496 | void SSL_set_info_callback(SSL *ssl, |
| 2203 | void (*cb)(const SSL *ssl,int type,int val)) | 2497 | void (*cb)(const SSL *ssl,int type,int val)) |
| 2204 | { | 2498 | { |
| 2205 | ssl->info_callback=cb; | 2499 | ssl->info_callback=cb; |
| 2206 | } | 2500 | } |
| 2207 | 2501 | ||
| 2208 | void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val) | 2502 | /* One compiler (Diab DCC) doesn't like argument names in returned |
| 2503 | function pointer. */ | ||
| 2504 | void (*SSL_get_info_callback(const SSL *ssl))(const SSL * /*ssl*/,int /*type*/,int /*val*/) | ||
| 2209 | { | 2505 | { |
| 2210 | return ssl->info_callback; | 2506 | return ssl->info_callback; |
| 2211 | } | 2507 | } |
| @@ -2292,14 +2588,14 @@ void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, | |||
| 2292 | int is_export, | 2588 | int is_export, |
| 2293 | int keylength)) | 2589 | int keylength)) |
| 2294 | { | 2590 | { |
| 2295 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); | 2591 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb); |
| 2296 | } | 2592 | } |
| 2297 | 2593 | ||
| 2298 | void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl, | 2594 | void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl, |
| 2299 | int is_export, | 2595 | int is_export, |
| 2300 | int keylength)) | 2596 | int keylength)) |
| 2301 | { | 2597 | { |
| 2302 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); | 2598 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb); |
| 2303 | } | 2599 | } |
| 2304 | #endif | 2600 | #endif |
| 2305 | 2601 | ||
| @@ -2328,24 +2624,38 @@ RSA *cb(SSL *ssl,int is_export,int keylength) | |||
| 2328 | void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, | 2624 | void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, |
| 2329 | int keylength)) | 2625 | int keylength)) |
| 2330 | { | 2626 | { |
| 2331 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); | 2627 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)(void))dh); |
| 2332 | } | 2628 | } |
| 2333 | 2629 | ||
| 2334 | void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, | 2630 | void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, |
| 2335 | int keylength)) | 2631 | int keylength)) |
| 2336 | { | 2632 | { |
| 2337 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); | 2633 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)(void))dh); |
| 2634 | } | ||
| 2635 | #endif | ||
| 2636 | |||
| 2637 | #ifndef OPENSSL_NO_ECDH | ||
| 2638 | void SSL_CTX_set_tmp_ecdh_callback(SSL_CTX *ctx,EC_KEY *(*ecdh)(SSL *ssl,int is_export, | ||
| 2639 | int keylength)) | ||
| 2640 | { | ||
| 2641 | SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); | ||
| 2642 | } | ||
| 2643 | |||
| 2644 | void SSL_set_tmp_ecdh_callback(SSL *ssl,EC_KEY *(*ecdh)(SSL *ssl,int is_export, | ||
| 2645 | int keylength)) | ||
| 2646 | { | ||
| 2647 | SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH_CB,(void (*)(void))ecdh); | ||
| 2338 | } | 2648 | } |
| 2339 | #endif | 2649 | #endif |
| 2340 | 2650 | ||
| 2341 | 2651 | ||
| 2342 | 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)) | 2652 | 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)) |
| 2343 | { | 2653 | { |
| 2344 | SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb); | 2654 | SSL_CTX_callback_ctrl(ctx, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb); |
| 2345 | } | 2655 | } |
| 2346 | 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)) | 2656 | 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)) |
| 2347 | { | 2657 | { |
| 2348 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)())cb); | 2658 | SSL_callback_ctrl(ssl, SSL_CTRL_SET_MSG_CALLBACK, (void (*)(void))cb); |
| 2349 | } | 2659 | } |
| 2350 | 2660 | ||
| 2351 | 2661 | ||
