dh=s->session->sess_cert->dh_tmp;
dh=s->session->sess_cert->peer_dh_tmp;
static int ssl3_check_cert_and_algorithm(SSL *s)	{	int i,idx;	long algs;	EVP_PKEY *pkey=NULL;	CERT *c;#ifndef NO_RSA	RSA *rsa;#endif#ifndef NO_DH	DH *dh;#endif	c=s->session->sess_cert;	if (c == NULL)		{		SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_INTERNAL_ERROR);		goto err;		}	algs=s->s3->tmp.new_cipher->algorithms;	/* we don't have a certificate */	if (algs & (SSL_aDH|SSL_aNULL))		return(1);#ifndef NO_RSA	rsa=s->session->sess_cert->rsa_tmp;#endif#ifndef NO_DH	dh=s->session->sess_cert->dh_tmp;#endif	/* This is the passed certificate */	idx=c->cert_type;	pkey=X509_get_pubkey(c->pkeys[idx].x509);	i=X509_certificate_type(c->pkeys[idx].x509,pkey);	EVP_PKEY_free(pkey);		/* Check that we have a certificate if we require one */	if ((algs & SSL_aRSA) && !has_bits(i,EVP_PK_RSA|EVP_PKT_SIGN))		{		SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_RSA_SIGNING_CERT);		goto f_err;		}#ifndef NO_DSA	else if ((algs & 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 NO_RSA	if ((algs & 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 NO_DH	if ((algs & 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_KEY);		goto f_err;		}	else if ((algs & SSL_kDHr) && !has_bits(i,EVP_PK_DH|EVP_PKS_RSA))		{		SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_DH_RSA_CERT);		goto f_err;		}#ifndef NO_DSA	else if ((algs & 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_IS_EXPORT(algs) && !has_bits(i,EVP_PKT_EXP))		{#ifndef NO_RSA		if (algs & SSL_kRSA)			{			if (rsa == NULL			    || RSA_size(rsa) > SSL_EXPORT_PKEYLENGTH(algs))				{				SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_RSA_KEY);				goto f_err;				}			}		else#endif#ifndef NO_DH			if (algs & (SSL_kEDH|SSL_kDHr|SSL_kDHd))			    {			    if (dh == NULL				|| DH_size(dh) > SSL_EXPORT_PKEYLENGTH(algs))				{				SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_MISSING_EXPORT_TMP_DH_KEY);				goto f_err;				}			}		else#endif			{			SSLerr(SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM,SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE);			goto f_err;			}		}	return(1);f_err:	ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE);err:	return(0);	}