156 #ifndef OPENSSL_NO_DH
159 #ifndef OPENSSL_NO_ENGINE
180 (int (*)(SSL *,
unsigned char *, size_t,
const char *,
181 size_t,
const unsigned char *, size_t,
264 sk=ssl_create_cipher_list(ctx->
method,&(ctx->cipher_list),
265 &(ctx->cipher_list_by_id),
291 if (s == NULL)
goto err;
292 memset(s,0,
sizeof(
SSL));
294 #ifndef OPENSSL_NO_KRB5
302 if (ctx->
cert != NULL)
326 s->verify_depth=ctx->verify_depth;
339 s->purpose = ctx->purpose;
340 s->trust = ctx->trust;
347 #ifndef OPENSSL_NO_TLSEXT
353 s->tlsext_ocsp_ids = NULL;
359 # ifndef OPENSSL_NO_NEXTPROTONEG
378 #ifndef OPENSSL_NO_PSK
398 unsigned int sid_ctx_len)
400 if(sid_ctx_len >
sizeof ctx->
sid_ctx)
406 memcpy(ctx->
sid_ctx,sid_ctx,sid_ctx_len);
412 unsigned int sid_ctx_len)
420 memcpy(ssl->
sid_ctx,sid_ctx,sid_ctx_len);
520 fprintf(stderr,
"SSL_free, bad reference count\n");
565 #ifndef OPENSSL_NO_TLSEXT
569 #ifndef OPENSSL_NO_EC
576 X509_EXTENSION_free);
577 if (s->tlsext_ocsp_ids)
583 if (s->client_CA != NULL)
590 #ifndef OPENSSL_NO_KRB5
595 #if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
600 if (s->srtp_profiles)
618 if ((s->
rbio != NULL) && (s->
rbio != rbio))
661 #ifndef OPENSSL_NO_SOCK
773 return(s->verify_callback);
788 return(ctx->default_verify_callback);
830 if ((s == NULL) || (s->
session == NULL))
835 if (r == NULL)
return(r);
890 if ( (ctx == NULL) ||
891 (ctx->
cert == NULL) ||
913 if (ssl->
cert == NULL)
1072 return(s->
mode|=larg);
1074 return(s->
mode &=~larg);
1082 #ifndef OPENSSL_NO_DTLS1
1123 return ctx->sessions;
1192 return(ctx->
mode|=larg);
1194 return(ctx->
mode&=~larg);
1226 return((l > 0)?1:-1);
1234 l=(*ap)->id-(*bp)->id;
1238 return((l > 0)?1:-1);
1247 if (s->cipher_list != NULL)
1249 return(s->cipher_list);
1251 else if ((s->
ctx != NULL) &&
1252 (s->
ctx->cipher_list != NULL))
1254 return(s->
ctx->cipher_list);
1266 if (s->cipher_list_by_id != NULL)
1268 return(s->cipher_list_by_id);
1270 else if ((s->
ctx != NULL) &&
1271 (s->
ctx->cipher_list_by_id != NULL))
1273 return(s->
ctx->cipher_list_by_id);
1285 if (s == NULL)
return(NULL);
1286 sk=SSL_get_ciphers(s);
1290 if (c == NULL)
return(NULL);
1299 sk=ssl_create_cipher_list(ctx->
method,&ctx->cipher_list,
1300 &ctx->cipher_list_by_id,str);
1323 sk=ssl_create_cipher_list(s->
ctx->
method,&s->cipher_list,
1324 &s->cipher_list_by_id,str);
1373 int (*put_cb)(
const SSL_CIPHER *,
unsigned char *))
1378 #ifndef OPENSSL_NO_KRB5
1382 if (sk == NULL)
return(0);
1392 #ifndef OPENSSL_NO_KRB5
1397 #ifndef OPENSSL_NO_PSK
1413 0, NULL,
SSL3_CK_SCSV, 0, 0, 0, 0, 0, 0, 0, 0, 0
1417 #ifdef OPENSSL_RI_DEBUG
1418 fprintf(stderr,
"SCSV sent by client\n");
1440 if ((skp == NULL) || (*skp == NULL))
1448 for (i=0; i<
num; i+=n)
1451 if (s->
s3 && (n != 3 || !p[0]) &&
1464 #ifdef OPENSSL_RI_DEBUG
1465 fprintf(stderr,
"SCSV received by server\n");
1486 if ((skp == NULL) || (*skp == NULL))
1492 #ifndef OPENSSL_NO_TLSEXT
1514 # ifndef OPENSSL_NO_NEXTPROTONEG
1545 int SSL_select_next_proto(
unsigned char **out,
unsigned char *outlen,
const unsigned char *server,
unsigned int server_len,
const unsigned char *client,
unsigned int client_len)
1548 const unsigned char *result;
1552 for (i = 0; i < server_len; )
1554 for (j = 0; j < client_len; )
1556 if (server[i] == client[j] &&
1557 memcmp(&server[i+1], &client[j+1], server[i]) == 0)
1560 result = &server[i];
1576 *out = (
unsigned char *) result + 1;
1577 *outlen = result[0];
1633 const char *label,
size_t llen,
const unsigned char *p,
size_t plen,
1644 static unsigned long ssl_session_hash(
const SSL_SESSION *
a)
1704 memset(ret,0,
sizeof(
SSL_CTX));
1722 memset((
char *)&ret->
stats,0,
sizeof(ret->
stats));
1744 ret->verify_depth=-1;
1758 if (ret->sessions == NULL)
goto err;
1762 ssl_create_cipher_list(ret->
method,
1763 &ret->cipher_list,&ret->cipher_list_by_id,
1765 if (ret->cipher_list == NULL
1797 ret->extra_certs=NULL;
1798 ret->comp_methods=SSL_COMP_get_compression_methods();
1802 #ifndef OPENSSL_NO_TLSEXT
1814 # ifndef OPENSSL_NO_NEXTPROTONEG
1819 #ifndef OPENSSL_NO_PSK
1824 #ifndef OPENSSL_NO_SRP
1827 #ifndef OPENSSL_NO_BUF_FREELISTS
1845 #ifndef OPENSSL_NO_ENGINE
1847 #ifdef OPENSSL_SSL_CLIENT_ENGINE_AUTO
1848 #define eng_strx(x) #x
1849 #define eng_str(x) eng_strx(x)
1853 eng =
ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO));
1858 eng =
ENGINE_by_id(eng_str(OPENSSL_SSL_CLIENT_ENGINE_AUTO));
1879 static void SSL_COMP_free(
SSL_COMP *comp)
1883 #ifndef OPENSSL_NO_BUF_FREELISTS
1888 for (ent = list->
head; ent; ent = next)
1901 if (a == NULL)
return;
1905 REF_PRINT(
"SSL_CTX",a);
1911 fprintf(stderr,
"SSL_CTX_free, bad reference count\n");
1928 if (a->sessions != NULL)
1933 if (a->sessions != NULL)
1938 if (a->cipher_list != NULL)
1940 if (a->cipher_list_by_id != NULL)
1942 if (a->
cert != NULL)
1944 if (a->client_CA != NULL)
1946 if (a->extra_certs != NULL)
1949 if (a->comp_methods != NULL)
1952 a->comp_methods = NULL;
1955 if (a->srtp_profiles)
1958 #ifndef OPENSSL_NO_PSK
1962 #ifndef OPENSSL_NO_SRP
1965 #ifndef OPENSSL_NO_ENGINE
1970 #ifndef OPENSSL_NO_BUF_FREELISTS
2010 int rsa_enc,rsa_tmp,rsa_sign,dh_tmp,dh_rsa,dh_dsa,dsa_sign;
2011 int rsa_enc_export,dh_rsa_export,dh_dsa_export;
2012 int rsa_tmp_export,dh_tmp_export,kl;
2013 unsigned long mask_k,mask_a,emask_k,emask_a;
2014 int have_ecc_cert, ecdh_ok, ecdsa_ok, ecc_pkey_size;
2015 #ifndef OPENSSL_NO_ECDH
2020 int signature_nid = 0, pk_nid = 0, md_nid = 0;
2022 if (c == NULL)
return;
2026 #ifndef OPENSSL_NO_RSA
2031 rsa_tmp=rsa_tmp_export=0;
2033 #ifndef OPENSSL_NO_DH
2038 dh_tmp=dh_tmp_export=0;
2041 #ifndef OPENSSL_NO_ECDH
2068 printf(
"rt=%d rte=%d dht=%d ecdht=%d re=%d ree=%d rs=%d ds=%d dhr=%d dhd=%d\n",
2069 rsa_tmp,rsa_tmp_export,dh_tmp,have_ecdh_tmp,
2070 rsa_enc,rsa_enc_export,rsa_sign,dsa_sign,dh_rsa,dh_dsa);
2084 if (rsa_enc || (rsa_tmp && rsa_sign))
2086 if (rsa_enc_export || (rsa_tmp_export && (rsa_sign || rsa_enc)))
2091 if ( (dh_tmp || dh_rsa || dh_dsa) &&
2092 (rsa_enc || rsa_sign || dsa_sign))
2094 if ((dh_tmp_export || dh_rsa_export || dh_dsa_export) &&
2095 (rsa_enc || rsa_sign || dsa_sign))
2106 if (dh_rsa_export) emask_k|=
SSL_kDHr;
2109 if (dh_dsa_export) emask_k|=
SSL_kDHd;
2111 if (rsa_enc || rsa_sign)
2126 #ifndef OPENSSL_NO_KRB5
2146 ecc_pkey_size = (ecc_pkey != NULL) ?
2154 #ifndef OPENSSL_NO_ECDH
2162 if (ecc_pkey_size <= 163)
2173 if (ecc_pkey_size <= 163)
2181 #ifndef OPENSSL_NO_ECDSA
2190 #ifndef OPENSSL_NO_ECDH
2198 #ifndef OPENSSL_NO_PSK
2213 #define ku_reject(x, usage) \
2214 (((x)->ex_flags & EXFLAG_KUSAGE) && !((x)->ex_kusage & (usage)))
2216 #ifndef OPENSSL_NO_EC
2220 unsigned long alg_k, alg_a;
2223 int signature_nid = 0, md_nid = 0, pk_nid = 0;
2233 if (pkey == NULL)
return 0;
2236 if (keysize > 163)
return 0;
2292 unsigned long alg_k,alg_a;
2348 if (c->
pkeys[i].
x509 == NULL)
return(NULL);
2355 unsigned long alg_a;
2393 i=s->session_ctx->session_cache_mode;
2394 if ((i & mode) && (!s->
hit)
2397 && (s->session_ctx->new_session_cb != NULL))
2400 if (!s->session_ctx->new_session_cb(s,s->
session))
2406 ((i & mode) == mode))
2409 ?s->session_ctx->stats.sess_connect_good
2410 :s->session_ctx->stats.sess_accept_good) & 0xff) == 0xff)
2651 if (s->
cert != NULL)
2653 if (ret->
cert != NULL)
2658 if (ret->
cert == NULL)
2686 if (s->
rbio != NULL)
2691 if (s->
wbio != NULL)
2717 if (s->cipher_list != NULL)
2722 if (s->cipher_list_by_id != NULL)
2728 if (s->client_CA != NULL)
2766 #ifndef OPENSSL_NO_COMP
2783 if (s->
cert != NULL)
2792 if (s->
cert != NULL)
2804 #ifdef OPENSSL_NO_COMP
2834 if (s->
bbio == NULL)
2837 if (bbio == NULL)
return(0);
2855 if (s->
wbio != bbio)
2860 if (s->
wbio == bbio)
2868 if (s->
bbio == NULL)
return;
2875 assert(s->
wbio != NULL);
2924 if (ssl->
ctx == ctx)
2926 #ifndef OPENSSL_NO_TLSEXT
2930 if (ssl->
cert != NULL)
2934 if (ssl->
ctx != NULL)
2940 #ifndef OPENSSL_NO_STDIO
2954 void (*
cb)(
const SSL *ssl,
int type,
int val))
2990 new_func, dup_func, free_func);
3007 new_func, dup_func, free_func);
3048 #ifndef OPENSSL_NO_RSA
3075 RSA *
cb(
SSL *ssl,
int is_export,
int keylength)
3085 #ifndef OPENSSL_NO_DH
3099 #ifndef OPENSSL_NO_ECDH
3113 #ifndef OPENSSL_NO_PSK
3123 if (identity_hint != NULL)
3149 if (identity_hint != NULL)
3162 if (s == NULL || s->
session == NULL)
3169 if (s == NULL || s->
session == NULL)
3175 unsigned int (*
cb)(
SSL *ssl,
const char *hint,
3176 char *identity,
unsigned int max_identity_len,
unsigned char *psk,
3177 unsigned int max_psk_len))
3183 unsigned int (*
cb)(
SSL *ssl,
const char *hint,
3184 char *identity,
unsigned int max_identity_len,
unsigned char *psk,
3185 unsigned int max_psk_len))
3191 unsigned int (*
cb)(
SSL *ssl,
const char *identity,
3192 unsigned char *psk,
unsigned int max_psk_len))
3198 unsigned int (*
cb)(
SSL *ssl,
const char *identity,
3199 unsigned char *psk,
unsigned int max_psk_len))
3244 #if defined(_WINDLL) && defined(OPENSSL_SYS_WIN16)
3245 #include "../crypto/bio/bss_file.c"