Check for 0 modulus in BN_MONT_CTX_set
[openssl.git] / crypto / bn / bn_mont.c
index aafd1b852654b60256ab08bc842ba3c34dfa17f6..be95bd55d02064793ee505f171f42d0431294049 100644 (file)
@@ -373,6 +373,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;