Fix from 0.9.8-stable
authorDr. Stephen Henson <steve@openssl.org>
Fri, 26 Jun 2009 23:14:11 +0000 (23:14 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 26 Jun 2009 23:14:11 +0000 (23:14 +0000)
crypto/rsa/rsa_oaep.c

index 70bacf850e36cfddce20c076a1fd79400a8d80e7..e238d10e5cc6fc517e0a6ce4cb42f453da2552ad 100644 (file)
@@ -52,13 +52,6 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
                return 0;
                }
 
-       dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH);
-       if (dbmask == NULL)
-               {
-               RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
-               return 0;
-               }
-
        to[0] = 0;
        seed = to + 1;
        db = to + SHA_DIGEST_LENGTH + 1;
@@ -76,6 +69,13 @@ int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
           20);
 #endif
 
+       dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH);
+       if (dbmask == NULL)
+               {
+               RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
+               return 0;
+               }
+
        if (MGF1(dbmask, emlen - SHA_DIGEST_LENGTH, seed, SHA_DIGEST_LENGTH) < 0)
                return 0;
        for (i = 0; i < emlen - SHA_DIGEST_LENGTH; i++)