summaryrefslogtreecommitdiff
path: root/crypto/rsa
diff options
context:
space:
mode:
authorUlf Möller <ulf@openssl.org>2001-06-06 17:23:23 +0000
committerUlf Möller <ulf@openssl.org>2001-06-06 17:23:23 +0000
commit8ca2ae775d418b44b0206788744ca0e5f5d9dc3d (patch)
tree3badfa8b3ebdd76405eebae212eb1dc94d98c1e9 /crypto/rsa
parentee8aa8217abc66c7d5d280960755a0180a20757d (diff)
downloadopenssl-new-8ca2ae775d418b44b0206788744ca0e5f5d9dc3d.tar.gz
move check to avoid memory leak.
Diffstat (limited to 'crypto/rsa')
-rw-r--r--crypto/rsa/rsa_oaep.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c
index a3361dc3d7..64b59ee121 100644
--- a/crypto/rsa/rsa_oaep.c
+++ b/crypto/rsa/rsa_oaep.c
@@ -102,6 +102,14 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
return (-1);
}
+ lzero = num - flen;
+ if (lzero < 0)
+ {
+ RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR);
+ return (-1);
+ }
+ maskeddb = from - lzero + SHA_DIGEST_LENGTH;
+
dblen = num - SHA_DIGEST_LENGTH;
db = OPENSSL_malloc(dblen);
if (db == NULL)
@@ -110,14 +118,6 @@ int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
return (-1);
}
- lzero = num - flen;
- if (lzero < 0)
- {
- RSAerr(RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP, RSA_R_OAEP_DECODING_ERROR);
- return (-1);
- }
- maskeddb = from - lzero + SHA_DIGEST_LENGTH;
-
MGF1(seed, SHA_DIGEST_LENGTH, maskeddb, dblen);
for (i = lzero; i < SHA_DIGEST_LENGTH; i++)
seed[i] ^= from[i - lzero];