Commit ecd8514e7f for openssl.org

commit ecd8514e7ff9521bfe2bc6d19d59d192daff1833
Author: Daiki Ueno <dueno@redhat.com>
Date:   Fri Aug 21 13:02:29 2026 +0900

    test: add external test for crypto-auditing

    This adds an external test which compiles crypto-auditing from the git
    submodule, exercise a handshake with s_server/s_client, and check that
    expected events are captured.

    Signed-off-by: Daiki Ueno <dueno@redhat.com>

    Reviewed-by: Mounir Idrassi <mounir.idrassi@idrix.fr>
    Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
    MergeDate: Sat Nov 21 14:48:35 2026
    (Merged from https://github.com/openssl/openssl/pull/32538)

diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml
index 80efe22f1a..fb3c95d7a0 100644
--- a/.github/workflows/ci-nightly.yml
+++ b/.github/workflows/ci-nightly.yml
@@ -225,3 +225,40 @@ jobs:
       run: ./config ${{ matrix.platform.arch }}  --strict-warnings --banner=Configured ${{ matrix.platform.config }}
     - name: make
       run: make -j4 -s
+
+  external-tests-crypto-auditing:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v6
+      with:
+        persist-credentials: false
+    - name: checkout crypto-auditing submodule
+      run: .github/retry git submodule update --init --depth 1 crypto-auditing
+    - name: package installs
+      run: |
+        .github/retry sh -c "sudo apt-get update &&
+          sudo apt-get -yq install systemtap-sdt-dev libbpf-dev libelf-dev zlib1g-dev \
+            clang libclang-dev gcc-multilib linux-tools-common linux-tools-$(uname -r)"
+    - name: generate vmlinux.h for the runner kernel
+      run: |
+        bpftool btf dump file /sys/kernel/btf/vmlinux format c > crypto-auditing/agent/src/bpf/vmlinux.h
+        cp crypto-auditing/agent/src/bpf/vmlinux.h crypto-auditing/agent/tests/agenttest/src/bpf/
+    - name: config
+      run: ./config --strict-warnings --banner=Configured --debug enable-external-tests no-fips && perl configdata.pm --dump
+    - name: make
+      run: make -s -j4
+    # Fetch crates separately so a compile error is not retried as an environment failure
+    - name: fetch crypto-auditing dependencies
+      working-directory: crypto-auditing
+      run: |
+        "$GITHUB_WORKSPACE"/.github/retry cargo fetch
+    - name: build crypto-auditing
+      working-directory: crypto-auditing
+      run: cargo build --offline --verbose
+    # crau-agent loads BPF programs, so the test runs as root with the runner's Rust toolchain
+    - name: test external crypto-auditing
+      run: sudo -E env "PATH=$PATH" "HOME=$HOME" make test TESTS="test_external_crypto_auditing" V=1
+    - name: get cpu info
+      run: |
+        cat /proc/cpuinfo
+        ./util/opensslwrap.sh version -c
diff --git a/.gitmodules b/.gitmodules
index b4c756a67b..f1605f3b14 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -35,3 +35,6 @@
 [submodule "pkcs11-provider"]
 	path = pkcs11-provider
 	url = https://github.com/latchset/pkcs11-provider.git
+[submodule "crypto-auditing"]
+	path = crypto-auditing
+	url = https://github.com/latchset/crypto-auditing.git
diff --git a/crypto-auditing b/crypto-auditing
new file mode 160000
index 0000000000..e9004d5636
--- /dev/null
+++ b/crypto-auditing
@@ -0,0 +1 @@
+Subproject commit e9004d563608b44bff8052cba0f7c76b5175570a
diff --git a/test/recipes/95-test_external_crypto_auditing.t b/test/recipes/95-test_external_crypto_auditing.t
new file mode 100644
index 0000000000..c7eb9b8678
--- /dev/null
+++ b/test/recipes/95-test_external_crypto_auditing.t
@@ -0,0 +1,26 @@
+#! /usr/bin/env perl
+# Copyright 2026 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+
+use OpenSSL::Test;
+use OpenSSL::Test::Utils;
+use OpenSSL::Test qw/:DEFAULT data_file bldtop_dir srctop_dir cmdstr/;
+
+setup("test_external_crypto_auditing");
+
+plan skip_all => "No external tests in this configuration"
+    if disabled("external-tests");
+plan skip_all => "crypto-auditing tests only available on Linux"
+    if $^O !~ /^linux$/;
+plan skip_all => "crypto-auditing tests not supported in out of tree builds"
+    if bldtop_dir() ne srctop_dir();
+
+plan tests => 1;
+
+ok(run(cmd(["sh", data_file("crypto-auditing.sh")])),
+   "running crypto-auditing tests");
diff --git a/test/recipes/95-test_external_crypto_auditing_data/crypto-auditing.sh b/test/recipes/95-test_external_crypto_auditing_data/crypto-auditing.sh
new file mode 100755
index 0000000000..4b774fea72
--- /dev/null
+++ b/test/recipes/95-test_external_crypto_auditing_data/crypto-auditing.sh
@@ -0,0 +1,104 @@
+#!/bin/sh
+#
+# Copyright 2026 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the Apache License 2.0 (the "License").  You may not use
+# this file except in compliance with the License.  You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+#
+# OpenSSL external testing using the pkcs11-provider
+#
+
+trap 'test -n "$agent_pids" && kill $agent_pids' EXIT
+
+if [ "$(id -u)" -ne 0 ]; then
+    echo "Need to be root to run this test!"
+    exit 1
+fi
+
+PWD="$(pwd)"
+
+SRCTOP="$(cd $SRCTOP; pwd)"
+BLDTOP="$(cd $BLDTOP; pwd)"
+
+if [ "$SRCTOP" != "$BLDTOP" ] ; then
+    echo "Out of tree builds not supported with crypto-auditing test!"
+    exit 1
+fi
+
+cd $BLDTOP
+
+O_EXE="$BLDTOP/apps"
+O_BINC="$BLDTOP/include"
+O_SINC="$SRCTOP/include"
+O_LIB="$BLDTOP"
+
+export PATH="$O_EXE:$PATH"
+export LD_LIBRARY_PATH="$O_LIB:$LD_LIBRARY_PATH"
+export OPENSSL_ROOT_DIR="$O_LIB"
+
+echo "------------------------------------------------------------------"
+echo "Building crypto-auditing"
+echo "------------------------------------------------------------------"
+
+cd $OPENSSL_ROOT_DIR/crypto-auditing
+
+cargo build --verbose
+
+cd -
+
+echo "------------------------------------------------------------------"
+echo "Running tests"
+echo "------------------------------------------------------------------"
+
+OPENSSL=$O_EXE/openssl
+CRAU_AGENT=$OPENSSL_ROOT_DIR/crypto-auditing/target/debug/crau-agent
+CRAU_QUERY=$OPENSSL_ROOT_DIR/crypto-auditing/target/debug/crau-query
+CRAU_CBOR_LOG=`mktemp`
+CRAU_JSON_LOG=`mktemp`
+
+rm -f "$CRAU_CBOR_LOG" "$CRAU_JSON_LOG"
+
+"$CRAU_AGENT" -c /dev/null \
+              --library "$O_LIB"/libssl.so.4 \
+              --library "$O_LIB"/libcrypto.so.4 \
+              --log-file "$CRAU_CBOR_LOG" &
+
+# wait until crau-agent starts
+timeout 2 sh -c "while true; do test -e \"""$CRAU_CBOR_LOG""\" && break; done"
+
+agent_pids=`ps -ef | grep crau-agent | grep -v grep | awk '{print $2}'`
+if [ -z "$agent_pids" ]
+then
+    echo "No sign of crau-agent - exiting (before client)"
+    exit 88
+fi
+
+"$O_EXE"/openssl s_server -tls1_3 -WWW -naccept 1 \
+        -cert test/certs/servercert.pem -key test/certs/serverkey.pem &
+
+server_pids=`ps -ef | grep s_server | grep -v grep | awk '{print $2}'`
+if [ -z "$server_pids" ]
+then
+    echo "No sign of s_server - exiting (before client)"
+    exit 88
+fi
+
+httpreq="GET / HTTP/1.1\\r\\nConnection: close\\r\\n\\r\\n"
+
+(echo -e "$httpreq"; sleep 2) | \
+    "$O_EXE"/openssl s_client -CAfile test/certs/rootcert.pem -connect localhost:4433
+
+
+"$CRAU_QUERY" --log-file "$CRAU_CBOR_LOG" | tee "$CRAU_JSON_LOG"
+
+# check if at least one TLS 1.3 handshake took place
+jq --exit-status '[.[] | .events | select(.name == "tls::handshake") | select(."tls::protocol_version" == 772)] | length > 0' "$CRAU_JSON_LOG"
+
+success=$?
+
+# crau-agent needs killing
+kill $agent_pids
+exit $success