Skip to content

Fixes for OpenBSD#585

Merged
stefanberger merged 5 commits into
stefanberger:masterfrom
moritzbuhl:patch-1
Jun 8, 2026
Merged

Fixes for OpenBSD#585
stefanberger merged 5 commits into
stefanberger:masterfrom
moritzbuhl:patch-1

Conversation

@moritzbuhl

@moritzbuhl moritzbuhl commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

To build this library on OpenBSD, I did:

export AUTOCONF_VERSION=2.69
export AUTOMAKE_VERSION=1.11
./autogen.sh
make
make check

A ports Makefile could look like this:

COMMENT =       emulation library for Trusted Platform Module TPM 1.2 or 2.0

GH_ACCOUNT =    stefanberger
GH_PROJECT =    libtpms
GH_TAGNAME =    v0.10.2
DISTNAME =      libtpms-${GH_TAGNAME:S/v//}

SHARED_LIBS +=  tpms                    0.0 # 10.2

CATEGORIES =    devel security

MAINTAINER =            Moritz Buhl <mbuhl@openbsd.org>

# BSD 3-Clause (TPM1.2/lib), BSD 2-Clause (TPM2 ref), TCG license (other TPM2)
PERMIT_PACKAGE =        Yes

SEPARATE_BUILD =        Yes
AUTOCONF_VERSION =      2.69
AUTOMAKE_VERSION =      1.11
AUTORECONF =            ./autogen.sh
CONFIGURE_STYLE =       autoreconf

WANTLIB +=      crypto

TEST_DEPENDS =  shells/bash

.include <bsd.port.mk>

I'll send it to ports@ once I have a working swtpm.
Currently libtpms is linking against the libcrypto in base, I tried creating a OpenSSL flavor without success.

Summary by CodeRabbit

  • Chores
    • Made manpage generation produce more consistent, reproducible output names.
    • Simplified the local check/build target so shell and platform flags are resolved more reliably at runtime.
    • Expanded crypto compatibility to better support a wider range of OpenSSL and LibreSSL versions.
    • Clarified POSIX 32/64-bit integer-width selection to avoid ambiguous configuration.

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 142c6c85-ccee-4e28-b547-2059c7768682

📥 Commits

Reviewing files that changed from the base of the PR and between 27951b4 and 58a63d8.

📒 Files selected for processing (5)
  • man/man3/Makefile.am
  • src/Makefile.am
  • src/tpm12/tpm_crypto.c
  • src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c
  • src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h
💤 Files with no reviewable changes (1)
  • src/Makefile.am
✅ Files skipped from review due to trivial changes (1)
  • man/man3/Makefile.am
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c
  • src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h
  • src/tpm12/tpm_crypto.c

📝 Walkthrough

Walkthrough

Refines OpenSSL/LibreSSL compile-time guards, explicitly sets 64-bit RADIX_BITS for POSIX builds, and updates manpage and check-local Makefile rules (suffix-based man rule, input-stem naming; removed per-target SHELL assignment).

Changes

Cross-platform OpenSSL, Radix, and Build Updates

Layer / File(s) Summary
OpenSSL version-based API selection
src/tpm12/tpm_crypto.c, src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c
OPENSSL_OLD_API is enabled via OpenSSL-version check (OPENSSL_VERSION_NUMBER < 0x10100000) instead of an OpenBSD-specific branch; EC point branch selection also treats LibreSSL (≥ 0x4010000fL) as equivalent to OpenSSL ≥ 3.0.
Radix bits compile-time configuration
src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h
Within #ifdef TPM_POSIX, RADIX_BITS is set to 64 when SIXTY_FOUR_BIT_LONG or SIXTY_FOUR_BIT is defined; the previous #ifndef RADIX_BITS / #error Need to determine RADIX_BITS value guard was removed.
Build system rule updates
man/man3/Makefile.am, src/Makefile.am
Manpage generation switches to suffix rule (.pod.3:) with SUFFIXES: .pod .3 and uses the input stem for pod2man -n; check-local target no longer uses a per-target SHELL?= assignment and the openbsd*) ADDLIBS branch was removed from the host_os case.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through headers and make,
Matching openssl versions for the sake,
Sixty-four bits now take their place,
Manpages rename with tidy grace,
I nibble a patch and leave a trace. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fixes for OpenBSD' is vague and does not clearly convey the specific changes made. While the PR does contain OpenBSD-related fixes, the title lacks descriptive detail about what was actually fixed. Consider using a more specific title that describes the main changes, such as 'Update OpenSSL compatibility checks and build system for OpenBSD support' or similar descriptive phrasing.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c

