diff options
Diffstat (limited to 'crypto/openssl/crypto/rsa')
-rw-r--r-- | crypto/openssl/crypto/rsa/rsa.h | 24 | ||||
-rw-r--r-- | crypto/openssl/crypto/rsa/rsa_eay.c | 26 | ||||
-rw-r--r-- | crypto/openssl/crypto/rsa/rsa_lib.c | 33 |
3 files changed, 48 insertions, 35 deletions
diff --git a/crypto/openssl/crypto/rsa/rsa.h b/crypto/openssl/crypto/rsa/rsa.h index b449228..880ebfe 100644 --- a/crypto/openssl/crypto/rsa/rsa.h +++ b/crypto/openssl/crypto/rsa/rsa.h @@ -60,10 +60,9 @@ #ifndef HEADER_RSA_H #define HEADER_RSA_H -#ifdef __cplusplus -extern "C" { +#ifndef NO_BIO +#include <openssl/bio.h> #endif - #include <openssl/bn.h> #include <openssl/crypto.h> @@ -71,6 +70,10 @@ extern "C" { #error RSA is disabled. #endif +#ifdef __cplusplus +extern "C" { +#endif + typedef struct rsa_st RSA; typedef struct rsa_meth_st @@ -192,8 +195,11 @@ RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth); /* This function needs the memory locking malloc callbacks to be installed */ int RSA_memory_lock(RSA *r); +/* If you have RSAref compiled in. */ +RSA_METHOD *RSA_PKCS1_RSAref(void); + /* these are the actual SSLeay RSA functions */ -RSA_METHOD *RSA_PKCS1(void); +RSA_METHOD *RSA_PKCS1_SSLeay(void); RSA_METHOD *RSA_null_method(void); @@ -207,10 +213,14 @@ int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); int RSA_print_fp(FILE *fp, RSA *r,int offset); #endif -#ifdef HEADER_BIO_H +#ifndef NO_BIO int RSA_print(BIO *bp, RSA *r,int offset); #endif +int i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey); +RSA *d2i_RSA_NET(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey); +RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey); + int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()); /* Naughty internal function required elsewhere, to handle a MS structure @@ -257,7 +267,6 @@ int RSA_padding_add_none(unsigned char *to,int tlen, int RSA_padding_check_none(unsigned char *to,int tlen, unsigned char *f,int fl,int rsa_len); -int RSA_libversion(); int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); int RSA_set_ex_data(RSA *r,int idx,void *arg); @@ -330,9 +339,6 @@ void *RSA_get_ex_data(RSA *r, int idx); #define RSA_R_UNKNOWN_PADDING_TYPE 118 #define RSA_R_WRONG_SIGNATURE_LENGTH 119 -#define RSALIB_OPENSSL 1 -#define RSALIB_RSAREF 2 - #ifdef __cplusplus } #endif diff --git a/crypto/openssl/crypto/rsa/rsa_eay.c b/crypto/openssl/crypto/rsa/rsa_eay.c index f73d7b2..8162117 100644 --- a/crypto/openssl/crypto/rsa/rsa_eay.c +++ b/crypto/openssl/crypto/rsa/rsa_eay.c @@ -63,6 +63,8 @@ #include <openssl/rsa.h> #include <openssl/rand.h> +#ifndef RSA_NULL + static int RSA_eay_public_encrypt(int flen, unsigned char *from, unsigned char *to, RSA *rsa,int padding); static int RSA_eay_private_encrypt(int flen, unsigned char *from, @@ -88,7 +90,7 @@ static RSA_METHOD rsa_pkcs1_eay_meth={ NULL, }; -RSA_METHOD *RSA_PKCS1(void) +RSA_METHOD *RSA_PKCS1_SSLeay(void) { return(&rsa_pkcs1_eay_meth); } @@ -105,7 +107,7 @@ static int RSA_eay_public_encrypt(int flen, unsigned char *from, BN_init(&ret); if ((ctx=BN_CTX_new()) == NULL) goto err; num=BN_num_bytes(rsa->n); - if ((buf=(unsigned char *)Malloc(num)) == NULL) + if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) { RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,ERR_R_MALLOC_FAILURE); goto err; @@ -160,7 +162,7 @@ err: if (buf != NULL) { memset(buf,0,num); - Free(buf); + OPENSSL_free(buf); } return(r); } @@ -178,7 +180,7 @@ static int RSA_eay_private_encrypt(int flen, unsigned char *from, if ((ctx=BN_CTX_new()) == NULL) goto err; num=BN_num_bytes(rsa->n); - if ((buf=(unsigned char *)Malloc(num)) == NULL) + if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) { RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE); goto err; @@ -236,7 +238,7 @@ err: if (buf != NULL) { memset(buf,0,num); - Free(buf); + OPENSSL_free(buf); } return(r); } @@ -257,13 +259,13 @@ static int RSA_eay_private_decrypt(int flen, unsigned char *from, num=BN_num_bytes(rsa->n); - if ((buf=(unsigned char *)Malloc(num)) == NULL) + if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL) { RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE); goto err; } - /* This check was for equallity but PGP does evil things + /* This check was for equality but PGP does evil things * and chops off the top '0' bytes */ if (flen > num) { @@ -329,7 +331,7 @@ err: if (buf != NULL) { memset(buf,0,num); - Free(buf); + OPENSSL_free(buf); } return(r); } @@ -349,14 +351,14 @@ static int RSA_eay_public_decrypt(int flen, unsigned char *from, if (ctx == NULL) goto err; num=BN_num_bytes(rsa->n); - buf=(unsigned char *)Malloc(num); + buf=(unsigned char *)OPENSSL_malloc(num); if (buf == NULL) { RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,ERR_R_MALLOC_FAILURE); goto err; } - /* This check was for equallity but PGP does evil things + /* This check was for equality but PGP does evil things * and chops off the top '0' bytes */ if (flen > num) { @@ -401,7 +403,7 @@ err: if (buf != NULL) { memset(buf,0,num); - Free(buf); + OPENSSL_free(buf); } return(r); } @@ -487,4 +489,4 @@ static int RSA_eay_finish(RSA *rsa) return(1); } - +#endif diff --git a/crypto/openssl/crypto/rsa/rsa_lib.c b/crypto/openssl/crypto/rsa/rsa_lib.c index c2a0b03..f5d1770 100644 --- a/crypto/openssl/crypto/rsa/rsa_lib.c +++ b/crypto/openssl/crypto/rsa/rsa_lib.c @@ -82,6 +82,19 @@ void RSA_set_default_method(RSA_METHOD *meth) RSA_METHOD *RSA_get_default_method(void) { + if (default_RSA_meth == NULL) + { +#ifdef RSA_NULL + default_RSA_meth=RSA_null_method(); +#else +#ifdef RSAref + default_RSA_meth=RSA_PKCS1_RSAref(); +#else + default_RSA_meth=RSA_PKCS1_SSLeay(); +#endif +#endif + } + return default_RSA_meth; } @@ -104,15 +117,7 @@ RSA *RSA_new_method(RSA_METHOD *meth) { RSA *ret; - if (default_RSA_meth == NULL) - { -#ifdef RSA_NULL - default_RSA_meth=RSA_null_method(); -#else - default_RSA_meth=RSA_PKCS1(); -#endif - } - ret=(RSA *)Malloc(sizeof(RSA)); + ret=(RSA *)OPENSSL_malloc(sizeof(RSA)); if (ret == NULL) { RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE); @@ -120,7 +125,7 @@ RSA *RSA_new_method(RSA_METHOD *meth) } if (meth == NULL) - ret->meth=default_RSA_meth; + ret->meth=RSA_get_default_method(); else ret->meth=meth; @@ -143,7 +148,7 @@ RSA *RSA_new_method(RSA_METHOD *meth) ret->flags=ret->meth->flags; if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { - Free(ret); + OPENSSL_free(ret); ret=NULL; } else @@ -184,8 +189,8 @@ void RSA_free(RSA *r) if (r->dmq1 != NULL) BN_clear_free(r->dmq1); if (r->iqmp != NULL) BN_clear_free(r->iqmp); if (r->blinding != NULL) BN_BLINDING_free(r->blinding); - if (r->bignum_data != NULL) Free_locked(r->bignum_data); - Free(r); + if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data); + OPENSSL_free(r); } int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, @@ -302,7 +307,7 @@ int RSA_memory_lock(RSA *r) j=1; for (i=0; i<6; i++) j+= (*t[i])->top; - if ((p=Malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL) + if ((p=OPENSSL_malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL) { RSAerr(RSA_F_MEMORY_LOCK,ERR_R_MALLOC_FAILURE); return(0); |