From nobody Sun May 28 00:05:51 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QTJpS2mqsz4X1s4; Sun, 28 May 2023 00:05:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QTJpS15Hvz46Jc; Sun, 28 May 2023 00:05:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685232352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F20uqpga6iZWjbOO/GfpMCBk+DXGZaF+M57h8LxbhxE=; b=MncVMcNDRq6/0ESG0G2ccGr3K6kVDag1CS28Pe5SSnaD3lZqHWT3UDJRRABf6FH1as/Tqu DcVVb3eMNOTtqIxwuPaMK2k76ODJ76q35lsOGT/39iWDnwGgQxgTqAxN5RH7VH1rLOF0L+ h4kHbpyDknEloZn8nWg3mw7ww5OdQ+kJE038Amg4RbJVHhuaXGiphyqCK8SGiiSPf/eraW HIthdCYC+ZkqbfSaFm5Fp6iX2lj3pUzFgt7IWeZjCalL5TfDe9PeOGX3AN6/Lz2HlFnrGj HI9wKMdg2UfNW+QsrFWn8jUOIsWoa8qm8ezfFfAHHQ43XiipwaYTC6O7M6MdPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685232352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F20uqpga6iZWjbOO/GfpMCBk+DXGZaF+M57h8LxbhxE=; b=WRlM3JVaLqp1I0RhNiiQVJqnViB2PCJHGy6/ej+g3M5QL//tVH1hT7ojWxi58AIqwyiui+ X1lGqMjbymBSA7JBrzFTXn1p0ti+Evp58ZxzA73h8KWoBqfINNkZP9MX/ieaCf1s4EdzYv TbpizJj83bEIhqGHo1UfE5bWTqM9TW+92IUm8d21DrgOABKh9YTPe93hcdb4YX+lrid1h5 Nd7ui0J80jXlbMR8eM9RWbVmuP45TfvaxTGYZCIqFDZ+BuMIgwBjPikcf3+BnnseM9EmfH uXkMo/ocpGsSmOmIu34yzEOYnhao1t3Ocacq4aAbwDoSoTX5q2GpIDdYZcVF6g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685232352; a=rsa-sha256; cv=none; b=CV1SPiyKXdG+53R9KPH0Ng2Uzt1uWQQp4ENxrZIcxUlyyIx+sLn7L1BNqaAzmR7yH603l0 zbxiykbRrVHYXaYR0tj1/o2Q0JrfsbAWSrX2KcJFtMerma0sbnIKuhC0suC5a9QVeFvFl7 NNo8y1aM3xS0NDKDu9G1UxozXD/GYC4XlPd38c3ybn9R5Vkm2j1G2QDWW7OV9G3eYIvZBy G7LNBjeLjO+n6OgLcBSnWbsavvGLhPNMXI2DYkpg9O9ujjCzdZTynI0a9BJYjCWlxyFuIO y9+8YotaikXU0fYFqvcGoOcaRoBMHhxqqeg+GygjUyztVrIPUucGaRRzw6cQ2g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QTJpS0BvBz185K; Sun, 28 May 2023 00:05:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34S05pd6083464; Sun, 28 May 2023 00:05:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34S05pEI083463; Sun, 28 May 2023 00:05:51 GMT (envelope-from git) Date: Sun, 28 May 2023 00:05:51 GMT Message-Id: <202305280005.34S05pEI083463@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Enji Cooper Subject: git: dcf5d5603b3a - main - Reduce ifdef soup by adding pre-3.0 compat support List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ngie X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dcf5d5603b3af831002caa7b2f64aec8bda14071 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=dcf5d5603b3af831002caa7b2f64aec8bda14071 commit dcf5d5603b3af831002caa7b2f64aec8bda14071 Author: Enji Cooper AuthorDate: 2023-05-27 21:07:45 +0000 Commit: Enji Cooper CommitDate: 2023-05-28 00:05:39 +0000 Reduce ifdef soup by adding pre-3.0 compat support This change creates a static inline function, BN_check_prime, for pre-3.0 use which is implemented with the previous (1.1) compatible call under the covers, `BN_is_prime_ex`. The `nchecks` parameter value is maintained, even though it has no noticable behavior change, given that the documentation clearly states that at least 64 or 128 rounds are executed on the backend, depending on how many bits there are in the given number being factored out. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D40305 --- usr.bin/factor/factor.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/usr.bin/factor/factor.c b/usr.bin/factor/factor.c index a3b0a65b5eca..7fc31353e5fa 100644 --- a/usr.bin/factor/factor.c +++ b/usr.bin/factor/factor.c @@ -82,7 +82,15 @@ __FBSDID("$FreeBSD$"); #include -#define PRIME_CHECKS 5 +#if OPENSSL_VERSION_NUMBER < 0x30000000L +static inline int +BN_check_prime(BN *p, BN_CTX *ctx, BN_GENCB *cb) +{ + const int nchecks = 5; + + return BN_is_prime_ex(val, nchecks, ctx, cb); +} +#endif static void pollard_pminus1(BIGNUM *); /* print factors for big numbers */ @@ -209,11 +217,7 @@ pr_fact(BIGNUM *val) if (!BN_sqr(bnfact, bnfact, ctx)) errx(1, "error in BN_sqr()"); if (BN_cmp(bnfact, val) > 0 || -#if OPENSSL_VERSION_NUMBER >= 0x30000000L BN_check_prime(val, NULL, NULL) == 1) -#else - BN_is_prime_ex(val, PRIME_CHECKS, NULL, NULL) == 1) -#endif pr_print(val); else pollard_pminus1(val); @@ -286,11 +290,7 @@ newbase: errx(1, "error in BN_gcd()"); if (!BN_is_one(x)) { -#if OPENSSL_VERSION_NUMBER >= 0x30000000L if (BN_check_prime(x, NULL, NULL) == 1) -#else - if (BN_is_prime_ex(x, PRIME_CHECKS, NULL, NULL) == 1) -#endif pr_print(x); else pollard_pminus1(x); @@ -299,13 +299,7 @@ newbase: BN_div(num, NULL, val, x, ctx); if (BN_is_one(num)) return; -#if OPENSSL_VERSION_NUMBER >= 0x30000000L - if (BN_check_prime(num, NULL, NULL) == 1) -#else - if (BN_is_prime_ex(num, PRIME_CHECKS, NULL, NULL) - == 1) -#endif - { + if (BN_check_prime(num, NULL, NULL) == 1) { pr_print(num); fflush(stdout); return;