Check for 0 modulus in BN_MONT_CTX_set
[openssl.git] / crypto / bn / bn_mont.c
index 1580e978ceac09d80cf3b136d13069f409466536..d4d817a74f8c2d82ec34bd8fa0b64d911717cf39 100644 (file)
@@ -351,6 +351,9 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
     int ret = 0;
     BIGNUM *Ri, *R;
 
+    if (BN_is_zero(mod))
+        return 0;
+
     BN_CTX_start(ctx);
     if ((Ri = BN_CTX_get(ctx)) == NULL)
         goto err;