src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c:26:10: fatal error: 'BnOssl.h' file not found
26 | #include "BnOssl.h"
| ^~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/58a63d8f44b7dceb0408696d8694919d7b56444d-a78a06e0615b76dc/tmp/clang_command_.tmp.b08277.txt
++Contents of '/tmp/coderabbit-infer/58a63d8f44b7dceb0408696d8694919d7b56444d-a78a06e0615b76dc/tmp/clang_command_.tmp.b08277.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-di

... [truncated 748 characters] ...

nfer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/a78a06e0615b76dc/file.o" "-x" "c"
"src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c" "-O0" "-fno-builtin"
"-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"

src/tpm12/tpm_crypto.c

In file included from src/tpm12/tpm_crypto.c:54:
In file included from src/tpm12/tpm_cryptoh.h:43:
In file included from src/tpm12/tpm_global.h:43:
src/tpm12/tpm_nvram_const.h:92:2: error: "TPM_MAX_NV_SPACE is not defined"
92 | #error "TPM_MAX_NV_SPACE is not defined"
| ^
src/tpm12/tpm_nvram_const.h:117:2: error: "TPM_MAX_SAVESTATE_SPACE is not defined"
117 | #error "TPM_MAX_SAVESTATE_SPACE is not defined"
| ^
src/tpm12/tpm_nvram_const.h:135:2: error: "TPM_MAX_VOLATILESTATE_SPACE is not defined"
135 | #error "TPM_MAX_VOLATILESTATE_SPACE is not defined"
| ^
In file included from src/tpm12/tpm_crypto.c:54:
In file included from src/tpm12/tpm_cryptoh.h:43:
src/tpm12/tpm_global.h:44:10: fatal error: 'tpm_types.h' file not found
44 | #include "tpm_types.h"
| ^~~~~~~~~~~~~
4 errors generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18

... [truncated 1386 characters] ...

/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/1564c1ee181f646a/file.o" "-x" "c"
"src/tpm12/tpm_crypto.c" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
man/man3/Makefile.am (1)

65-89: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove the old pattern rule to avoid conflicting implicit conversions.

%.3 : %.pod is still present while .pod.3: is newly added. Keeping both conversion rules is redundant and can cause the old rule to be selected, defeating the intended suffix-rule switch for BSD-oriented compatibility.

Proposed cleanup
-%.3 : %.pod
-	`@if` test -n "$$SOURCE_DATE_EPOCH"; then \
-		BUILD_DATE=$$(date +%F --utc --date="@$$SOURCE_DATE_EPOCH"); \
-	else \
-		BUILD_DATE=$$(date +%F); \
-	fi; \
-	pod2man -r "libtpms" \
-		-c "" \
-		-n $(basename $@) \
-		--date="$$BUILD_DATE" \
-		--section=3 $< > $@
-
 SUFFIXES: .pod .3
 .pod.3:
 	`@if` test -n "$$SOURCE_DATE_EPOCH"; then \
 		BUILD_DATE=$$(date +%F --utc --date="@$$SOURCE_DATE_EPOCH"); \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@man/man3/Makefile.am` around lines 65 - 89, Remove the old pattern rule "%.3
: %.pod" which conflicts with the new suffix-style rule ".pod.3:"; keep only the
suffix rule ".pod.3:" (and its BUILD_DATE/pod2man invocation) so implicit
conversions use the intended BSD-compatible suffix rule and avoid
redundant/ambiguous implicit pattern matches.
🧹 Nitpick comments (1)
src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c (1)

580-601: 💤 Low value

Consider adding a clarifying comment for LibreSSL routing.

The change correctly routes LibreSSL to the OpenSSL 3.0+ code path because LibreSSL lacks the EC_POINTs_mul() function. While the code is correct, a brief comment would help future maintainers understand why LibreSSL takes this path despite having a lower version number.

📝 Optional comment addition
     else
     {
-#if OPENSSL_VERSION_NUMBER >= 0x30000000L || defined(LIBRESSL_VERSION_NUMBER)
+#if OPENSSL_VERSION_NUMBER >= 0x30000000L || defined(LIBRESSL_VERSION_NUMBER)
+        // LibreSSL never implemented EC_POINTs_mul, use alternative path
          EC_POINT *pR1 = EC_POINT_new(E->G);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c` around lines 580 - 601,
