|
| 1 | +name: HSM |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'hsm/**' |
| 7 | + - '.github/workflows/hsm.yml' |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened, ready_for_review] |
| 10 | + paths: |
| 11 | + - 'hsm/**' |
| 12 | + - '.github/workflows/hsm.yml' |
| 13 | + workflow_call: |
| 14 | + inputs: |
| 15 | + caller_run_id: |
| 16 | + description: 'run id of the calling workflow; keeps a called run in its own concurrency group' |
| 17 | + type: string |
| 18 | + default: '' |
| 19 | + workflow_dispatch: |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: ${{ inputs.caller_run_id && format('hsm-call-{0}', inputs.caller_run_id) || format('hsm-{0}', github.ref) }} |
| 23 | + cancel-in-progress: ${{ !inputs.caller_run_id }} |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + |
| 28 | +jobs: |
| 29 | + hsm: |
| 30 | + # wolfHSM tracks wolfSSL master, so make download_repos clones and builds both |
| 31 | + # at master; a stable-tag matrix would not build. Hence master-only. |
| 32 | + name: Run / hsm dtls_client (wolfHSM ECC over DTLS) wolfSSL master |
| 33 | + runs-on: ubuntu-24.04 |
| 34 | + timeout-minutes: 30 |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v5 |
| 37 | + - uses: ./.github/actions/apt-update |
| 38 | + - name: Install build deps |
| 39 | + run: sudo apt-get install -y --no-install-recommends autoconf automake libtool |
| 40 | + |
| 41 | + # download_repos clones wolfSSL + wolfHSM; make all builds the wolfSSL DTLS |
| 42 | + # server/client, the wolfHSM posix server, and this repo's DTLS client. |
| 43 | + - name: Clone wolfSSL + wolfHSM and build the stack |
| 44 | + working-directory: hsm/dtls_client |
| 45 | + run: | |
| 46 | + set -euo pipefail |
| 47 | + bash "$GITHUB_WORKSPACE/.github/scripts/retry.sh" make download_repos |
| 48 | + make all |
| 49 | +
|
| 50 | + # A successful DTLS handshake proves the client drove its ECC signing through |
| 51 | + # the HSM: wolfHSM server on TCP 23456, wolfSSL DTLS server on UDP 11111. |
| 52 | + - name: Run the wolfHSM-backed DTLS handshake |
| 53 | + working-directory: hsm/dtls_client |
| 54 | + run: | |
| 55 | + set -uo pipefail |
| 56 | + make run_hsm_server > hsm.log 2>&1 & |
| 57 | + make run_dtls_server > dtls.log 2>&1 & |
| 58 | + for _ in $(seq 1 150); do ss -tln 2>/dev/null | grep -q ':23456 ' && break; sleep 0.2; done |
| 59 | + for _ in $(seq 1 150); do ss -uln 2>/dev/null | grep -q ':11111 ' && break; sleep 0.2; done |
| 60 | + ss -tln | grep -q ':23456 ' \ |
| 61 | + || { echo "FAIL: wolfHSM server never listened on 23456"; cat hsm.log; exit 1; } |
| 62 | + ss -uln | grep -q ':11111 ' \ |
| 63 | + || { echo "FAIL: DTLS server never listened on 11111"; cat dtls.log; exit 1; } |
| 64 | + rc=0 |
| 65 | + make run_client > client.log 2>&1 || rc=$? |
| 66 | + echo "--- client:"; cat client.log |
| 67 | + pkill -f wh_posix_server 2>/dev/null || true |
| 68 | + pkill -f 'examples/server/server' 2>/dev/null || true |
| 69 | + [ "$rc" -eq 0 ] \ |
| 70 | + || { echo "FAIL: client rc=$rc"; echo '--- hsm:'; cat hsm.log; echo '--- dtls:'; cat dtls.log; exit 1; } |
| 71 | + grep -q 'DTLS handshake successful' client.log \ |
| 72 | + || { echo "FAIL: no successful HSM-backed DTLS handshake"; exit 1; } |
| 73 | + echo "verified: wolfHSM-backed DTLS handshake (ECC signing on the HSM)" |
0 commit comments