Check return from BN_sub
authorPauli <paul.dale@oracle.com>
Tue, 31 Jul 2018 03:11:00 +0000 (13:11 +1000)
committerPauli <paul.dale@oracle.com>
Tue, 31 Jul 2018 04:50:55 +0000 (14:50 +1000)
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6823)

(cherry picked from commit 3d3cbce550ff5d6172cf28dbbf80bda93f6577a9)

crypto/rsa/rsa_ossl.c

index 41fafa7418ad15cd4089f186ef3b0c56644cc2ff..8e81cbb4110df5279b842eb7434ce41a8ca94b0c 100644 (file)
@@ -332,7 +332,8 @@ static int rsa_ossl_private_encrypt(int flen, const unsigned char *from,
             goto err;
 
     if (padding == RSA_X931_PADDING) {
-        BN_sub(f, rsa->n, ret);
+        if (!BN_sub(f, rsa->n, ret))
+            goto err;
         if (BN_cmp(ret, f) > 0)
             res = f;
         else