unsigned char *p, *d;
int n;
unsigned long alg_k;
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
EVP_PKEY *pkey = NULL;
-#endif
#ifndef OPENSSL_NO_KRB5
KSSL_ERR kssl_err;
#endif /* OPENSSL_NO_KRB5 */
/* Fool emacs indentation */
if (0) {
}
-#ifndef OPENSSL_NO_RSA
else if (alg_k & SSL_kRSA) {
RSA *rsa;
unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
tmp_buf, sizeof tmp_buf);
OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);
}
-#endif
#ifndef OPENSSL_NO_KRB5
else if (alg_k & SSL_kKRB5) {
krb5_error_code krb5rc;
unsigned char *p, *d;
unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
EVP_PKEY *pkey;
-#ifndef OPENSSL_NO_RSA
unsigned u = 0;
-#endif
unsigned long n;
-#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
int j;
-#endif
if (s->state == SSL3_ST_CW_CERT_VRFY_A) {
d = (unsigned char *)s->init_buf->data;
s->method->ssl3_enc->cert_verify_mac(s, NID_sha1,
&(data[MD5_DIGEST_LENGTH]));
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
s->method->ssl3_enc->cert_verify_mac(s,
NID_md5, &(data[0]));
s2n(u, p);
n = u + 2;
} else
-#endif
-#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA) {
if (!DSA_sign(pkey->save_type,
&(data[MD5_DIGEST_LENGTH]),
s2n(j, p);
n = j + 2;
} else
-#endif
#ifndef OPENSSL_NO_ECDSA
if (pkey->type == EVP_PKEY_EC) {
if (!ECDSA_sign(pkey->save_type,
int
dtls1_send_server_key_exchange(SSL *s)
{
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
int j, num;
RSA *rsa;
unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
unsigned int u;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh = NULL, *dhp;
#endif
r[0] = r[1] = r[2] = r[3] = NULL;
n = 0;
-#ifndef OPENSSL_NO_RSA
if (type & SSL_kRSA) {
rsa = cert->rsa_tmp;
if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) {
r[1] = rsa->e;
s->s3->tmp.use_rsa_tmp = 1;
} else
-#endif
#ifndef OPENSSL_NO_DH
if (type & SSL_kEDH) {
dhp = cert->dh_tmp;
/* n is the length of the params, they start at
* &(d[DTLS1_HM_HEADER_LENGTH]) and p points to the space
* at the end. */
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
q = md_buf;
j = 0;
s2n(u, p);
n += u + 2;
} else
-#endif
-#if !defined(OPENSSL_NO_DSA)
if (pkey->type == EVP_PKEY_DSA) {
/* lets do DSS */
EVP_SignInit_ex(&md_ctx, EVP_dss1(), NULL);
s2n(i, p);
n += i + 2;
} else
-#endif
#if !defined(OPENSSL_NO_ECDSA)
if (pkey->type == EVP_PKEY_EC) {
/* let's do ECDSA */
int
ssl3_get_key_exchange(SSL *s)
{
-#ifndef OPENSSL_NO_RSA
unsigned char *q, md_buf[EVP_MAX_MD_SIZE*2];
-#endif
EVP_MD_CTX md_ctx;
unsigned char *param, *p;
int al, i, j, param_len, ok;
long n, alg_k, alg_a;
EVP_PKEY *pkey = NULL;
const EVP_MD *md = NULL;
-#ifndef OPENSSL_NO_RSA
RSA *rsa = NULL;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh = NULL;
#endif
param = p = (unsigned char *)s->init_msg;
if (s->session->sess_cert != NULL) {
-#ifndef OPENSSL_NO_RSA
if (s->session->sess_cert->peer_rsa_tmp != NULL) {
RSA_free(s->session->sess_cert->peer_rsa_tmp);
s->session->sess_cert->peer_rsa_tmp = NULL;
}
-#endif
#ifndef OPENSSL_NO_DH
if (s->session->sess_cert->peer_dh_tmp) {
DH_free(s->session->sess_cert->peer_dh_tmp);
n -= param_len;
/* We must check if there is a certificate */
-#ifndef OPENSSL_NO_RSA
if (alg_a & SSL_aRSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
-#else
- if (0)
-;
-#endif
-#ifndef OPENSSL_NO_DSA
else if (alg_a & SSL_aDSS)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509);
-#endif
} else
#endif /* !OPENSSL_NO_SRP */
-#ifndef OPENSSL_NO_RSA
if (alg_k & SSL_kRSA) {
if ((rsa = RSA_new()) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
s->session->sess_cert->peer_rsa_tmp = rsa;
rsa = NULL;
}
-#else /* OPENSSL_NO_RSA */
- if (0)
-;
-#endif
#ifndef OPENSSL_NO_DH
else if (alg_k & SSL_kEDH) {
if ((dh = DH_new()) == NULL) {
p += i;
n -= param_len;
-#ifndef OPENSSL_NO_RSA
if (alg_a & SSL_aRSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
-#else
- if (0)
-;
-#endif
-#ifndef OPENSSL_NO_DSA
else if (alg_a & SSL_aDSS)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509);
-#endif
/* else anonymous DH, so no certificate or pkey. */
s->session->sess_cert->peer_dh_tmp = dh;
* key exchange message. We do support RSA and ECDSA.
*/
if (0);
-#ifndef OPENSSL_NO_RSA
else if (alg_a & SSL_aRSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
-#endif
#ifndef OPENSSL_NO_ECDSA
else if (alg_a & SSL_aECDSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_ECC].x509);
goto f_err;
}
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA && TLS1_get_version(s) < TLS1_2_VERSION) {
int num;
goto f_err;
}
} else
-#endif
{
EVP_VerifyInit_ex(&md_ctx, md, NULL);
EVP_VerifyUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE);
ssl3_send_alert(s, SSL3_AL_FATAL, al);
err:
EVP_PKEY_free(pkey);
-#ifndef OPENSSL_NO_RSA
if (rsa != NULL)
RSA_free(rsa);
-#endif
#ifndef OPENSSL_NO_DH
if (dh != NULL)
DH_free(dh);
unsigned char *p, *d;
int n;
unsigned long alg_k;
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
EVP_PKEY *pkey = NULL;
-#endif
#ifndef OPENSSL_NO_KRB5
KSSL_ERR kssl_err;
#endif /* OPENSSL_NO_KRB5 */
/* Fool emacs indentation */
if (0) {
}
-#ifndef OPENSSL_NO_RSA
else if (alg_k & SSL_kRSA) {
RSA *rsa;
unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
sizeof tmp_buf);
OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);
}
-#endif
#ifndef OPENSSL_NO_KRB5
else if (alg_k & SSL_kKRB5) {
krb5_error_code krb5rc;
if (!ssl3_digest_cached_records(s))
goto err;
} else
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
s->method->ssl3_enc->cert_verify_mac(
s, NID_md5, &(data[0]));
s2n(u, p);
n = u + 2;
} else
-#endif
-#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA) {
if (!DSA_sign(pkey->save_type,
&(data[MD5_DIGEST_LENGTH]),
s2n(j, p);
n = j + 2;
} else
-#endif
#ifndef OPENSSL_NO_ECDSA
if (pkey->type == EVP_PKEY_EC) {
if (!ECDSA_sign(pkey->save_type,
long alg_k, alg_a;
EVP_PKEY *pkey = NULL;
SESS_CERT *sc;
-#ifndef OPENSSL_NO_RSA
RSA *rsa;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh;
#endif
goto err;
}
-#ifndef OPENSSL_NO_RSA
rsa = s->session->sess_cert->peer_rsa_tmp;
-#endif
#ifndef OPENSSL_NO_DH
dh = s->session->sess_cert->peer_dh_tmp;
#endif
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_RSA_SIGNING_CERT);
goto f_err;
}
-#ifndef OPENSSL_NO_DSA
else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA|EVP_PKT_SIGN)) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DSA_SIGNING_CERT);
goto f_err;
}
-#endif
-#ifndef OPENSSL_NO_RSA
if ((alg_k & SSL_kRSA) &&
!(has_bits(i, EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_RSA_ENCRYPTING_CERT);
goto f_err;
}
-#endif
#ifndef OPENSSL_NO_DH
if ((alg_k & SSL_kEDH) &&
!(has_bits(i, EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_RSA_CERT);
goto f_err;
}
-#ifndef OPENSSL_NO_DSA
else if ((alg_k & SSL_kDHd) && !has_bits(i, EVP_PK_DH|EVP_PKS_DSA)) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_DSA_CERT);
goto f_err;
}
-#endif
#endif
if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i, EVP_PKT_EXP)) {
-#ifndef OPENSSL_NO_RSA
if (alg_k & SSL_kRSA) {
if (rsa == NULL ||
RSA_size(rsa) * 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {
goto f_err;
}
} else
-#endif
#ifndef OPENSSL_NO_DH
if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) {
if (dh == NULL ||
{
int ret = 0;
-#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
- if (
-#ifndef OPENSSL_NO_RSA
- cmd == SSL_CTRL_SET_TMP_RSA ||
- cmd == SSL_CTRL_SET_TMP_RSA_CB ||
-#endif
-#ifndef OPENSSL_NO_DSA
- cmd == SSL_CTRL_SET_TMP_DH ||
- cmd == SSL_CTRL_SET_TMP_DH_CB ||
-#endif
- 0) {
+ if (cmd == SSL_CTRL_SET_TMP_RSA || cmd == SSL_CTRL_SET_TMP_RSA_CB ||
+ cmd == SSL_CTRL_SET_TMP_DH || cmd == SSL_CTRL_SET_TMP_DH_CB) {
if (!ssl_cert_inst(&s->cert)) {
SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
return (0);
}
}
-#endif
switch (cmd) {
case SSL_CTRL_GET_SESSION_REUSED:
case SSL_CTRL_GET_FLAGS:
ret = (int)(s->s3->flags);
break;
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_NEED_TMP_RSA:
if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
return (ret);
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH:
{
{
int ret = 0;
-#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
- if (
-#ifndef OPENSSL_NO_RSA
- cmd == SSL_CTRL_SET_TMP_RSA_CB ||
-#endif
-#ifndef OPENSSL_NO_DSA
- cmd == SSL_CTRL_SET_TMP_DH_CB ||
-#endif
- 0) {
+ if (cmd == SSL_CTRL_SET_TMP_RSA_CB || cmd == SSL_CTRL_SET_TMP_DH_CB) {
if (!ssl_cert_inst(&s->cert)) {
SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
return (0);
}
}
-#endif
switch (cmd) {
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_SET_TMP_RSA_CB:
{
s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH_CB:
{
cert = ctx->cert;
switch (cmd) {
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_NEED_TMP_RSA:
if ((cert->rsa_tmp == NULL) &&
((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
return (0);
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH:
{
cert = ctx->cert;
switch (cmd) {
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_SET_TMP_RSA_CB:
{
cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH_CB:
{
#ifndef OPENSSL_NO_DH
if (alg_k & (SSL_kDHr|SSL_kEDH)) {
-# ifndef OPENSSL_NO_RSA
p[ret++] = SSL3_CT_RSA_FIXED_DH;
-# endif
-# ifndef OPENSSL_NO_DSA
p[ret++] = SSL3_CT_DSS_FIXED_DH;
-# endif
}
if ((s->version == SSL3_VERSION) &&
(alg_k & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) {
-# ifndef OPENSSL_NO_RSA
p[ret++] = SSL3_CT_RSA_EPHEMERAL_DH;
-# endif
-# ifndef OPENSSL_NO_DSA
p[ret++] = SSL3_CT_DSS_EPHEMERAL_DH;
-# endif
}
#endif /* !OPENSSL_NO_DH */
-#ifndef OPENSSL_NO_RSA
p[ret++] = SSL3_CT_RSA_SIGN;
-#endif
-#ifndef OPENSSL_NO_DSA
p[ret++] = SSL3_CT_DSS_SIGN;
-#endif
#ifndef OPENSSL_NO_ECDH
if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->version >= TLS1_VERSION)) {
p[ret++] = TLS_CT_RSA_FIXED_ECDH;
int
ssl3_send_server_key_exchange(SSL *s)
{
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
int j, num;
RSA *rsa;
unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
unsigned int u;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh = NULL, *dhp;
#endif
r[0] = r[1] = r[2] = r[3] = NULL;
n = 0;
-#ifndef OPENSSL_NO_RSA
if (type & SSL_kRSA) {
rsa = cert->rsa_tmp;
if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) {
r[1] = rsa->e;
s->s3->tmp.use_rsa_tmp = 1;
} else
-#endif
#ifndef OPENSSL_NO_DH
if (type & SSL_kEDH) {
dhp = cert->dh_tmp;
* n is the length of the params, they start at &(d[4])
* and p points to the space at the end.
*/
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA
&& TLS1_get_version(s) < TLS1_2_VERSION) {
q = md_buf;
s2n(u, p);
n += u + 2;
} else
-#endif
if (md) {
/*
* For TLS1.2 and later send signature
long n;
unsigned long alg_k;
unsigned char *p;
-#ifndef OPENSSL_NO_RSA
RSA *rsa = NULL;
EVP_PKEY *pkey = NULL;
-#endif
#ifndef OPENSSL_NO_DH
BIGNUM *pub = NULL;
DH *dh_srvr;
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
-#ifndef OPENSSL_NO_RSA
if (alg_k & SSL_kRSA) {
/* FIX THIS UP EAY EAY EAY EAY */
if (s->s3->tmp.use_rsa_tmp) {
p, i);
OPENSSL_cleanse(p, i);
} else
-#endif
#ifndef OPENSSL_NO_DH
if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) {
n2s(p, i);
return (1);
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
-#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_SRP)
err:
-#endif
#ifndef OPENSSL_NO_ECDH
EVP_PKEY_free(clnt_pub_pkey);
EC_POINT_free(clnt_ecpoint);
goto f_err;
}
} else
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,
MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i,
goto f_err;
}
} else
-#endif
-#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA) {
j = DSA_verify(pkey->save_type,
&(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]),
goto f_err;
}
} else
-#endif
#ifndef OPENSSL_NO_ECDSA
if (pkey->type == EVP_PKEY_EC) {
j = ECDSA_verify(pkey->save_type,
unsigned char *p, *d;
int n;
unsigned long alg_k;
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
EVP_PKEY *pkey = NULL;
-#endif
#ifndef OPENSSL_NO_KRB5
KSSL_ERR kssl_err;
#endif /* OPENSSL_NO_KRB5 */
/* Fool emacs indentation */
if (0) {
}
-#ifndef OPENSSL_NO_RSA
else if (alg_k & SSL_kRSA) {
RSA *rsa;
unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
tmp_buf, sizeof tmp_buf);
OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);
}
-#endif
#ifndef OPENSSL_NO_KRB5
else if (alg_k & SSL_kKRB5) {
krb5_error_code krb5rc;
unsigned char *p, *d;
unsigned char data[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
EVP_PKEY *pkey;
-#ifndef OPENSSL_NO_RSA
unsigned u = 0;
-#endif
unsigned long n;
-#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)
int j;
-#endif
if (s->state == SSL3_ST_CW_CERT_VRFY_A) {
d = (unsigned char *)s->init_buf->data;
s->method->ssl3_enc->cert_verify_mac(s, NID_sha1,
&(data[MD5_DIGEST_LENGTH]));
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
s->method->ssl3_enc->cert_verify_mac(s,
NID_md5, &(data[0]));
s2n(u, p);
n = u + 2;
} else
-#endif
-#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA) {
if (!DSA_sign(pkey->save_type,
&(data[MD5_DIGEST_LENGTH]),
s2n(j, p);
n = j + 2;
} else
-#endif
#ifndef OPENSSL_NO_ECDSA
if (pkey->type == EVP_PKEY_EC) {
if (!ECDSA_sign(pkey->save_type,
int
dtls1_send_server_key_exchange(SSL *s)
{
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
int j, num;
RSA *rsa;
unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
unsigned int u;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh = NULL, *dhp;
#endif
r[0] = r[1] = r[2] = r[3] = NULL;
n = 0;
-#ifndef OPENSSL_NO_RSA
if (type & SSL_kRSA) {
rsa = cert->rsa_tmp;
if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) {
r[1] = rsa->e;
s->s3->tmp.use_rsa_tmp = 1;
} else
-#endif
#ifndef OPENSSL_NO_DH
if (type & SSL_kEDH) {
dhp = cert->dh_tmp;
/* n is the length of the params, they start at
* &(d[DTLS1_HM_HEADER_LENGTH]) and p points to the space
* at the end. */
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
q = md_buf;
j = 0;
s2n(u, p);
n += u + 2;
} else
-#endif
-#if !defined(OPENSSL_NO_DSA)
if (pkey->type == EVP_PKEY_DSA) {
/* lets do DSS */
EVP_SignInit_ex(&md_ctx, EVP_dss1(), NULL);
s2n(i, p);
n += i + 2;
} else
-#endif
#if !defined(OPENSSL_NO_ECDSA)
if (pkey->type == EVP_PKEY_EC) {
/* let's do ECDSA */
int
ssl3_get_key_exchange(SSL *s)
{
-#ifndef OPENSSL_NO_RSA
unsigned char *q, md_buf[EVP_MAX_MD_SIZE*2];
-#endif
EVP_MD_CTX md_ctx;
unsigned char *param, *p;
int al, i, j, param_len, ok;
long n, alg_k, alg_a;
EVP_PKEY *pkey = NULL;
const EVP_MD *md = NULL;
-#ifndef OPENSSL_NO_RSA
RSA *rsa = NULL;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh = NULL;
#endif
param = p = (unsigned char *)s->init_msg;
if (s->session->sess_cert != NULL) {
-#ifndef OPENSSL_NO_RSA
if (s->session->sess_cert->peer_rsa_tmp != NULL) {
RSA_free(s->session->sess_cert->peer_rsa_tmp);
s->session->sess_cert->peer_rsa_tmp = NULL;
}
-#endif
#ifndef OPENSSL_NO_DH
if (s->session->sess_cert->peer_dh_tmp) {
DH_free(s->session->sess_cert->peer_dh_tmp);
n -= param_len;
/* We must check if there is a certificate */
-#ifndef OPENSSL_NO_RSA
if (alg_a & SSL_aRSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
-#else
- if (0)
-;
-#endif
-#ifndef OPENSSL_NO_DSA
else if (alg_a & SSL_aDSS)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509);
-#endif
} else
#endif /* !OPENSSL_NO_SRP */
-#ifndef OPENSSL_NO_RSA
if (alg_k & SSL_kRSA) {
if ((rsa = RSA_new()) == NULL) {
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
s->session->sess_cert->peer_rsa_tmp = rsa;
rsa = NULL;
}
-#else /* OPENSSL_NO_RSA */
- if (0)
-;
-#endif
#ifndef OPENSSL_NO_DH
else if (alg_k & SSL_kEDH) {
if ((dh = DH_new()) == NULL) {
p += i;
n -= param_len;
-#ifndef OPENSSL_NO_RSA
if (alg_a & SSL_aRSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
-#else
- if (0)
-;
-#endif
-#ifndef OPENSSL_NO_DSA
else if (alg_a & SSL_aDSS)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_DSA_SIGN].x509);
-#endif
/* else anonymous DH, so no certificate or pkey. */
s->session->sess_cert->peer_dh_tmp = dh;
* key exchange message. We do support RSA and ECDSA.
*/
if (0);
-#ifndef OPENSSL_NO_RSA
else if (alg_a & SSL_aRSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_RSA_ENC].x509);
-#endif
#ifndef OPENSSL_NO_ECDSA
else if (alg_a & SSL_aECDSA)
pkey = X509_get_pubkey(s->session->sess_cert->peer_pkeys[SSL_PKEY_ECC].x509);
goto f_err;
}
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA && TLS1_get_version(s) < TLS1_2_VERSION) {
int num;
goto f_err;
}
} else
-#endif
{
EVP_VerifyInit_ex(&md_ctx, md, NULL);
EVP_VerifyUpdate(&md_ctx, &(s->s3->client_random[0]), SSL3_RANDOM_SIZE);
ssl3_send_alert(s, SSL3_AL_FATAL, al);
err:
EVP_PKEY_free(pkey);
-#ifndef OPENSSL_NO_RSA
if (rsa != NULL)
RSA_free(rsa);
-#endif
#ifndef OPENSSL_NO_DH
if (dh != NULL)
DH_free(dh);
unsigned char *p, *d;
int n;
unsigned long alg_k;
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
EVP_PKEY *pkey = NULL;
-#endif
#ifndef OPENSSL_NO_KRB5
KSSL_ERR kssl_err;
#endif /* OPENSSL_NO_KRB5 */
/* Fool emacs indentation */
if (0) {
}
-#ifndef OPENSSL_NO_RSA
else if (alg_k & SSL_kRSA) {
RSA *rsa;
unsigned char tmp_buf[SSL_MAX_MASTER_KEY_LENGTH];
sizeof tmp_buf);
OPENSSL_cleanse(tmp_buf, sizeof tmp_buf);
}
-#endif
#ifndef OPENSSL_NO_KRB5
else if (alg_k & SSL_kKRB5) {
krb5_error_code krb5rc;
if (!ssl3_digest_cached_records(s))
goto err;
} else
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
s->method->ssl3_enc->cert_verify_mac(
s, NID_md5, &(data[0]));
s2n(u, p);
n = u + 2;
} else
-#endif
-#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA) {
if (!DSA_sign(pkey->save_type,
&(data[MD5_DIGEST_LENGTH]),
s2n(j, p);
n = j + 2;
} else
-#endif
#ifndef OPENSSL_NO_ECDSA
if (pkey->type == EVP_PKEY_EC) {
if (!ECDSA_sign(pkey->save_type,
long alg_k, alg_a;
EVP_PKEY *pkey = NULL;
SESS_CERT *sc;
-#ifndef OPENSSL_NO_RSA
RSA *rsa;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh;
#endif
goto err;
}
-#ifndef OPENSSL_NO_RSA
rsa = s->session->sess_cert->peer_rsa_tmp;
-#endif
#ifndef OPENSSL_NO_DH
dh = s->session->sess_cert->peer_dh_tmp;
#endif
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_RSA_SIGNING_CERT);
goto f_err;
}
-#ifndef OPENSSL_NO_DSA
else if ((alg_a & SSL_aDSS) && !has_bits(i, EVP_PK_DSA|EVP_PKT_SIGN)) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DSA_SIGNING_CERT);
goto f_err;
}
-#endif
-#ifndef OPENSSL_NO_RSA
if ((alg_k & SSL_kRSA) &&
!(has_bits(i, EVP_PK_RSA|EVP_PKT_ENC) || (rsa != NULL))) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_RSA_ENCRYPTING_CERT);
goto f_err;
}
-#endif
#ifndef OPENSSL_NO_DH
if ((alg_k & SSL_kEDH) &&
!(has_bits(i, EVP_PK_DH|EVP_PKT_EXCH) || (dh != NULL))) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_RSA_CERT);
goto f_err;
}
-#ifndef OPENSSL_NO_DSA
else if ((alg_k & SSL_kDHd) && !has_bits(i, EVP_PK_DH|EVP_PKS_DSA)) {
SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM, SSL_R_MISSING_DH_DSA_CERT);
goto f_err;
}
-#endif
#endif
if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i, EVP_PKT_EXP)) {
-#ifndef OPENSSL_NO_RSA
if (alg_k & SSL_kRSA) {
if (rsa == NULL ||
RSA_size(rsa) * 8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {
goto f_err;
}
} else
-#endif
#ifndef OPENSSL_NO_DH
if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) {
if (dh == NULL ||
{
int ret = 0;
-#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
- if (
-#ifndef OPENSSL_NO_RSA
- cmd == SSL_CTRL_SET_TMP_RSA ||
- cmd == SSL_CTRL_SET_TMP_RSA_CB ||
-#endif
-#ifndef OPENSSL_NO_DSA
- cmd == SSL_CTRL_SET_TMP_DH ||
- cmd == SSL_CTRL_SET_TMP_DH_CB ||
-#endif
- 0) {
+ if (cmd == SSL_CTRL_SET_TMP_RSA || cmd == SSL_CTRL_SET_TMP_RSA_CB ||
+ cmd == SSL_CTRL_SET_TMP_DH || cmd == SSL_CTRL_SET_TMP_DH_CB) {
if (!ssl_cert_inst(&s->cert)) {
SSLerr(SSL_F_SSL3_CTRL, ERR_R_MALLOC_FAILURE);
return (0);
}
}
-#endif
switch (cmd) {
case SSL_CTRL_GET_SESSION_REUSED:
case SSL_CTRL_GET_FLAGS:
ret = (int)(s->s3->flags);
break;
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_NEED_TMP_RSA:
if ((s->cert != NULL) && (s->cert->rsa_tmp == NULL) &&
((s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
return (ret);
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH:
{
{
int ret = 0;
-#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_RSA)
- if (
-#ifndef OPENSSL_NO_RSA
- cmd == SSL_CTRL_SET_TMP_RSA_CB ||
-#endif
-#ifndef OPENSSL_NO_DSA
- cmd == SSL_CTRL_SET_TMP_DH_CB ||
-#endif
- 0) {
+ if (cmd == SSL_CTRL_SET_TMP_RSA_CB || cmd == SSL_CTRL_SET_TMP_DH_CB) {
if (!ssl_cert_inst(&s->cert)) {
SSLerr(SSL_F_SSL3_CALLBACK_CTRL, ERR_R_MALLOC_FAILURE);
return (0);
}
}
-#endif
switch (cmd) {
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_SET_TMP_RSA_CB:
{
s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH_CB:
{
cert = ctx->cert;
switch (cmd) {
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_NEED_TMP_RSA:
if ((cert->rsa_tmp == NULL) &&
((cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL) ||
return (0);
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH:
{
cert = ctx->cert;
switch (cmd) {
-#ifndef OPENSSL_NO_RSA
case SSL_CTRL_SET_TMP_RSA_CB:
{
cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))fp;
}
break;
-#endif
#ifndef OPENSSL_NO_DH
case SSL_CTRL_SET_TMP_DH_CB:
{
#ifndef OPENSSL_NO_DH
if (alg_k & (SSL_kDHr|SSL_kEDH)) {
-# ifndef OPENSSL_NO_RSA
p[ret++] = SSL3_CT_RSA_FIXED_DH;
-# endif
-# ifndef OPENSSL_NO_DSA
p[ret++] = SSL3_CT_DSS_FIXED_DH;
-# endif
}
if ((s->version == SSL3_VERSION) &&
(alg_k & (SSL_kEDH|SSL_kDHd|SSL_kDHr))) {
-# ifndef OPENSSL_NO_RSA
p[ret++] = SSL3_CT_RSA_EPHEMERAL_DH;
-# endif
-# ifndef OPENSSL_NO_DSA
p[ret++] = SSL3_CT_DSS_EPHEMERAL_DH;
-# endif
}
#endif /* !OPENSSL_NO_DH */
-#ifndef OPENSSL_NO_RSA
p[ret++] = SSL3_CT_RSA_SIGN;
-#endif
-#ifndef OPENSSL_NO_DSA
p[ret++] = SSL3_CT_DSS_SIGN;
-#endif
#ifndef OPENSSL_NO_ECDH
if ((alg_k & (SSL_kECDHr|SSL_kECDHe)) && (s->version >= TLS1_VERSION)) {
p[ret++] = TLS_CT_RSA_FIXED_ECDH;
int
ssl3_send_server_key_exchange(SSL *s)
{
-#ifndef OPENSSL_NO_RSA
unsigned char *q;
int j, num;
RSA *rsa;
unsigned char md_buf[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
unsigned int u;
-#endif
#ifndef OPENSSL_NO_DH
DH *dh = NULL, *dhp;
#endif
r[0] = r[1] = r[2] = r[3] = NULL;
n = 0;
-#ifndef OPENSSL_NO_RSA
if (type & SSL_kRSA) {
rsa = cert->rsa_tmp;
if ((rsa == NULL) && (s->cert->rsa_tmp_cb != NULL)) {
r[1] = rsa->e;
s->s3->tmp.use_rsa_tmp = 1;
} else
-#endif
#ifndef OPENSSL_NO_DH
if (type & SSL_kEDH) {
dhp = cert->dh_tmp;
* n is the length of the params, they start at &(d[4])
* and p points to the space at the end.
*/
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA
&& TLS1_get_version(s) < TLS1_2_VERSION) {
q = md_buf;
s2n(u, p);
n += u + 2;
} else
-#endif
if (md) {
/*
* For TLS1.2 and later send signature
long n;
unsigned long alg_k;
unsigned char *p;
-#ifndef OPENSSL_NO_RSA
RSA *rsa = NULL;
EVP_PKEY *pkey = NULL;
-#endif
#ifndef OPENSSL_NO_DH
BIGNUM *pub = NULL;
DH *dh_srvr;
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
-#ifndef OPENSSL_NO_RSA
if (alg_k & SSL_kRSA) {
/* FIX THIS UP EAY EAY EAY EAY */
if (s->s3->tmp.use_rsa_tmp) {
p, i);
OPENSSL_cleanse(p, i);
} else
-#endif
#ifndef OPENSSL_NO_DH
if (alg_k & (SSL_kEDH|SSL_kDHr|SSL_kDHd)) {
n2s(p, i);
return (1);
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
-#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_RSA) || !defined(OPENSSL_NO_ECDH) || defined(OPENSSL_NO_SRP)
err:
-#endif
#ifndef OPENSSL_NO_ECDH
EVP_PKEY_free(clnt_pub_pkey);
EC_POINT_free(clnt_ecpoint);
goto f_err;
}
} else
-#ifndef OPENSSL_NO_RSA
if (pkey->type == EVP_PKEY_RSA) {
i = RSA_verify(NID_md5_sha1, s->s3->tmp.cert_verify_md,
MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH, p, i,
goto f_err;
}
} else
-#endif
-#ifndef OPENSSL_NO_DSA
if (pkey->type == EVP_PKEY_DSA) {
j = DSA_verify(pkey->save_type,
&(s->s3->tmp.cert_verify_md[MD5_DIGEST_LENGTH]),
goto f_err;
}
} else
-#endif
#ifndef OPENSSL_NO_ECDSA
if (pkey->type == EVP_PKEY_EC) {
j = ECDSA_verify(pkey->save_type,
void SSL_set_verify(SSL *s, int mode,
int (*callback)(int ok, X509_STORE_CTX *ctx));
void SSL_set_verify_depth(SSL *s, int depth);
-#ifndef OPENSSL_NO_RSA
int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
-#endif
int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, long len);
int (*callback)(int, X509_STORE_CTX *));
void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);
void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg);
-#ifndef OPENSSL_NO_RSA
int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
-#endif
int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len);
int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, const unsigned char *d, long len);
SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)
/* NB: the keylength is only applicable when is_export is true */
-#ifndef OPENSSL_NO_RSA
void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
RSA *(*cb)(SSL *ssl, int is_export, int keylength));
void SSL_set_tmp_rsa_callback(SSL *ssl,
RSA *(*cb)(SSL *ssl, int is_export, int keylength));
-#endif
#ifndef OPENSSL_NO_DH
void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
DH *(*dh)(SSL *ssl, int is_export, int keylength));
EVP_add_digest(EVP_sha256());
EVP_add_digest(EVP_sha384());
EVP_add_digest(EVP_sha512());
-#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA)
EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
-#endif
#ifndef OPENSSL_NO_ECDSA
EVP_add_digest(EVP_ecdsa());
#endif
ssl_cert_set_default_md(CERT *cert)
{
/* Set digest values to defaults */
-#ifndef OPENSSL_NO_DSA
cert->pkeys[SSL_PKEY_DSA_SIGN].digest = EVP_sha1();
-#endif
-#ifndef OPENSSL_NO_RSA
cert->pkeys[SSL_PKEY_RSA_SIGN].digest = EVP_sha1();
cert->pkeys[SSL_PKEY_RSA_ENC].digest = EVP_sha1();
-#endif
#ifndef OPENSSL_NO_ECDSA
cert->pkeys[SSL_PKEY_ECC].digest = EVP_sha1();
#endif
ret->export_mask_k = cert->export_mask_k;
ret->export_mask_a = cert->export_mask_a;
-#ifndef OPENSSL_NO_RSA
if (cert->rsa_tmp != NULL) {
RSA_up_ref(cert->rsa_tmp);
ret->rsa_tmp = cert->rsa_tmp;
}
ret->rsa_tmp_cb = cert->rsa_tmp_cb;
-#endif
#ifndef OPENSSL_NO_DH
if (cert->dh_tmp != NULL) {
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_ECDH)
err:
#endif
-#ifndef OPENSSL_NO_RSA
if (ret->rsa_tmp != NULL)
RSA_free(ret->rsa_tmp);
-#endif
#ifndef OPENSSL_NO_DH
if (ret->dh_tmp != NULL)
DH_free(ret->dh_tmp);
if (i > 0)
return;
-#ifndef OPENSSL_NO_RSA
if (c->rsa_tmp)
RSA_free(c->rsa_tmp);
-#endif
#ifndef OPENSSL_NO_DH
if (c->dh_tmp)
DH_free(c->dh_tmp);
#endif
}
-#ifndef OPENSSL_NO_RSA
if (sc->peer_rsa_tmp != NULL)
RSA_free(sc->peer_rsa_tmp);
-#endif
#ifndef OPENSSL_NO_DH
if (sc->peer_dh_tmp != NULL)
DH_free(sc->peer_dh_tmp);
*mac = 0;
*ssl = 0;
-#ifdef OPENSSL_NO_RSA
- *mkey |= SSL_kRSA;
- *auth |= SSL_aRSA;
-#endif
-#ifdef OPENSSL_NO_DSA
- *auth |= SSL_aDSS;
-#endif
*mkey |= SSL_kDHr|SSL_kDHd; /* no such ciphersuites supported! */
*auth |= SSL_aDH;
#ifdef OPENSSL_NO_DH
kl = SSL_C_EXPORT_PKEYLENGTH(cipher);
-#ifndef OPENSSL_NO_RSA
rsa_tmp = (c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL);
rsa_tmp_export = (c->rsa_tmp_cb != NULL ||
(rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl));
-#else
- rsa_tmp = rsa_tmp_export = 0;
-#endif
#ifndef OPENSSL_NO_DH
dh_tmp = (c->dh_tmp != NULL || c->dh_tmp_cb != NULL);
dh_tmp_export = (c->dh_tmp_cb != NULL ||
* \param cb the callback
*/
-#ifndef OPENSSL_NO_RSA
void
SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, RSA *(*cb)(SSL *ssl,
int is_export,
{
SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb);
}
-#endif
#ifdef DOXYGEN
/*!
#endif
#include <openssl/bio.h>
#include <openssl/stack.h>
-#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
-#endif
-#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
-#endif
#include <openssl/err.h>
#include <openssl/ssl.h>
unsigned long mask_a;
unsigned long export_mask_k;
unsigned long export_mask_a;
-#ifndef OPENSSL_NO_RSA
RSA *rsa_tmp;
RSA *(*rsa_tmp_cb)(SSL *ssl, int is_export, int keysize);
-#endif
#ifndef OPENSSL_NO_DH
DH *dh_tmp;
DH *(*dh_tmp_cb)(SSL *ssl, int is_export, int keysize);
/* Obviously we don't have the private keys of these,
* so maybe we shouldn't even use the CERT_PKEY type here. */
-#ifndef OPENSSL_NO_RSA
RSA *peer_rsa_tmp; /* not used for SSL 2 */
-#endif
#ifndef OPENSSL_NO_DH
DH *peer_dh_tmp; /* not used for SSL 2 */
#endif
return (ret);
}
-#ifndef OPENSSL_NO_RSA
int
SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
{
EVP_PKEY_free(pkey);
return (ret);
}
-#endif
static int
ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
EVP_PKEY_free(pktmp);
ERR_clear_error();
-#ifndef OPENSSL_NO_RSA
/* Don't check the public/private key, this is mostly
* for smart cards. */
if ((pkey->type == EVP_PKEY_RSA) &&
(RSA_flags(pkey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK))
;
else
-#endif
if (!X509_check_private_key(c->pkeys[i].x509, pkey)) {
X509_free(c->pkeys[i].x509);
c->pkeys[i].x509 = NULL;
return (1);
}
-#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_STDIO
int
SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
RSA_free(rsa);
return (ret);
}
-#endif /* !OPENSSL_NO_RSA */
int
SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
EVP_PKEY_copy_parameters(pkey, c->pkeys[i].privatekey);
ERR_clear_error();
-#ifndef OPENSSL_NO_RSA
/* Don't check the public/private key, this is mostly
* for smart cards. */
if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) &&
RSA_METHOD_FLAG_NO_CHECK))
;
else
-#endif /* OPENSSL_NO_RSA */
if (!X509_check_private_key(x, c->pkeys[i].privatekey)) {
/* don't fail for a cert/key mismatch, just free
* current private key (when switching to a different
return (ret);
}
-#ifndef OPENSSL_NO_RSA
int
SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
{
RSA_free(rsa);
return (ret);
}
-#endif /* !OPENSSL_NO_RSA */
int
SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
#endif
#include <openssl/err.h>
#include <openssl/rand.h>
-#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
-#endif
-#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
-#endif
#ifndef OPENSSL_NO_DH
#include <openssl/dh.h>
#endif
#define COMP_ZLIB 1
static int verify_callback(int ok, X509_STORE_CTX *ctx);
-#ifndef OPENSSL_NO_RSA
static RSA *tmp_rsa_cb(SSL *s, int is_export, int keylength);
static void free_tmp_rsa(void);
-#endif
static int app_verify_callback(X509_STORE_CTX *ctx, void *arg);
#define APP_CALLBACK_STRING "Test Callback Argument"
struct app_verify_arg {
if (pkey != NULL) {
if (0)
;
-#ifndef OPENSSL_NO_RSA
else if (pkey->type == EVP_PKEY_RSA &&
pkey->pkey.rsa != NULL &&
pkey->pkey.rsa->n != NULL) {
BIO_printf(bio_stdout, ", %d bit RSA",
BN_num_bits(pkey->pkey.rsa->n));
}
-#endif
-#ifndef OPENSSL_NO_DSA
else if (pkey->type == EVP_PKEY_DSA &&
pkey->pkey.dsa != NULL &&
pkey->pkey.dsa->p != NULL) {
BIO_printf(bio_stdout, ", %d bit DSA",
BN_num_bits(pkey->pkey.dsa->p));
}
-#endif
EVP_PKEY_free(pkey);
}
X509_free(cert);
(void)no_ecdhe;
#endif
-#ifndef OPENSSL_NO_RSA
SSL_CTX_set_tmp_rsa_callback(s_ctx, tmp_rsa_cb);
-#endif
#ifdef TLSEXT_TYPE_opaque_prf_input
SSL_CTX_set_tlsext_opaque_prf_input_callback(c_ctx, opaque_prf_input_cb);
if (bio_stdout != NULL)
BIO_free(bio_stdout);
-#ifndef OPENSSL_NO_RSA
free_tmp_rsa();
-#endif
#ifndef OPENSSL_NO_ENGINE
ENGINE_cleanup();
#endif
return (ok);
}
-#ifndef OPENSSL_NO_RSA
static RSA *rsa_tmp = NULL;
static RSA
rsa_tmp = NULL;
}
}
-#endif
#ifndef OPENSSL_NO_DH
/* These DH parameters have been generated as follows:
* customisable at some point, for now include everything we support.
*/
-#ifdef OPENSSL_NO_RSA
-#define tlsext_sigalg_rsa(md) /* */
-#else
#define tlsext_sigalg_rsa(md) md, TLSEXT_signature_rsa,
-#endif
-#ifdef OPENSSL_NO_DSA
-#define tlsext_sigalg_dsa(md) /* */
-#else
#define tlsext_sigalg_dsa(md) md, TLSEXT_signature_dsa,
-#endif
#ifdef OPENSSL_NO_ECDSA
#define tlsext_sigalg_ecdsa(md) /* */
};
static tls12_lookup tls12_sig[] = {
-#ifndef OPENSSL_NO_RSA
{EVP_PKEY_RSA, TLSEXT_signature_rsa},
-#endif
-#ifndef OPENSSL_NO_DSA
{EVP_PKEY_DSA, TLSEXT_signature_dsa},
-#endif
#ifndef OPENSSL_NO_ECDSA
{EVP_PKEY_EC, TLSEXT_signature_ecdsa}
#endif
unsigned char hash_alg = data[i], sig_alg = data[i + 1];
switch (sig_alg) {
-#ifndef OPENSSL_NO_RSA
case TLSEXT_signature_rsa:
idx = SSL_PKEY_RSA_SIGN;
break;
-#endif
-#ifndef OPENSSL_NO_DSA
case TLSEXT_signature_dsa:
idx = SSL_PKEY_DSA_SIGN;
break;
-#endif
#ifndef OPENSSL_NO_ECDSA
case TLSEXT_signature_ecdsa:
idx = SSL_PKEY_ECC;
/* Set any remaining keys to default values. NOTE: if alg is not
* supported it stays as NULL.
*/
-#ifndef OPENSSL_NO_DSA
if (!c->pkeys[SSL_PKEY_DSA_SIGN].digest)
c->pkeys[SSL_PKEY_DSA_SIGN].digest = EVP_sha1();
-#endif
-#ifndef OPENSSL_NO_RSA
if (!c->pkeys[SSL_PKEY_RSA_SIGN].digest) {
c->pkeys[SSL_PKEY_RSA_SIGN].digest = EVP_sha1();
c->pkeys[SSL_PKEY_RSA_ENC].digest = EVP_sha1();
}
-#endif
#ifndef OPENSSL_NO_ECDSA
if (!c->pkeys[SSL_PKEY_ECC].digest)
c->pkeys[SSL_PKEY_ECC].digest = EVP_sha1();
void SSL_set_verify(SSL *s, int mode,
int (*callback)(int ok, X509_STORE_CTX *ctx));
void SSL_set_verify_depth(SSL *s, int depth);
-#ifndef OPENSSL_NO_RSA
int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa);
-#endif
int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len);
int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, long len);
int (*callback)(int, X509_STORE_CTX *));
void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth);
void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, int (*cb)(X509_STORE_CTX *, void *), void *arg);
-#ifndef OPENSSL_NO_RSA
int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa);
-#endif
int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, long len);
int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey);
int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, const unsigned char *d, long len);
SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL)
/* NB: the keylength is only applicable when is_export is true */
-#ifndef OPENSSL_NO_RSA
void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,
RSA *(*cb)(SSL *ssl, int is_export, int keylength));
void SSL_set_tmp_rsa_callback(SSL *ssl,
RSA *(*cb)(SSL *ssl, int is_export, int keylength));
-#endif
#ifndef OPENSSL_NO_DH
void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,
DH *(*dh)(SSL *ssl, int is_export, int keylength));
EVP_add_digest(EVP_sha256());
EVP_add_digest(EVP_sha384());
EVP_add_digest(EVP_sha512());
-#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_DSA)
EVP_add_digest(EVP_dss1()); /* DSA with sha1 */
EVP_add_digest_alias(SN_dsaWithSHA1, SN_dsaWithSHA1_2);
EVP_add_digest_alias(SN_dsaWithSHA1, "DSS1");
EVP_add_digest_alias(SN_dsaWithSHA1, "dss1");
-#endif
#ifndef OPENSSL_NO_ECDSA
EVP_add_digest(EVP_ecdsa());
#endif
ssl_cert_set_default_md(CERT *cert)
{
/* Set digest values to defaults */
-#ifndef OPENSSL_NO_DSA
cert->pkeys[SSL_PKEY_DSA_SIGN].digest = EVP_sha1();
-#endif
-#ifndef OPENSSL_NO_RSA
cert->pkeys[SSL_PKEY_RSA_SIGN].digest = EVP_sha1();
cert->pkeys[SSL_PKEY_RSA_ENC].digest = EVP_sha1();
-#endif
#ifndef OPENSSL_NO_ECDSA
cert->pkeys[SSL_PKEY_ECC].digest = EVP_sha1();
#endif
ret->export_mask_k = cert->export_mask_k;
ret->export_mask_a = cert->export_mask_a;
-#ifndef OPENSSL_NO_RSA
if (cert->rsa_tmp != NULL) {
RSA_up_ref(cert->rsa_tmp);
ret->rsa_tmp = cert->rsa_tmp;
}
ret->rsa_tmp_cb = cert->rsa_tmp_cb;
-#endif
#ifndef OPENSSL_NO_DH
if (cert->dh_tmp != NULL) {
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_ECDH)
err:
#endif
-#ifndef OPENSSL_NO_RSA
if (ret->rsa_tmp != NULL)
RSA_free(ret->rsa_tmp);
-#endif
#ifndef OPENSSL_NO_DH
if (ret->dh_tmp != NULL)
DH_free(ret->dh_tmp);
if (i > 0)
return;
-#ifndef OPENSSL_NO_RSA
if (c->rsa_tmp)
RSA_free(c->rsa_tmp);
-#endif
#ifndef OPENSSL_NO_DH
if (c->dh_tmp)
DH_free(c->dh_tmp);
#endif
}
-#ifndef OPENSSL_NO_RSA
if (sc->peer_rsa_tmp != NULL)
RSA_free(sc->peer_rsa_tmp);
-#endif
#ifndef OPENSSL_NO_DH
if (sc->peer_dh_tmp != NULL)
DH_free(sc->peer_dh_tmp);
*mac = 0;
*ssl = 0;
-#ifdef OPENSSL_NO_RSA
- *mkey |= SSL_kRSA;
- *auth |= SSL_aRSA;
-#endif
-#ifdef OPENSSL_NO_DSA
- *auth |= SSL_aDSS;
-#endif
*mkey |= SSL_kDHr|SSL_kDHd; /* no such ciphersuites supported! */
*auth |= SSL_aDH;
#ifdef OPENSSL_NO_DH
kl = SSL_C_EXPORT_PKEYLENGTH(cipher);
-#ifndef OPENSSL_NO_RSA
rsa_tmp = (c->rsa_tmp != NULL || c->rsa_tmp_cb != NULL);
rsa_tmp_export = (c->rsa_tmp_cb != NULL ||
(rsa_tmp && RSA_size(c->rsa_tmp)*8 <= kl));
-#else
- rsa_tmp = rsa_tmp_export = 0;
-#endif
#ifndef OPENSSL_NO_DH
dh_tmp = (c->dh_tmp != NULL || c->dh_tmp_cb != NULL);
dh_tmp_export = (c->dh_tmp_cb != NULL ||
* \param cb the callback
*/
-#ifndef OPENSSL_NO_RSA
void
SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx, RSA *(*cb)(SSL *ssl,
int is_export,
{
SSL_callback_ctrl(ssl, SSL_CTRL_SET_TMP_RSA_CB,(void (*)(void))cb);
}
-#endif
#ifdef DOXYGEN
/*!
#endif
#include <openssl/bio.h>
#include <openssl/stack.h>
-#ifndef OPENSSL_NO_RSA
#include <openssl/rsa.h>
-#endif
-#ifndef OPENSSL_NO_DSA
#include <openssl/dsa.h>
-#endif
#include <openssl/err.h>
#include <openssl/ssl.h>
unsigned long mask_a;
unsigned long export_mask_k;
unsigned long export_mask_a;
-#ifndef OPENSSL_NO_RSA
RSA *rsa_tmp;
RSA *(*rsa_tmp_cb)(SSL *ssl, int is_export, int keysize);
-#endif
#ifndef OPENSSL_NO_DH
DH *dh_tmp;
DH *(*dh_tmp_cb)(SSL *ssl, int is_export, int keysize);
/* Obviously we don't have the private keys of these,
* so maybe we shouldn't even use the CERT_PKEY type here. */
-#ifndef OPENSSL_NO_RSA
RSA *peer_rsa_tmp; /* not used for SSL 2 */
-#endif
#ifndef OPENSSL_NO_DH
DH *peer_dh_tmp; /* not used for SSL 2 */
#endif
return (ret);
}
-#ifndef OPENSSL_NO_RSA
int
SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa)
{
EVP_PKEY_free(pkey);
return (ret);
}
-#endif
static int
ssl_set_pkey(CERT *c, EVP_PKEY *pkey)
EVP_PKEY_free(pktmp);
ERR_clear_error();
-#ifndef OPENSSL_NO_RSA
/* Don't check the public/private key, this is mostly
* for smart cards. */
if ((pkey->type == EVP_PKEY_RSA) &&
(RSA_flags(pkey->pkey.rsa) & RSA_METHOD_FLAG_NO_CHECK))
;
else
-#endif
if (!X509_check_private_key(c->pkeys[i].x509, pkey)) {
X509_free(c->pkeys[i].x509);
c->pkeys[i].x509 = NULL;
return (1);
}
-#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_STDIO
int
SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type)
RSA_free(rsa);
return (ret);
}
-#endif /* !OPENSSL_NO_RSA */
int
SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey)
EVP_PKEY_copy_parameters(pkey, c->pkeys[i].privatekey);
ERR_clear_error();
-#ifndef OPENSSL_NO_RSA
/* Don't check the public/private key, this is mostly
* for smart cards. */
if ((c->pkeys[i].privatekey->type == EVP_PKEY_RSA) &&
RSA_METHOD_FLAG_NO_CHECK))
;
else
-#endif /* OPENSSL_NO_RSA */
if (!X509_check_private_key(x, c->pkeys[i].privatekey)) {
/* don't fail for a cert/key mismatch, just free
* current private key (when switching to a different
return (ret);
}
-#ifndef OPENSSL_NO_RSA
int
SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa)
{
RSA_free(rsa);
return (ret);
}
-#endif /* !OPENSSL_NO_RSA */
int
SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey)
* customisable at some point, for now include everything we support.
*/
-#ifdef OPENSSL_NO_RSA
-#define tlsext_sigalg_rsa(md) /* */
-#else
#define tlsext_sigalg_rsa(md) md, TLSEXT_signature_rsa,
-#endif
-#ifdef OPENSSL_NO_DSA
-#define tlsext_sigalg_dsa(md) /* */
-#else
#define tlsext_sigalg_dsa(md) md, TLSEXT_signature_dsa,
-#endif
#ifdef OPENSSL_NO_ECDSA
#define tlsext_sigalg_ecdsa(md) /* */
};
static tls12_lookup tls12_sig[] = {
-#ifndef OPENSSL_NO_RSA
{EVP_PKEY_RSA, TLSEXT_signature_rsa},
-#endif
-#ifndef OPENSSL_NO_DSA
{EVP_PKEY_DSA, TLSEXT_signature_dsa},
-#endif
#ifndef OPENSSL_NO_ECDSA
{EVP_PKEY_EC, TLSEXT_signature_ecdsa}
#endif
unsigned char hash_alg = data[i], sig_alg = data[i + 1];
switch (sig_alg) {
-#ifndef OPENSSL_NO_RSA
case TLSEXT_signature_rsa:
idx = SSL_PKEY_RSA_SIGN;
break;
-#endif
-#ifndef OPENSSL_NO_DSA
case TLSEXT_signature_dsa:
idx = SSL_PKEY_DSA_SIGN;
break;
-#endif
#ifndef OPENSSL_NO_ECDSA
case TLSEXT_signature_ecdsa:
idx = SSL_PKEY_ECC;
/* Set any remaining keys to default values. NOTE: if alg is not
* supported it stays as NULL.
*/
-#ifndef OPENSSL_NO_DSA
if (!c->pkeys[SSL_PKEY_DSA_SIGN].digest)
c->pkeys[SSL_PKEY_DSA_SIGN].digest = EVP_sha1();
-#endif
-#ifndef OPENSSL_NO_RSA
if (!c->pkeys[SSL_PKEY_RSA_SIGN].digest) {
c->pkeys[SSL_PKEY_RSA_SIGN].digest = EVP_sha1();
c->pkeys[SSL_PKEY_RSA_ENC].digest = EVP_sha1();
}
-#endif
#ifndef OPENSSL_NO_ECDSA
if (!c->pkeys[SSL_PKEY_ECC].digest)
c->pkeys[SSL_PKEY_ECC].digest = EVP_sha1();