From 916b323f32dbf9e6f9583662bcc722f3137c4725 Mon Sep 17 00:00:00 2001 From: tb Date: Mon, 7 Feb 2022 19:44:23 +0000 Subject: [PATCH] Check for zero modulus in BN_MONT_CTX_set(). From OpenSSL 6a009812, prompted by a report by Guido Vranken ok beck jsing --- lib/libcrypto/bn/bn_mont.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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; -- 2.20.1