move check to avoid memory leak.
This commit is contained in:
parent
ee8aa8217a
commit
8ca2ae775d
@ -102,14 +102,6 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dblen = num - SHA_DIGEST_LENGTH;
|
|
||||||
db = OPENSSL_malloc(dblen);
|
|
||||||
if (db == NULL)
|
|
||||||
{
|
|
||||||
RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
lzero = num - flen;
|
lzero = num - flen;
|
||||||
if (lzero < 0)
|
if (lzero < 0)
|
||||||
{
|
{
|
||||||
@ -118,6 +110,14 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
|
|||||||
}
|
}
|
||||||
maskeddb = from - lzero + SHA_DIGEST_LENGTH;
|
maskeddb = from - lzero + SHA_DIGEST_LENGTH;
|
||||||
|
|
||||||
|
dblen = num - SHA_DIGEST_LENGTH;
|
||||||
|
db = OPENSSL_malloc(dblen);
|
||||||
|
if (db == NULL)
|
||||||
|
{
|
||||||
|
RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen);
|
MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen);
|
||||||
for (i = lzero; i < SHA_DIGEST_LENGTH; i++)
|
for (i = lzero; i < SHA_DIGEST_LENGTH; i++)
|
||||||
seed[i] ^= from[i - lzero];
|
seed[i] ^= from[i - lzero];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user