Add a short clarifying comment above the preprocessor branch that explains why
LibreSSL is routed to the OpenSSL 3.0+ code path: LibreSSL does not provide
EC_POINTs_mul(), so we must use the EC_POINT_mul/EC_POINT_add sequence
(functions EC_POINT_mul, EC_POINT_add, EC_POINTs_mul are relevant) even though
LIBRESSL_VERSION_NUMBER may be numerically lower; place the comment near the `#if`
OPENSSL_VERSION_NUMBER >= 0x30000000L || defined(LIBRESSL_VERSION_NUMBER) line
to make intent clear for future maintainers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@man/man3/Makefile.am`:
- Around line 65-89: Remove the old pattern rule "%.3 : %.pod" which conflicts
with the new suffix-style rule ".pod.3:"; keep only the suffix rule ".pod.3:"
(and its BUILD_DATE/pod2man invocation) so implicit conversions use the intended
BSD-compatible suffix rule and avoid redundant/ambiguous implicit pattern
matches.

---

Nitpick comments:
In `@src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c`:
- Around line 580-601: Add a short clarifying comment above the preprocessor
branch that explains why LibreSSL is routed to the OpenSSL 3.0+ code path:
LibreSSL does not provide EC_POINTs_mul(), so we must use the
EC_POINT_mul/EC_POINT_add sequence (functions EC_POINT_mul, EC_POINT_add,
EC_POINTs_mul are relevant) even though LIBRESSL_VERSION_NUMBER may be
numerically lower; place the comment near the `#if` OPENSSL_VERSION_NUMBER >=
0x30000000L || defined(LIBRESSL_VERSION_NUMBER) line to make intent clear for
future maintainers.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4ac4d90-7de6-474b-b57a-231b31968200

📥 Commits

Reviewing files that changed from the base of the PR and between 521c510 and db0da0b.

📒 Files selected for processing (5)
  • man/man3/Makefile.am
  • src/Makefile.am
  • src/tpm12/tpm_crypto.c
  • src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c
  • src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h
💤 Files with no reviewable changes (2)
  • src/Makefile.am
  • src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h

@stefanberger

Copy link
Copy Markdown
Owner

Can you prefix the patch titles with tpm12: for a tpm1.2 patch, build-sys for Makefiles, and tpm2: for a TPM 2 related patch.

My general concern with LibreSSL support is related to PQC supprt. I have lots of outstanding patches for support of PQC support (ML-DSA, ML-KEM) with OpenSSL libcrypto but I am not sure how or whether LibreSSL implements PQC and if it does it hopefully introduced the same API. Otherwise the LibreSSL support may be short-lived.

Comment thread man/man3/Makefile.am
Comment thread src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c Outdated
# endif
# ifndef RADIX_BITS
# error Need to determine RADIX_BITS value
# endif

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this rule otherwise break your build?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  CC     tpm2/libtpms_tpm2_la-ACTCommands.lo
In file included from tpm2/ACTCommands.c:62:
In file included from ./tpm2/TPMCmd/tpm/include/private/Tpm.h:8:
In file included from ./tpm2/TPMCmd/tpm/include/tpm_public/tpm_public.h:13:
./tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h:16:4: error: Need to determine RADIX_BITS value
   16 | #  error Need to determine RADIX_BITS value
      |    ^
1 error generated.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How and/or where does it determine the value for RADIX_BITS then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines below the change in tpm_radix.h

Comment thread src/Makefile.am
LDFLAGS_ARCH += $(findstring -m32, $(AM_LDFLAGS))
LDFLAGS_ARCH += $(findstring -m64, $(AM_LDFLAGS))

check-local: SHELL?="/usr/bin/env bash"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I had added this originally because of the case statement below that may not work with other shells. What is the issue on OpenBSD?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current$ make check
Making check in include
Making check in libtpms
Making check in man
Making check in man3
Making check in src
make  check-local
make: don't know how to make bash" (prerequisite of: check-local)
Stop in src
*** Error 2 in src (Makefile:4537 'check-am')
*** Error 1 in /home/mbuhl/projects/libtpms (Makefile:472 'check-recursive': @fail= failcom='exit 1';  for f in x $MAKEFLAGS; do  case $f in...)

