/* ssl/ssl_rsa.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
return(ssl_set_cert(c,x));
}
+#ifndef NO_STDIO
int SSL_use_certificate_file(ssl, file, type)
SSL *ssl;
char *file;
int ret=0;
X509 *x=NULL;
-#ifdef WIN16
- in=BIO_new(BIO_s_file_internal_w16());
-#else
- in=BIO_new(BIO_s_file());
-#endif
+ in=BIO_new(BIO_s_file_internal());
if (in == NULL)
{
SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE,ERR_R_BUF_LIB);
if (BIO_read_filename(in,file) <= 0)
{
- SYSerr(SYS_F_FOPEN,errno);
SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE,ERR_R_SYS_LIB);
goto end;
}
if (in != NULL) BIO_free(in);
return(ret);
}
+#endif
int SSL_use_certificate_ASN1(ssl, len, d)
SSL *ssl;
if (c->pkeys[i].x509 != NULL)
{
- if (!X509_check_private_key(c->pkeys[i].x509,pkey))
+ EVP_PKEY_copy_parameters(
+ X509_get_pubkey(c->pkeys[i].x509),pkey);
+ ERR_clear_error();
+
+#ifndef 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))
+ ok=1;
+ else
+#endif
+ if (!X509_check_private_key(c->pkeys[i].x509,pkey))
{
if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA))
{
}
#ifndef NO_RSA
+#ifndef NO_STDIO
int SSL_use_RSAPrivateKey_file(ssl, file, type)
SSL *ssl;
char *file;
BIO *in;
RSA *rsa=NULL;
-#ifdef WIN16
- in=BIO_new(BIO_s_file_internal_w16());
-#else
- in=BIO_new(BIO_s_file());
-#endif
+ in=BIO_new(BIO_s_file_internal());
if (in == NULL)
{
SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,ERR_R_BUF_LIB);
if (BIO_read_filename(in,file) <= 0)
{
- SYSerr(SYS_F_FOPEN,errno);
SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE,ERR_R_SYS_LIB);
goto end;
}
if (in != NULL) BIO_free(in);
return(ret);
}
+#endif
int SSL_use_RSAPrivateKey_ASN1(ssl,d,len)
SSL *ssl;
return(ret);
}
+#ifndef NO_STDIO
int SSL_use_PrivateKey_file(ssl, file, type)
SSL *ssl;
char *file;
BIO *in;
EVP_PKEY *pkey=NULL;
-#ifdef WIN16
- in=BIO_new(BIO_s_file_internal_w16());
-#else
- in=BIO_new(BIO_s_file());
-#endif
+ in=BIO_new(BIO_s_file_internal());
if (in == NULL)
{
SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE,ERR_R_BUF_LIB);
if (BIO_read_filename(in,file) <= 0)
{
- SYSerr(SYS_F_FOPEN,errno);
SSLerr(SSL_F_SSL_USE_PRIVATEKEY_FILE,ERR_R_SYS_LIB);
goto end;
}
if (in != NULL) BIO_free(in);
return(ret);
}
+#endif
int SSL_use_PrivateKey_ASN1(type,ssl,d,len)
int type;
pkey=X509_get_pubkey(x);
if (pkey == NULL)
{
- SSLerr(SSL_F_SSL_SET_PKEY,SSL_R_X509_LIB);
+ SSLerr(SSL_F_SSL_SET_CERT,SSL_R_X509_LIB);
return(0);
}
i=ssl_cert_type(x,pkey);
if (i < 0)
{
- SSLerr(SSL_F_SSL_SET_PKEY,SSL_R_UNKNOWN_CERTIFICATE_TYPE);
+ SSLerr(SSL_F_SSL_SET_CERT,SSL_R_UNKNOWN_CERTIFICATE_TYPE);
return(0);
}
if (c->pkeys[i].privatekey != NULL)
+ {
+ EVP_PKEY_copy_parameters(pkey,c->pkeys[i].privatekey);
+ ERR_clear_error();
+
+#ifndef 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_flags(c->pkeys[i].privatekey->pkey.rsa) &
+ RSA_METHOD_FLAG_NO_CHECK))
+ ok=1;
+ else
+#endif
{
if (!X509_check_private_key(x,c->pkeys[i].privatekey))
{
}
else
ok=1;
+ } /* NO_RSA */
}
else
ok=1;
return(1);
}
+#ifndef NO_STDIO
int SSL_CTX_use_certificate_file(ctx, file, type)
SSL_CTX *ctx;
char *file;
int ret=0;
X509 *x=NULL;
-#ifdef WIN16
- in=BIO_new(BIO_s_file_internal_w16());
-#else
- in=BIO_new(BIO_s_file());
-#endif
+ in=BIO_new(BIO_s_file_internal());
if (in == NULL)
{
SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE,ERR_R_BUF_LIB);
if (BIO_read_filename(in,file) <= 0)
{
- SYSerr(SYS_F_FOPEN,errno);
SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE,ERR_R_SYS_LIB);
goto end;
}
if (in != NULL) BIO_free(in);
return(ret);
}
+#endif
int SSL_CTX_use_certificate_ASN1(ctx, len, d)
SSL_CTX *ctx;
return(ret);
}
+#ifndef NO_STDIO
int SSL_CTX_use_RSAPrivateKey_file(ctx, file, type)
SSL_CTX *ctx;
char *file;
BIO *in;
RSA *rsa=NULL;
-#ifdef WIN16
- in=BIO_new(BIO_s_file_internal_w16());
-#else
- in=BIO_new(BIO_s_file());
-#endif
+ in=BIO_new(BIO_s_file_internal());
if (in == NULL)
{
SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE,ERR_R_BUF_LIB);
if (BIO_read_filename(in,file) <= 0)
{
- SYSerr(SYS_F_FOPEN,errno);
SSLerr(SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE,ERR_R_SYS_LIB);
goto end;
}
if (in != NULL) BIO_free(in);
return(ret);
}
+#endif
int SSL_CTX_use_RSAPrivateKey_ASN1(ctx,d,len)
SSL_CTX *ctx;
return(ssl_set_pkey(c,pkey));
}
+#ifndef NO_STDIO
int SSL_CTX_use_PrivateKey_file(ctx, file, type)
SSL_CTX *ctx;
char *file;
BIO *in;
EVP_PKEY *pkey=NULL;
-#ifdef WIN16
- in=BIO_new(BIO_s_file_internal_w16());
-#else
- in=BIO_new(BIO_s_file());
-#endif
+ in=BIO_new(BIO_s_file_internal());
if (in == NULL)
{
SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE,ERR_R_BUF_LIB);
if (BIO_read_filename(in,file) <= 0)
{
- SYSerr(SYS_F_FOPEN,errno);
SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE,ERR_R_SYS_LIB);
goto end;
}
if (in != NULL) BIO_free(in);
return(ret);
}
+#endif
int SSL_CTX_use_PrivateKey_ASN1(type,ctx,d,len)
int type;