From: tb Date: Wed, 13 Jul 2022 18:38:20 +0000 (+0000) Subject: Simplify computation of max_pub_key = dh->p - 1. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4ce274f75c71cf18bf08beaf8925c02a4fb0f574;p=openbsd Simplify computation of max_pub_key = dh->p - 1. ok jsing --- 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)