To my understanding the current way it adds "/usr/bin/env" and "bash" as prerequisites and then it fails because there is no "bash" target or file in the current directory.
Maybe check-local: SHELL?="$(/usr/bin/env bash)"?
This works for my make check and gmake check but I don't know if is right.

@stefanberger stefanberger Jun 1, 2026

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had switched to tcsh locally for a test and did not notice a failure on make check. Adding set; to the target showed all kinds of BASH variables, so it must have switched to bash automatically (after removing SHELL?= as you did), though I am not sure whether it would do this on all systems.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does SHELL?='/usr/bin/env bash' with single quotes work for you? CoderabbitAI seems to suggest this. It works for me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the SHELL?=... syntax is GNU make only.

To my understanding, the case statement is POSIX compatible: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_09_04_05
And I can confirm that it works with my ksh (both gmake and make).
The target currently evaluates to:

case openbsd7.9 in \
  openbsd*) ADDLIBS="-lc" ;; \
  darwin*|freebsd*) LDFLAGS_OS="-shared" ;; \
  *) ADDLIBS="" ;; \
esac; \
 (cc $LDFLAGS_OS     -nostdlib -L./.libs -ltpms $ADDLIBS 2>/dev/null || \
 (echo "There are undefined symbols in libtpms ($LDFLAGS_OS    )";\
  cc $LDFLAGS_OS     -nostdlib -L./.libs -ltpms $ADDLIBS 2>&1 | grep libtpms))
case openbsd7.9 in \
  openbsd*) ADDLIBS="-lc" ;; \
  darwin*|freebsd*) LDFLAGS_OS="-shared" ;; \
  *) ADDLIBS="" ;; \
esac; \
cc $LDFLAGS_OS     -nostdlib -L./.libs -ltpms $ADDLIBS 2>/dev/null

so cc -nostdlib -L./.libs -ltpms -lc for me. I can leave the ADDLIBS out and get the same result:

current$ cc -nostdlib -L./.libs -ltpms -lc
ld: warning: cannot find entry symbol _start; not setting start address
current$ cc -nostdlib -L./.libs -ltpms
ld: warning: cannot find entry symbol _start; not setting start address

Maybe we can wrap the whole target in bash -c?

check-local:
           /usr/bin/env bash -c ' \
           ...
           '

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then let's remove the SHELL?= for now. And you can also remove the openbsd*) case if you don't need it, of course.
I used the case statement for wildcard matching because on FreeBSD host_os is freebsd15.0 for example, so we cannot easily replace it with an if statement.

Comment thread src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/Makefile.am (1)

711-711: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Verify $() expansion semantics across Make implementations.

In GNU Make, $(/usr/bin/env bash) is variable/function expansion syntax—not shell command substitution. Since no Make variable named /usr/bin/env bash exists, this would expand to an empty string, effectively setting SHELL="". This could cause recipe failures.

The intent is to avoid OpenBSD's make parsing the original value as prerequisites. A more portable approach may be to avoid embedded spaces or use different quoting.

#!/bin/bash
# Test how GNU Make interprets the $() expansion in this context

# Create a minimal test Makefile
cat > /tmp/test_makefile <<'EOF'
test-target: SHELL?="$(/usr/bin/env bash)"
test-target:
	`@echo` "SHELL is: [$(SHELL)]"
EOF

echo "=== Testing with GNU make ==="
make -f /tmp/test_makefile test-target

rm /tmp/test_makefile

,

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Makefile.am` at line 711, The Makefile sets SHELL using GNU-make-style
expansion in the check-local target (SHELL?="$(/usr/bin/env bash)") which is
nonportable and can evaluate to empty; replace that assignment with a portable
explicit shell assignment (e.g., change the check-local target to set SHELL ?=
/bin/bash) or otherwise avoid embedded spaces by assigning a single-token path
to SHELL; update the check-local target where SHELL?="$(/usr/bin/env bash)"
appears to use SHELL ?= /bin/bash (or another explicit single-path shell) to
ensure consistent behavior across make implementations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/Makefile.am`:
- Line 711: The Makefile sets SHELL using GNU-make-style expansion in the
check-local target (SHELL?="$(/usr/bin/env bash)") which is nonportable and can
evaluate to empty; replace that assignment with a portable explicit shell
assignment (e.g., change the check-local target to set SHELL ?= /bin/bash) or
otherwise avoid embedded spaces by assigning a single-token path to SHELL;
update the check-local target where SHELL?="$(/usr/bin/env bash)" appears to use
SHELL ?= /bin/bash (or another explicit single-path shell) to ensure consistent
behavior across make implementations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 79fa7718-cef4-45e4-bc5e-af59595b6437

