ssl_rsa.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#include <stdio.h>
#include "ssl_locl.h"
{
if (x == NULL)
{
return(0);
}
{
return(0);
}
}
#ifndef OPENSSL_NO_STDIO
{
int j;
int ret=0;
{
goto end;
}
{
goto end;
}
if (type == SSL_FILETYPE_ASN1)
{
}
else if (type == SSL_FILETYPE_PEM)
{
x=PEM_read_bio_X509(in,NULL,ssl->ctx->default_passwd_callback,ssl->ctx->default_passwd_callback_userdata);
}
else
{
goto end;
}
if (x == NULL)
{
goto end;
}
end:
return(ret);
}
#endif
{
X509 *x;
int ret;
if (x == NULL)
{
return(0);
}
X509_free(x);
return(ret);
}
#ifndef OPENSSL_NO_RSA
{
int ret;
{
return(0);
}
{
return(0);
}
{
return(0);
}
return(ret);
}
#endif
{
if (i < 0)
{
return(0);
}
{
#ifndef OPENSSL_NO_RSA
* for smart cards. */
ok=1;
else
#endif
{
if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA))
{
i=(i == SSL_PKEY_DH_RSA)?
ok=1;
else
{
if (!X509_check_private_key(
bad=1;
else
ok=1;
}
}
else
bad=1;
}
else
ok=1;
}
else
ok=1;
if (bad)
{
return(0);
}
ERR_clear_error(); /* make sure no error from X509_check_private_key()
* is left if we have chosen to ignore it */
c->valid=0;
return(1);
}
#ifndef OPENSSL_NO_RSA
#ifndef OPENSSL_NO_STDIO
{
int j,ret=0;
{
goto end;
}
{
goto end;
}
if (type == SSL_FILETYPE_ASN1)
{
}
else if (type == SSL_FILETYPE_PEM)
{
}
else
{
goto end;
}
{
goto end;
}
end:
return(ret);
}
#endif
{
int ret;
const unsigned char *p;
p=d;
{
return(0);
}
return(ret);
}
#endif /* !OPENSSL_NO_RSA */
{
int ret;
{
return(0);
}
{
return(0);
}
return(ret);
}
#ifndef OPENSSL_NO_STDIO
{
int j,ret=0;
{
goto end;
}
{
goto end;
}
if (type == SSL_FILETYPE_PEM)
{
}
else
{
goto end;
}
{
goto end;
}
end:
return(ret);
}
#endif
{
int ret;
unsigned char *p;
p=d;
{
return(0);
}
return(ret);
}
{
if (x == NULL)
{
return(0);
}
{
return(0);
}
}
{
pkey=X509_get_pubkey(x);
{
return(0);
}
i=ssl_cert_type(x,pkey);
if (i < 0)
{
return(0);
}
{
#ifndef OPENSSL_NO_RSA
* for smart cards. */
ok=1;
else
#endif
{
{
if ((i == SSL_PKEY_DH_RSA) || (i == SSL_PKEY_DH_DSA))
{
i=(i == SSL_PKEY_DH_RSA)?
ok=1;
else
{
if (!X509_check_private_key(x,
c->pkeys[i].privatekey))
bad=1;
else
ok=1;
}
}
else
bad=1;
}
else
ok=1;
} /* OPENSSL_NO_RSA */
}
else
ok=1;
if (bad)
{
}
c->valid=0;
return(1);
}
#ifndef OPENSSL_NO_STDIO
{
int j;
int ret=0;
{
goto end;
}
{
goto end;
}
if (type == SSL_FILETYPE_ASN1)
{
}
else if (type == SSL_FILETYPE_PEM)
{
}
else
{
goto end;
}
if (x == NULL)
{
goto end;
}
end:
return(ret);
}
#endif
{
X509 *x;
int ret;
if (x == NULL)
{
return(0);
}
X509_free(x);
return(ret);
}
#ifndef OPENSSL_NO_RSA
{
int ret;
{
return(0);
}
{
return(0);
}
{
return(0);
}
return(ret);
}
#ifndef OPENSSL_NO_STDIO
{
int j,ret=0;
{
goto end;
}
{
goto end;
}
if (type == SSL_FILETYPE_ASN1)
{
}
else if (type == SSL_FILETYPE_PEM)
{
}
else
{
goto end;
}
{
goto end;
}
end:
return(ret);
}
#endif
{
int ret;
const unsigned char *p;
p=d;
{
return(0);
}
return(ret);
}
#endif /* !OPENSSL_NO_RSA */
{
{
return(0);
}
{
return(0);
}
}
#ifndef OPENSSL_NO_STDIO
{
int j,ret=0;
{
goto end;
}
{
goto end;
}
if (type == SSL_FILETYPE_PEM)
{
}
else
{
goto end;
}
{
goto end;
}
end:
return(ret);
}
#endif
long len)
{
int ret;
unsigned char *p;
p=d;
{
return(0);
}
return(ret);
}
#ifndef OPENSSL_NO_STDIO
/* Read a file that contains our certificate in "PEM" format,
* possibly followed by a sequence of CA certificates that should be
* sent to the peer in the Certificate message.
*/
{
int ret=0;
{
goto end;
}
{
goto end;
}
if (x == NULL)
{
goto end;
}
if (ERR_peek_error() != 0)
ret = 0; /* Key/certificate mismatch doesn't imply ret==0 ... */
if (ret)
{
/* If we could set up our certificate, now proceed to
* the CA certificates.
*/
int r;
unsigned long err;
{
}
while ((ca = PEM_read_bio_X509(in,NULL,ctx->default_passwd_callback,ctx->default_passwd_callback_userdata))
!= NULL)
{
if (!r)
{
ret = 0;
goto end;
}
/* Note that we must not free r if it was successfully
* added to the chain (while we must free the main
* certificate, since its reference count is increased
* by SSL_CTX_use_certificate). */
}
/* When the while loop ends, it's usually just EOF. */
err = ERR_peek_last_error();
(void)ERR_get_error();
else
ret = 0; /* some real error */
}
end:
return(ret);
}
#endif