From 4ce274f75c71cf18bf08beaf8925c02a4fb0f574 Mon Sep 17 00:00:00 2001 From: tb Date: Wed, 13 Jul 2022 18:38:20 +0000 Subject: [PATCH] Simplify computation of max_pub_key = dh->p - 1. ok jsing --- lib/libcrypto/dh/dh_check.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/dh/dh_check.c b/lib/libcrypto/dh/dh_check.c index 1d20952e26d..ee405f92b10 100644 --- a/lib/libcrypto/dh/dh_check.c +++ b/lib/libcrypto/dh/dh_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dh_check.c,v 1.24 2022/01/10 12:00:52 tb Exp $ */ +/* $OpenBSD: dh_check.c,v 1.25 2022/07/13 18:38:20 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -269,9 +269,7 @@ DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *flags) *flags |= DH_CHECK_PUBKEY_TOO_SMALL; /* max_pub_key = dh->p - 1 */ - if (BN_copy(max_pub_key, dh->p) == NULL) - goto err; - if (!BN_sub_word(max_pub_key, 1)) + if (!BN_sub(max_pub_key, dh->p, BN_value_one())) goto err; if (BN_cmp(pub_key, max_pub_key) >= 0) -- 2.20.1