summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/ssl_lib.c')
-rw-r--r--src/lib/libssl/ssl_lib.c103
1 files changed, 43 insertions, 60 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c
index 631229558f..ee9a82d586 100644
--- a/src/lib/libssl/ssl_lib.c
+++ b/src/lib/libssl/ssl_lib.c
@@ -121,7 +121,6 @@
121#include <openssl/objects.h> 121#include <openssl/objects.h>
122#include <openssl/lhash.h> 122#include <openssl/lhash.h>
123#include <openssl/x509v3.h> 123#include <openssl/x509v3.h>
124#include <openssl/fips.h>
125 124
126const char *SSL_version_str=OPENSSL_VERSION_TEXT; 125const char *SSL_version_str=OPENSSL_VERSION_TEXT;
127 126
@@ -501,18 +500,18 @@ void SSL_set_bio(SSL *s,BIO *rbio,BIO *wbio)
501 s->wbio=wbio; 500 s->wbio=wbio;
502 } 501 }
503 502
504BIO *SSL_get_rbio(const SSL *s) 503BIO *SSL_get_rbio(SSL *s)
505 { return(s->rbio); } 504 { return(s->rbio); }
506 505
507BIO *SSL_get_wbio(const SSL *s) 506BIO *SSL_get_wbio(SSL *s)
508 { return(s->wbio); } 507 { return(s->wbio); }
509 508
510int SSL_get_fd(const SSL *s) 509int SSL_get_fd(SSL *s)
511 { 510 {
512 return(SSL_get_rfd(s)); 511 return(SSL_get_rfd(s));
513 } 512 }
514 513
515int SSL_get_rfd(const SSL *s) 514int SSL_get_rfd(SSL *s)
516 { 515 {
517 int ret= -1; 516 int ret= -1;
518 BIO *b,*r; 517 BIO *b,*r;
@@ -524,7 +523,7 @@ int SSL_get_rfd(const SSL *s)
524 return(ret); 523 return(ret);
525 } 524 }
526 525
527int SSL_get_wfd(const SSL *s) 526int SSL_get_wfd(SSL *s)
528 { 527 {
529 int ret= -1; 528 int ret= -1;
530 BIO *b,*r; 529 BIO *b,*r;
@@ -606,7 +605,7 @@ err:
606 605
607 606
608/* return length of latest Finished message we sent, copy to 'buf' */ 607/* return length of latest Finished message we sent, copy to 'buf' */
609size_t SSL_get_finished(const SSL *s, void *buf, size_t count) 608size_t SSL_get_finished(SSL *s, void *buf, size_t count)
610 { 609 {
611 size_t ret = 0; 610 size_t ret = 0;
612 611
@@ -621,7 +620,7 @@ size_t SSL_get_finished(const SSL *s, void *buf, size_t count)
621 } 620 }
622 621
623/* return length of latest Finished message we expected, copy to 'buf' */ 622/* return length of latest Finished message we expected, copy to 'buf' */
624size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count) 623size_t SSL_get_peer_finished(SSL *s, void *buf, size_t count)
625 { 624 {
626 size_t ret = 0; 625 size_t ret = 0;
627 626
@@ -636,32 +635,32 @@ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count)
636 } 635 }
637 636
638 637
639int SSL_get_verify_mode(const SSL *s) 638int SSL_get_verify_mode(SSL *s)
640 { 639 {
641 return(s->verify_mode); 640 return(s->verify_mode);
642 } 641 }
643 642
644int SSL_get_verify_depth(const SSL *s) 643int SSL_get_verify_depth(SSL *s)
645 { 644 {
646 return(s->verify_depth); 645 return(s->verify_depth);
647 } 646 }
648 647
649int (*SSL_get_verify_callback(const SSL *s))(int,X509_STORE_CTX *) 648int (*SSL_get_verify_callback(SSL *s))(int,X509_STORE_CTX *)
650 { 649 {
651 return(s->verify_callback); 650 return(s->verify_callback);
652 } 651 }
653 652
654int SSL_CTX_get_verify_mode(const SSL_CTX *ctx) 653int SSL_CTX_get_verify_mode(SSL_CTX *ctx)
655 { 654 {
656 return(ctx->verify_mode); 655 return(ctx->verify_mode);
657 } 656 }
658 657
659int SSL_CTX_get_verify_depth(const SSL_CTX *ctx) 658int SSL_CTX_get_verify_depth(SSL_CTX *ctx)
660 { 659 {
661 return(ctx->verify_depth); 660 return(ctx->verify_depth);
662 } 661 }
663 662
664int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx))(int,X509_STORE_CTX *) 663int (*SSL_CTX_get_verify_callback(SSL_CTX *ctx))(int,X509_STORE_CTX *)
665 { 664 {
666 return(ctx->default_verify_callback); 665 return(ctx->default_verify_callback);
667 } 666 }
@@ -684,12 +683,12 @@ void SSL_set_read_ahead(SSL *s,int yes)
684 s->read_ahead=yes; 683 s->read_ahead=yes;
685 } 684 }
686 685
687int SSL_get_read_ahead(const SSL *s) 686int SSL_get_read_ahead(SSL *s)
688 { 687 {
689 return(s->read_ahead); 688 return(s->read_ahead);
690 } 689 }
691 690
692int SSL_pending(const SSL *s) 691int SSL_pending(SSL *s)
693 { 692 {
694 /* SSL_pending cannot work properly if read-ahead is enabled 693 /* SSL_pending cannot work properly if read-ahead is enabled
695 * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)), 694 * (SSL_[CTX_]ctrl(..., SSL_CTRL_SET_READ_AHEAD, 1, NULL)),
@@ -701,7 +700,7 @@ int SSL_pending(const SSL *s)
701 return(s->method->ssl_pending(s)); 700 return(s->method->ssl_pending(s));
702 } 701 }
703 702
704X509 *SSL_get_peer_certificate(const SSL *s) 703X509 *SSL_get_peer_certificate(SSL *s)
705 { 704 {
706 X509 *r; 705 X509 *r;
707 706
@@ -717,7 +716,7 @@ X509 *SSL_get_peer_certificate(const SSL *s)
717 return(r); 716 return(r);
718 } 717 }
719 718
720STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s) 719STACK_OF(X509) *SSL_get_peer_cert_chain(SSL *s)
721 { 720 {
722 STACK_OF(X509) *r; 721 STACK_OF(X509) *r;
723 722
@@ -734,7 +733,7 @@ STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s)
734 733
735/* Now in theory, since the calling process own 't' it should be safe to 734/* Now in theory, since the calling process own 't' it should be safe to
736 * modify. We need to be able to read f without being hassled */ 735 * modify. We need to be able to read f without being hassled */
737void SSL_copy_session_id(SSL *t,const SSL *f) 736void SSL_copy_session_id(SSL *t,SSL *f)
738 { 737 {
739 CERT *tmp; 738 CERT *tmp;
740 739
@@ -763,7 +762,7 @@ void SSL_copy_session_id(SSL *t,const SSL *f)
763 } 762 }
764 763
765/* Fix this so it checks all the valid key/cert options */ 764/* Fix this so it checks all the valid key/cert options */
766int SSL_CTX_check_private_key(const SSL_CTX *ctx) 765int SSL_CTX_check_private_key(SSL_CTX *ctx)
767 { 766 {
768 if ( (ctx == NULL) || 767 if ( (ctx == NULL) ||
769 (ctx->cert == NULL) || 768 (ctx->cert == NULL) ||
@@ -781,7 +780,7 @@ int SSL_CTX_check_private_key(const SSL_CTX *ctx)
781 } 780 }
782 781
783/* Fix this function so that it takes an optional type parameter */ 782/* Fix this function so that it takes an optional type parameter */
784int SSL_check_private_key(const SSL *ssl) 783int SSL_check_private_key(SSL *ssl)
785 { 784 {
786 if (ssl == NULL) 785 if (ssl == NULL)
787 { 786 {
@@ -825,7 +824,7 @@ int SSL_connect(SSL *s)
825 return(s->method->ssl_connect(s)); 824 return(s->method->ssl_connect(s));
826 } 825 }
827 826
828long SSL_get_default_timeout(const SSL *s) 827long SSL_get_default_timeout(SSL *s)
829 { 828 {
830 return(s->method->get_timeout()); 829 return(s->method->get_timeout());
831 } 830 }
@@ -1072,7 +1071,7 @@ int ssl_cipher_ptr_id_cmp(const SSL_CIPHER * const *ap,
1072 1071
1073/** return a STACK of the ciphers available for the SSL and in order of 1072/** return a STACK of the ciphers available for the SSL and in order of
1074 * preference */ 1073 * preference */
1075STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s) 1074STACK_OF(SSL_CIPHER) *SSL_get_ciphers(SSL *s)
1076 { 1075 {
1077 if (s != NULL) 1076 if (s != NULL)
1078 { 1077 {
@@ -1109,7 +1108,7 @@ STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *s)
1109 } 1108 }
1110 1109
1111/** The old interface to get the same thing as SSL_get_ciphers() */ 1110/** The old interface to get the same thing as SSL_get_ciphers() */
1112const char *SSL_get_cipher_list(const SSL *s,int n) 1111const char *SSL_get_cipher_list(SSL *s,int n)
1113 { 1112 {
1114 SSL_CIPHER *c; 1113 SSL_CIPHER *c;
1115 STACK_OF(SSL_CIPHER) *sk; 1114 STACK_OF(SSL_CIPHER) *sk;
@@ -1146,7 +1145,7 @@ int SSL_set_cipher_list(SSL *s,const char *str)
1146 } 1145 }
1147 1146
1148/* works well for SSLv2, not so good for SSLv3 */ 1147/* works well for SSLv2, not so good for SSLv3 */
1149char *SSL_get_shared_ciphers(const SSL *s,char *buf,int len) 1148char *SSL_get_shared_ciphers(SSL *s,char *buf,int len)
1150 { 1149 {
1151 char *p; 1150 char *p;
1152 const char *cp; 1151 const char *cp;
@@ -1250,7 +1249,7 @@ err:
1250 return(NULL); 1249 return(NULL);
1251 } 1250 }
1252 1251
1253unsigned long SSL_SESSION_hash(const SSL_SESSION *a) 1252unsigned long SSL_SESSION_hash(SSL_SESSION *a)
1254 { 1253 {
1255 unsigned long l; 1254 unsigned long l;
1256 1255
@@ -1267,7 +1266,7 @@ unsigned long SSL_SESSION_hash(const SSL_SESSION *a)
1267 * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being 1266 * SSL_CTX_has_matching_session_id() is checked accordingly. It relies on being
1268 * able to construct an SSL_SESSION that will collide with any existing session 1267 * able to construct an SSL_SESSION that will collide with any existing session
1269 * with a matching session ID. */ 1268 * with a matching session ID. */
1270int SSL_SESSION_cmp(const SSL_SESSION *a,const SSL_SESSION *b) 1269int SSL_SESSION_cmp(SSL_SESSION *a,SSL_SESSION *b)
1271 { 1270 {
1272 if (a->ssl_version != b->ssl_version) 1271 if (a->ssl_version != b->ssl_version)
1273 return(1); 1272 return(1);
@@ -1293,14 +1292,6 @@ SSL_CTX *SSL_CTX_new(SSL_METHOD *meth)
1293 return(NULL); 1292 return(NULL);
1294 } 1293 }
1295 1294
1296#ifdef OPENSSL_FIPS
1297 if (FIPS_mode() && (meth->version < TLS1_VERSION))
1298 {
1299 SSLerr(SSL_F_SSL_CTX_NEW, SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE);
1300 return NULL;
1301 }
1302#endif
1303
1304 if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) 1295 if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0)
1305 { 1296 {
1306 SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); 1297 SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);
@@ -1731,7 +1722,7 @@ int SSL_set_ssl_method(SSL *s,SSL_METHOD *meth)
1731 return(ret); 1722 return(ret);
1732 } 1723 }
1733 1724
1734int SSL_get_error(const SSL *s,int i) 1725int SSL_get_error(SSL *s,int i)
1735 { 1726 {
1736 int reason; 1727 int reason;
1737 unsigned long l; 1728 unsigned long l;
@@ -1865,19 +1856,13 @@ int ssl_undefined_function(SSL *s)
1865 return(0); 1856 return(0);
1866 } 1857 }
1867 1858
1868int ssl_undefined_const_function(const SSL *s)
1869 {
1870 SSLerr(SSL_F_SSL_UNDEFINED_CONST_FUNCTION,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1871 return(0);
1872 }
1873
1874SSL_METHOD *ssl_bad_method(int ver) 1859SSL_METHOD *ssl_bad_method(int ver)
1875 { 1860 {
1876 SSLerr(SSL_F_SSL_BAD_METHOD,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); 1861 SSLerr(SSL_F_SSL_BAD_METHOD,ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
1877 return(NULL); 1862 return(NULL);
1878 } 1863 }
1879 1864
1880const char *SSL_get_version(const SSL *s) 1865const char *SSL_get_version(SSL *s)
1881 { 1866 {
1882 if (s->version == TLS1_VERSION) 1867 if (s->version == TLS1_VERSION)
1883 return("TLSv1"); 1868 return("TLSv1");
@@ -2046,7 +2031,7 @@ void ssl_clear_cipher_ctx(SSL *s)
2046 } 2031 }
2047 2032
2048/* Fix this function so that it takes an optional type parameter */ 2033/* Fix this function so that it takes an optional type parameter */
2049X509 *SSL_get_certificate(const SSL *s) 2034X509 *SSL_get_certificate(SSL *s)
2050 { 2035 {
2051 if (s->cert != NULL) 2036 if (s->cert != NULL)
2052 return(s->cert->key->x509); 2037 return(s->cert->key->x509);
@@ -2063,7 +2048,7 @@ EVP_PKEY *SSL_get_privatekey(SSL *s)
2063 return(NULL); 2048 return(NULL);
2064 } 2049 }
2065 2050
2066SSL_CIPHER *SSL_get_current_cipher(const SSL *s) 2051SSL_CIPHER *SSL_get_current_cipher(SSL *s)
2067 { 2052 {
2068 if ((s->session != NULL) && (s->session->cipher != NULL)) 2053 if ((s->session != NULL) && (s->session->cipher != NULL))
2069 return(s->session->cipher); 2054 return(s->session->cipher);
@@ -2127,7 +2112,7 @@ void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx,int mode)
2127 ctx->quiet_shutdown=mode; 2112 ctx->quiet_shutdown=mode;
2128 } 2113 }
2129 2114
2130int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx) 2115int SSL_CTX_get_quiet_shutdown(SSL_CTX *ctx)
2131 { 2116 {
2132 return(ctx->quiet_shutdown); 2117 return(ctx->quiet_shutdown);
2133 } 2118 }
@@ -2137,7 +2122,7 @@ void SSL_set_quiet_shutdown(SSL *s,int mode)
2137 s->quiet_shutdown=mode; 2122 s->quiet_shutdown=mode;
2138 } 2123 }
2139 2124
2140int SSL_get_quiet_shutdown(const SSL *s) 2125int SSL_get_quiet_shutdown(SSL *s)
2141 { 2126 {
2142 return(s->quiet_shutdown); 2127 return(s->quiet_shutdown);
2143 } 2128 }
@@ -2147,17 +2132,17 @@ void SSL_set_shutdown(SSL *s,int mode)
2147 s->shutdown=mode; 2132 s->shutdown=mode;
2148 } 2133 }
2149 2134
2150int SSL_get_shutdown(const SSL *s) 2135int SSL_get_shutdown(SSL *s)
2151 { 2136 {
2152 return(s->shutdown); 2137 return(s->shutdown);
2153 } 2138 }
2154 2139
2155int SSL_version(const SSL *s) 2140int SSL_version(SSL *s)
2156 { 2141 {
2157 return(s->version); 2142 return(s->version);
2158 } 2143 }
2159 2144
2160SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl) 2145SSL_CTX *SSL_get_SSL_CTX(SSL *ssl)
2161 { 2146 {
2162 return(ssl->ctx); 2147 return(ssl->ctx);
2163 } 2148 }
@@ -2171,9 +2156,7 @@ int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx)
2171int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, 2156int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile,
2172 const char *CApath) 2157 const char *CApath)
2173 { 2158 {
2174 int r; 2159 return(X509_STORE_load_locations(ctx->cert_store,CAfile,CApath));
2175 r=X509_STORE_load_locations(ctx->cert_store,CAfile,CApath);
2176 return r;
2177 } 2160 }
2178#endif 2161#endif
2179 2162
@@ -2183,12 +2166,12 @@ void SSL_set_info_callback(SSL *ssl,
2183 ssl->info_callback=cb; 2166 ssl->info_callback=cb;
2184 } 2167 }
2185 2168
2186void (*SSL_get_info_callback(const SSL *ssl))(const SSL *ssl,int type,int val) 2169void (*SSL_get_info_callback(SSL *ssl))(const SSL *ssl,int type,int val)
2187 { 2170 {
2188 return ssl->info_callback; 2171 return ssl->info_callback;
2189 } 2172 }
2190 2173
2191int SSL_state(const SSL *ssl) 2174int SSL_state(SSL *ssl)
2192 { 2175 {
2193 return(ssl->state); 2176 return(ssl->state);
2194 } 2177 }
@@ -2198,7 +2181,7 @@ void SSL_set_verify_result(SSL *ssl,long arg)
2198 ssl->verify_result=arg; 2181 ssl->verify_result=arg;
2199 } 2182 }
2200 2183
2201long SSL_get_verify_result(const SSL *ssl) 2184long SSL_get_verify_result(SSL *ssl)
2202 { 2185 {
2203 return(ssl->verify_result); 2186 return(ssl->verify_result);
2204 } 2187 }
@@ -2215,7 +2198,7 @@ int SSL_set_ex_data(SSL *s,int idx,void *arg)
2215 return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); 2198 return(CRYPTO_set_ex_data(&s->ex_data,idx,arg));
2216 } 2199 }
2217 2200
2218void *SSL_get_ex_data(const SSL *s,int idx) 2201void *SSL_get_ex_data(SSL *s,int idx)
2219 { 2202 {
2220 return(CRYPTO_get_ex_data(&s->ex_data,idx)); 2203 return(CRYPTO_get_ex_data(&s->ex_data,idx));
2221 } 2204 }
@@ -2232,7 +2215,7 @@ int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg)
2232 return(CRYPTO_set_ex_data(&s->ex_data,idx,arg)); 2215 return(CRYPTO_set_ex_data(&s->ex_data,idx,arg));
2233 } 2216 }
2234 2217
2235void *SSL_CTX_get_ex_data(const SSL_CTX *s,int idx) 2218void *SSL_CTX_get_ex_data(SSL_CTX *s,int idx)
2236 { 2219 {
2237 return(CRYPTO_get_ex_data(&s->ex_data,idx)); 2220 return(CRYPTO_get_ex_data(&s->ex_data,idx));
2238 } 2221 }
@@ -2242,7 +2225,7 @@ int ssl_ok(SSL *s)
2242 return(1); 2225 return(1);
2243 } 2226 }
2244 2227
2245X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *ctx) 2228X509_STORE *SSL_CTX_get_cert_store(SSL_CTX *ctx)
2246 { 2229 {
2247 return(ctx->cert_store); 2230 return(ctx->cert_store);
2248 } 2231 }
@@ -2254,7 +2237,7 @@ void SSL_CTX_set_cert_store(SSL_CTX *ctx,X509_STORE *store)
2254 ctx->cert_store=store; 2237 ctx->cert_store=store;
2255 } 2238 }
2256 2239
2257int SSL_want(const SSL *s) 2240int SSL_want(SSL *s)
2258 { 2241 {
2259 return(s->rwstate); 2242 return(s->rwstate);
2260 } 2243 }