From nobody Sat May 27 18:11:55 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 4QT8y351H4z4V6sb; Sat, 27 May 2023 18:11:55 +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 4QT8y3423Rz43q6; Sat, 27 May 2023 18:11:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685211115; 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=FpdrMlL+xTU3vr4CM3IE+yna9/LxP/92LtfTr+vPcCg=; b=d28/PlNQqW/GhPN0EP9MuzhYzjAtq8wMbuZYyX4z/m3SjslfN1M4pF+I+tOlDV9+hxxpNG wT1oIu6dVJzTFW1yUbW/4pN0l22KLeur8DXvOVmZUknjyunK/+2uvMx10v4QV91/DBoFqi ua6BmHHgtUdNmAt7oz9jNff5pBVIMJLvjKtk3JuYiBpsjD8gC/uH5lqSPEFU7A/fq2J2jI +YVaiocLL4YdQ8PYn2vYj3T0xv4SRCZlsvsyLSRyI+PY5kQVvoUC4A2hTscaDi3CRHgBSt eiFxmhNb+xNNA2srJfgls7dypEDePoYZ+Snwz+S2SRpBwX1q+38xnEixIgwTAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685211115; 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=FpdrMlL+xTU3vr4CM3IE+yna9/LxP/92LtfTr+vPcCg=; b=xQCJF0nRXfr03ue/cumPNRj3eVH1dkQJmdb06kLiCQpFLQkIJhCRoc3V7tGeOl3MhekT3D mqfAd4KmKggQtpIqYupZ9ZEcZKA0nEY99vgMsaI+P3byIszXuoj6JdhYjfjyaUm7u8SAcN TaaUa40RUULHEx1o8q2psCA5pBJoFccAbvQLC0Z7MRRm0RrRiXaaGceRQts6KBPUpu1Avd rF0KIR5N7U7/7rzZ9gYJ08X8DWtnABxJyVLNfdBhyQeqwZUDxDW4K7bJWU+3d0gcg3N9dr WKdxoChynD04LbByTzgCb5w6kaZwjgMZ10CBib3PX4qXczWAqSrIDr5hHZpfcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685211115; a=rsa-sha256; cv=none; b=F96uHUjoniFBisRk2wNxHtegUb/gVRdfd94gGTjTH2Fo2KU/VbCDFSTZWjI40CxaTuxGks RS11or37M09DkKCDXldyjCJmhOyvJ4VtdmmERM32lb+tdgSoTXy5DRSd8f4KvoBJv9YN6x 7GpsB4XtCszO93QTye7zNNVUsGIrT3Bg3jWatJQpiQmcNNA9SOqUB5c+nYv+72YfqdddOU u+wfKttTFGXc0wUD/kXhVhh/EyZJabBhXwfRvESPRlR82U0rbYG8QsRqNM2nO0cmhqDmfT Alhig7U76RdSUslvvIw/I7uP7qFjOtFGASojxmH/NiHDsAFGH6Frrd0eDPXN7g== 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 4QT8y335KdzyjP; Sat, 27 May 2023 18:11:55 +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 34RIBtiT093539; Sat, 27 May 2023 18:11:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34RIBtHY093538; Sat, 27 May 2023 18:11:55 GMT (envelope-from git) Date: Sat, 27 May 2023 18:11:55 GMT Message-Id: <202305271811.34RIBtHY093538@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: 537cd766435c - main - factor: support OpenSSL 3 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: 537cd766435c80e61e72bb9369f77aa9630a1537 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=537cd766435c80e61e72bb9369f77aa9630a1537 commit 537cd766435c80e61e72bb9369f77aa9630a1537 Author: Enji Cooper AuthorDate: 2023-05-27 04:55:12 +0000 Commit: Enji Cooper CommitDate: 2023-05-27 18:11:44 +0000 factor: support OpenSSL 3 This change ports the BN APIs to an OpenSSL 3 compatible set of APIs. This removes the need for requesting OpenSSL 1.1 compatible APIs. MFC after: 1 week Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D40298 --- usr.bin/factor/Makefile | 1 - usr.bin/factor/factor.c | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/usr.bin/factor/Makefile b/usr.bin/factor/Makefile index 255160ef6e00..ffa9ec7de1f8 100644 --- a/usr.bin/factor/Makefile +++ b/usr.bin/factor/Makefile @@ -9,7 +9,6 @@ CFLAGS+=-I${SRCTOP}/usr.bin/primes .if ${MK_OPENSSL} != "no" CFLAGS+=-DHAVE_OPENSSL -CFLAGS+=-DOPENSSL_API_COMPAT=0x10100000L LIBADD+=crypto .endif diff --git a/usr.bin/factor/factor.c b/usr.bin/factor/factor.c index 4edc2ed2a72c..a3b0a65b5eca 100644 --- a/usr.bin/factor/factor.c +++ b/usr.bin/factor/factor.c @@ -209,7 +209,11 @@ 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); @@ -282,7 +286,11 @@ 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); @@ -291,8 +299,13 @@ newbase: BN_div(num, NULL, val, x, ctx); if (BN_is_one(num)) return; - if (BN_is_prime_ex(num, PRIME_CHECKS, NULL, - NULL) == 1) { +#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 + { pr_print(num); fflush(stdout); return;