From: tb Date: Mon, 7 Feb 2022 19:44:23 +0000 (+0000) Subject: Check for zero modulus in BN_MONT_CTX_set(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=916b323f32dbf9e6f9583662bcc722f3137c4725;p=openbsd Check for zero modulus in BN_MONT_CTX_set(). From OpenSSL 6a009812, prompted by a report by Guido Vranken ok beck jsing --- diff --git a/lib/libcrypto/bn/bn_mont.c b/lib/libcrypto/bn/bn_mont.c index 45e312a3a6d..e01af702e77 100644 --- a/lib/libcrypto/bn/bn_mont.c +++ b/lib/libcrypto/bn/bn_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mont.c,v 1.27 2021/12/04 16:05:46 tb Exp $ */ +/* $OpenBSD: bn_mont.c,v 1.28 2022/02/07 19:44:23 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -369,6 +369,9 @@ 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;