diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index 1580e978ceac09d80cf3b136d13069f409466536..d4d817a74f8c2d82ec34bd8fa0b64d911717cf39 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -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;