Fix SSL 2.0 rollback checking: The previous implementation of the
[openssl.git] / crypto / rsa / rsa_eay.c
index 7f51c42e9fea3f7aa55fdb72cfab8909d53eae5e..618b5bd59565ec819272aa8a8e9d88f42cfea1ba 100644 (file)
@@ -62,6 +62,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,
@@ -104,7 +106,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;
@@ -159,7 +161,7 @@ err:
        if (buf != NULL) 
                {
                memset(buf,0,num);
-               Free(buf);
+               OPENSSL_free(buf);
                }
        return(r);
        }
@@ -177,7 +179,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;
@@ -235,7 +237,7 @@ err:
        if (buf != NULL)
                {
                memset(buf,0,num);
-               Free(buf);
+               OPENSSL_free(buf);
                }
        return(r);
        }
@@ -256,13 +258,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)
                {
@@ -328,7 +330,7 @@ err:
        if (buf != NULL)
                {
                memset(buf,0,num);
-               Free(buf);
+               OPENSSL_free(buf);
                }
        return(r);
        }
@@ -348,14 +350,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)
                {
@@ -400,7 +402,7 @@ err:
        if (buf != NULL)
                {
                memset(buf,0,num);
-               Free(buf);
+               OPENSSL_free(buf);
                }
        return(r);
        }
@@ -486,4 +488,4 @@ static int RSA_eay_finish(RSA *rsa)
        return(1);
        }
 
-
+#endif