📥 Commits

Reviewing files that changed from the base of the PR and between db0da0b and 4360fb6.

📒 Files selected for processing (5)
  • man/man3/Makefile.am
  • src/Makefile.am
  • src/tpm12/tpm_crypto.c
  • src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c
  • src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h
💤 Files with no reviewable changes (1)
  • src/tpm2/TPMCmd/tpm/include/tpm_public/tpm_radix.h
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/tpm2/TPMCmd/tpm/cryptolibs/Ossl/BnToOsslMath.c
  • man/man3/Makefile.am
  • src/tpm12/tpm_crypto.c

@stefanberger

stefanberger commented Jun 1, 2026

Copy link
Copy Markdown
Owner

I am occasionally building in a DragonflyBSD VM. There I recently saw that LibreSSL's openssl command line tool does not support the same options (openssl req -CA / -CAfile; needed in swtpm) as the version from OpenSSL does. I didn't end up trying to make it work there since the PQC support is the much bigger hurdle...

@moritzbuhl

Copy link
Copy Markdown
Contributor Author

My general concern with LibreSSL support is related to PQC supprt. I have lots of outstanding patches for support of PQC support (ML-DSA, ML-KEM) with OpenSSL libcrypto but I am not sure how or whether LibreSSL implements PQC and if it does it hopefully introduced the same API. Otherwise the LibreSSL support may be short-lived.

ML-KEM is available, ML-DSA not yet. I am confident that I can work around any ML-API incompatibilities once they arise.

@moritzbuhl

Copy link
Copy Markdown
Contributor Author

I am occasionally building in a DragonflyBSD VM. There I recently saw that LibreSSL's openssl command line tool does not support the same options (openssl req -CA / -CAfile; needed in swtpm) as the version from OpenSSL does. I didn't end up trying to make it work there since the PQC support is the much bigger hurdle...

Regarding -CA and -CAfile, is it the following three locations?

@stefanberger

Copy link
Copy Markdown
Owner

I am occasionally building in a DragonflyBSD VM. There I recently saw that LibreSSL's openssl command line tool does not support the same options (openssl req -CA / -CAfile; needed in swtpm) as the version from OpenSSL does. I didn't end up trying to make it work there since the PQC support is the much bigger hurdle...

Regarding -CA and -CAfile, is it the following three locations?

* `swtpm_localca.c`:
  https://github.com/stefanberger/swtpm/blob/4a748877d7540e35656dbb918ab3eb18cf866b9a/src/swtpm_localca/swtpm_localca.c#L178-L179

* `test_tpm2_swtpm_localca_pkcs11.test`:
  https://github.com/stefanberger/swtpm/blob/4a748877d7540e35656dbb918ab3eb18cf866b9a/tests/test_tpm2_swtpm_localca_pkcs11.test#L95

* `swtpm-create-tpmca`:
  https://github.com/stefanberger/swtpm/blob/4a748877d7540e35656dbb918ab3eb18cf866b9a/samples/swtpm-create-tpmca#L225-L226

Yes, these links look correct to me. At least some of the errors I saw when running swtpm test cases were related to these missing options...

@stefanberger

Copy link
Copy Markdown
Owner

Please rebase on latest master. I moved swtpm to depend on OpenSSL 3.5 due to PQC and EdDSA dependencies...

Signed-off-by: Moritz Buhl <mbuhl@openbsd.org>
Signed-off-by: Moritz Buhl <mbuhl@openbsd.org>
Signed-off-by: Moritz Buhl <mbuhl@openbsd.org>
Signed-off-by: Moritz Buhl <mbuhl@openbsd.org>
Signed-off-by: Moritz Buhl <mbuhl@openbsd.org>
@stefanberger

Copy link
Copy Markdown
Owner

Looks good now. I will merge it shortly.

@stefanberger stefanberger merged commit e7a4061 into stefanberger:master Jun 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants