Skip to content

Commit 5bec495

Browse files
authored
Add OQS OpenSSH, oqsprovider and liboqs formulas (#722)
* Add OQS OpenSSH and OpenSSL provider formulas * Add OQS packages to modular builds * Register OQS formulas in upstream version audit * Link Linux OQS OpenSSH with static OpenSSL dependencies * Namespace liboqs SHA-3 symbols for OpenSSL linking * ci: run OQS macOS packages on xcode-27 The optional liboqs, oqsprovider and openssh osx jobs never got macos-14 runners in the shared apple matrix. Move them to a dedicated workflow on the xcode-27 image used by desktop macOS builds, and package ordinary OQS archives from out/ when they are not staged as XCFrameworks. * ci: treat build-oqs as a modular latest-modular workflow Validate platform artifact reuse failed because test-workflow-scheduling.rb requires version-tag publishing on every build*.yml except linux-modular and modular-optional. OQS packages publish to latest-modular on bleeding/master like those workflows, so exempt build-oqs.yml and run the scheduling check from the OQS test job. * ci: build OQS macOS packages on hosted macos-15 The dedicated xcode-27 jobs never left the queue behind core Apple builds. Compile liboqs, oqsprovider and openssh in one GitHub-hosted osx job, package from out/, and smoke-test native OpenSSH plus staged cross-arch binaries. * ci: smoke-test native OQS OpenSSH only macos-15 compiled liboqs, oqsprovider and openssh and the arm64 OpenSSH checks passed. arch -x86_64 then failed because Homebrew bash is arm64. Execute the host architecture, confirm the staged x86_64 Mach-O, and save the compile cache before those checks. * Generate a private ofxOQS addon from OQS packages Build ofxOQS from the liboqs, oqsprovider and OpenSSH archives: universal osx libraries, addon_config.mk, and an OF example. Native smoke tests cover ML-KEM/ML-DSA and OpenSSH. CI uploads the addon and compiles the example against openFrameworks master.
1 parent 80b36a5 commit 5bec495

38 files changed

Lines changed: 1456 additions & 18 deletions

‎.github/workflows/build-oqs.yml‎

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: build-oqs
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
paths:
7+
- '.github/workflows/build-oqs.yml'
8+
- 'apothecary/formulas/liboqs/**'
9+
- 'apothecary/formulas/oqsprovider/**'
10+
- 'apothecary/formulas/openssh/**'
11+
- 'scripts/tests/oqs/**'
12+
- 'scripts/tests/test-package-platforms.sh'
13+
- 'scripts/build-modular-optional.sh'
14+
- 'scripts/package-individual.sh'
15+
- 'scripts/package-platform.sh'
16+
- 'scripts/calculate_formulas.sh'
17+
- 'scripts/modular-cache-key.sh'
18+
- 'scripts/cache-toolchain.sh'
19+
- 'scripts/secure.sh'
20+
- 'scripts/osx/install.sh'
21+
- 'scripts/apple-install-tools.sh'
22+
- 'scripts/check-apple-sdk.sh'
23+
- 'scripts/test-openframeworks-libraries.sh'
24+
push:
25+
branches: [bleeding, master]
26+
paths:
27+
- '.github/workflows/build-oqs.yml'
28+
- 'apothecary/formulas/liboqs/**'
29+
- 'apothecary/formulas/oqsprovider/**'
30+
- 'apothecary/formulas/openssh/**'
31+
- 'scripts/tests/oqs/**'
32+
- 'scripts/tests/test-package-platforms.sh'
33+
- 'scripts/build-modular-optional.sh'
34+
- 'scripts/package-individual.sh'
35+
- 'scripts/package-platform.sh'
36+
- 'scripts/calculate_formulas.sh'
37+
- 'scripts/modular-cache-key.sh'
38+
- 'scripts/cache-toolchain.sh'
39+
- 'scripts/secure.sh'
40+
- 'scripts/osx/install.sh'
41+
- 'scripts/apple-install-tools.sh'
42+
- 'scripts/check-apple-sdk.sh'
43+
- 'scripts/test-openframeworks-libraries.sh'
44+
45+
concurrency:
46+
group: ${{ github.workflow }}-${{ startsWith(github.ref, 'refs/tags/') && github.run_id || github.event.pull_request.number || github.ref }}
47+
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
48+
49+
permissions:
50+
contents: write
51+
52+
env:
53+
BUILD_PROFILE_ID: "2"
54+
55+
jobs:
56+
test:
57+
permissions:
58+
contents: read
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v7.0.1
62+
- run: bash -n apothecary/formulas/liboqs/liboqs.sh
63+
- run: bash -n apothecary/formulas/oqsprovider/oqsprovider.sh
64+
- run: bash -n apothecary/formulas/openssh/openssh.sh
65+
- run: bash -n scripts/package-individual.sh
66+
- run: bash -n scripts/build-modular-optional.sh
67+
- run: bash scripts/tests/test-package-platforms.sh
68+
- run: ruby scripts/tests/test-workflow-scheduling.rb
69+
- run: bash -n scripts/tests/oqs/generate-ofx-addon.sh
70+
- run: bash -n scripts/tests/oqs/test-ofx-addon.sh
71+
- run: bash -n scripts/tests/oqs/install-ofx-addon.sh
72+
73+
osx:
74+
needs: test
75+
name: optional oqs-osx
76+
runs-on: macos-15
77+
env:
78+
TARGET: osx
79+
TYPE: osx
80+
OPTIONAL_ARCHS: x86_64 arm64
81+
PACKAGE_LIBS: liboqs oqsprovider openssh
82+
ALWAYS_BUILD: 1
83+
NO_FORCE: 1
84+
steps:
85+
- uses: actions/checkout@v7.0.1
86+
- name: Install
87+
run: |
88+
./scripts/osx/install.sh
89+
echo "$(brew --prefix)/bin" >> "$GITHUB_PATH"
90+
- name: Ensure Ninja is available for the cache fingerprint
91+
run: command -v ninja >/dev/null || brew install ninja
92+
- name: Compute exact modular cache key
93+
id: key
94+
run: |
95+
digest=$(
96+
{
97+
bash scripts/modular-cache-key.sh liboqs
98+
bash scripts/modular-cache-key.sh oqsprovider
99+
bash scripts/modular-cache-key.sh openssh
100+
} | shasum -a 256 | awk '{print $1}'
101+
)
102+
printf 'key=modular-v1-osx-oqs-%s\n' "$digest" >> "$GITHUB_OUTPUT"
103+
- name: Restore compiled modular outputs
104+
id: cache
105+
uses: actions/cache/restore@v6.1.0
106+
with:
107+
key: ${{ steps.key.outputs.key }}
108+
path: |
109+
out/liboqs
110+
out/oqsprovider
111+
out/openssh
112+
- name: Report modular cache result
113+
env:
114+
CACHE_KEY: ${{ steps.key.outputs.key }}
115+
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
116+
run: |
117+
printf '### Modular cache: %s / %s\n\nKey: `%s`\n\nExact hit: `%s`\n' "$TARGET" "$PACKAGE_LIBS" "$CACHE_KEY" "${CACHE_HIT:-false}" >> "$GITHUB_STEP_SUMMARY"
118+
- name: Build or reuse and package modular libraries
119+
env:
120+
MODULAR_CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
121+
run: bash scripts/build-modular-optional.sh
122+
- name: Verify packaged archives
123+
run: |
124+
shopt -s nullglob
125+
for library in liboqs oqsprovider openssh; do
126+
packages=(out/oF_${library}_osx_*.tar.bz2)
127+
test "${#packages[@]}" -gt 0
128+
ls -lah "${packages[@]}"
129+
done
130+
- name: Save compiled modular outputs
131+
if: steps.cache.outputs.cache-hit != 'true'
132+
uses: actions/cache/save@v6.1.0
133+
with:
134+
key: ${{ steps.key.outputs.key }}
135+
path: |
136+
out/liboqs
137+
out/oqsprovider
138+
out/openssh
139+
- name: Run OpenSSH OQS smoke tests
140+
run: |
141+
host=$(uname -m)
142+
case "$host" in
143+
arm64|aarch64) native=MAC_ARM64; foreign=MAC; foreign_macho='x86_64' ;;
144+
x86_64) native=MAC; foreign=MAC_ARM64; foreign_macho='arm64' ;;
145+
*) echo "Unsupported host architecture: $host" >&2; exit 1 ;;
146+
esac
147+
bash scripts/tests/oqs/test-openssh.sh out osx "$native"
148+
native_bin=out/openssh/bin/osx/$native/ssh
149+
foreign_bin=out/openssh/bin/osx/$foreign/ssh
150+
test -x "$native_bin"
151+
test -x "$foreign_bin"
152+
file "$native_bin"
153+
file "$foreign_bin"
154+
file "$foreign_bin" | grep -F "$foreign_macho"
155+
156+
- name: Generate private ofxOQS addon from packages
157+
run: bash scripts/tests/oqs/generate-ofx-addon.sh out out/ofxOQS osx
158+
- name: Test ofxOQS addon layout and native smoke tests
159+
run: bash scripts/tests/oqs/test-ofx-addon.sh out/ofxOQS
160+
161+
- name: Upload validation package
162+
uses: actions/upload-artifact@v7.0.2
163+
with:
164+
name: oqs-osx
165+
path: |
166+
out/oF_liboqs_osx_*.tar.bz2
167+
out/oF_oqsprovider_osx_*.tar.bz2
168+
out/oF_openssh_osx_*.tar.bz2
169+
if-no-files-found: error
170+
- name: Upload private ofxOQS addon
171+
uses: actions/upload-artifact@v7.0.2
172+
with:
173+
name: ofxOQS-osx
174+
path: out/ofxOQS
175+
if-no-files-found: error
176+
- name: Upload Open Quantum Safe package to latest-modular
177+
if: github.event_name == 'push' && github.repository == 'openframeworks/apothecary'
178+
uses: danoli3/action-gh-release@ec40b04e78c39008f73c4ca3fdf9b51df604c4ed # temporary patch: softprops/action-gh-release#852
179+
with:
180+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
181+
tag_name: latest-modular
182+
fail_on_unmatched_files: true
183+
files: |
184+
out/oF_liboqs_osx_*.tar.bz2
185+
out/oF_oqsprovider_osx_*.tar.bz2
186+
out/oF_openssh_osx_*.tar.bz2
187+
188+
of-addon:
189+
needs: osx
190+
name: ofxOQS openFrameworks example
191+
runs-on: macos-15
192+
steps:
193+
- uses: actions/checkout@v7.0.1
194+
with:
195+
path: apothecary
196+
- uses: actions/checkout@v7.0.1
197+
with:
198+
repository: openframeworks/openFrameworks
199+
ref: master
200+
submodules: recursive
201+
path: openFrameworks
202+
- name: Download private ofxOQS addon
203+
uses: actions/download-artifact@v8
204+
with:
205+
name: ofxOQS-osx
206+
path: openFrameworks/addons/ofxOQS
207+
- name: Install openFrameworks osx libraries
208+
working-directory: openFrameworks
209+
run: scripts/osx/download_libs.sh -b
210+
- name: Build ofxOQS example
211+
working-directory: openFrameworks/addons/ofxOQS/example
212+
run: make -j4

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
!/.github/workflows/upstream-versions.yml
2323
!/.github/workflows/publish-checksums.yml
2424
!/.github/workflows/build-modular-optional.yml
25+
!/.github/workflows/build-oqs.yml
2526
!/apothecary/**/*
2627
!/scripts/**/*
2728
/apothecary/build
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/usr/bin/env bash
2+
# liboqs post-quantum algorithms. Opt-in; not part of the core archive.
3+
4+
FORMULA_TYPES=("osx" "linux")
5+
FORMULA_DEPENDS=()
6+
VER=0.16.0
7+
SHA256="162d5b510518ee5f285f82fa1f16402a885176e818bf1b1a4c3c91c9a2f01eae"
8+
BUILD_ID=2
9+
DEFINES=""
10+
URL="https://github.com/open-quantum-safe/liboqs/archive/refs/tags/${VER}.tar.gz"
11+
12+
GIT_URL="$URL"
13+
14+
function download() {
15+
. "$DOWNLOADER_SCRIPT"
16+
downloader "$URL" || return $?
17+
verify_sha256 "${VER}.tar.gz" "$SHA256" || return $?
18+
tar -xf "${VER}.tar.gz" || return $?
19+
mv "liboqs-${VER}" liboqs || return $?
20+
rm "${VER}.tar.gz"
21+
}
22+
23+
function prepare() {
24+
if ! grep -q OQS_SNTRUP761_crypto_int16_optblocker src/kem/ntruprime/CMakeLists.txt; then
25+
patch -p1 < "$FORMULA_DIR/sntrup-symbol-namespace.patch" || return $?
26+
fi
27+
if ! grep -q OQS_keccak_1600_init_state src/common/CMakeLists.txt; then
28+
patch -p1 < "$FORMULA_DIR/openssl-sha3-symbol-namespace.patch" || return $?
29+
fi
30+
}
31+
32+
function build() {
33+
local build_dir="$PWD/build_${TYPE}_${PLATFORM}"
34+
local platform_args=()
35+
case "$TYPE" in
36+
osx)
37+
platform_args=(
38+
-DCMAKE_TOOLCHAIN_FILE="$APOTHECARY_DIR/toolchains/ios.toolchain.cmake"
39+
-DPLATFORM="$PLATFORM" -DDEPLOYMENT_TARGET="$MIN_SDK_VER"
40+
-DENABLE_BITCODE=OFF -DENABLE_ARC=OFF
41+
) ;;
42+
linux)
43+
platform_args=(-DCMAKE_TOOLCHAIN_FILE="$APOTHECARY_DIR/toolchains/linux${PLATFORM}.toolchain.cmake") ;;
44+
*) echoError "Unsupported liboqs target: $TYPE"; return 1 ;;
45+
esac
46+
47+
# Install directly into the Apothecary layout. CMake generates exports with
48+
# the correct relative prefix depth, preserving upstream names and targets.
49+
cmake -S . -B "$build_dir" "${platform_args[@]}" \
50+
-DCMAKE_BUILD_TYPE=Release \
51+
-DCMAKE_INSTALL_PREFIX="$build_dir/Release" \
52+
-DCMAKE_INSTALL_LIBDIR="lib/$TYPE/$PLATFORM" \
53+
-DCMAKE_INSTALL_INCLUDEDIR=include \
54+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
55+
-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=ON \
56+
-DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF \
57+
-DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF \
58+
-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF \
59+
-DOQS_BUILD_ONLY_LIB=ON -DOQS_DIST_BUILD=ON \
60+
-DOQS_USE_OPENSSL=OFF -DOQS_LIBJADE_BUILD=OFF \
61+
-DOQS_USE_CUPQC=OFF -DOQS_USE_ICICLE=OFF || return $?
62+
cmake --build "$build_dir" --config Release -j"${PARALLEL_MAKE:-4}" --target install
63+
}
64+
65+
function copy() {
66+
local prefix="build_${TYPE}_${PLATFORM}/Release"
67+
local library metadata_name extension=a count=0
68+
[ "$TYPE" != vs ] || extension=lib
69+
mkdir -p "$1/include" "$1/lib/$TYPE/$PLATFORM" "$1/license"
70+
cp -R "$prefix/include/." "$1/include/" || return $?
71+
cp -R "$prefix/lib/$TYPE/$PLATFORM/." "$1/lib/$TYPE/$PLATFORM/" || return $?
72+
cp LICENSE.txt "$1/license/" || return $?
73+
74+
# Algorithm implementations carry additional notices in the source tree.
75+
cp -R docs/algorithms "$1/license/" || return $?
76+
cp README.md "$1/license/" || return $?
77+
local notice
78+
while IFS= read -r notice; do
79+
mkdir -p "$1/license/$(dirname "$notice")" || return $?
80+
cp "$notice" "$1/license/$notice" || return $?
81+
done < <(find src -type f \( -iname 'LICENSE*' -o -iname 'COPYING*' -o -iname 'NOTICE*' \))
82+
. "$SECURE_SCRIPT"
83+
for library in "$1/lib/$TYPE/$PLATFORM/"*."$extension"; do
84+
[ -f "$library" ] || continue
85+
count=$((count + 1))
86+
metadata_name=$(basename "$library")
87+
[ "$TYPE" = vs ] || metadata_name="${metadata_name#lib}"
88+
secure "$library" "$metadata_name" "$VER" "$DEFINES" "$BUILD_ID" "${FORMULA_DEPENDS[*]}" "$SHA256" || return $?
89+
done
90+
[ "$count" -gt 0 ] || { echoError "No installed liboqs archives for $TYPE/$PLATFORM"; return 1; }
91+
}
92+
93+
function clean() {
94+
local build_dir="build_${TYPE}_${PLATFORM}"
95+
if [ -d "$build_dir" ]; then rm -r "$build_dir"; fi
96+
}
97+
98+
# No remote binary cache until this opt-in formula has published artifacts.
99+
function load() { echo 0; }
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- a/src/common/CMakeLists.txt
2+
+++ b/src/common/CMakeLists.txt
3+
@@ -105,5 +105,28 @@
4+
${OSSL_HELPERS}
5+
common.c
6+
rand/rand_nist.c)
7+
+
8+
+# OpenSSL also exports these private AVX512 Keccak symbols from libcrypto.
9+
+# Keep liboqs's copy local to its implementation when static archives are
10+
+# linked into the same executable.
11+
+if(TARGET sha3_avx512vl_low)
12+
+ set(_OQS_SHA3_SYMBOL_RENAMES
13+
+ keccak_1600_init_state=OQS_keccak_1600_init_state
14+
+ keccak_1600_load_state_x4=OQS_keccak_1600_load_state_x4
15+
+ keccak_1600_save_state_x4=OQS_keccak_1600_save_state_x4
16+
+ keccak_1600_partial_add_x4=OQS_keccak_1600_partial_add_x4
17+
+ keccak_1600_extract_bytes_x4=OQS_keccak_1600_extract_bytes_x4
18+
+ SHA3_shake128_x4_avx512vl=OQS_SHA3_shake128_x4_avx512vl
19+
+ SHA3_shake128_x4_inc_absorb_avx512vl=OQS_SHA3_shake128_x4_inc_absorb_avx512vl
20+
+ SHA3_shake128_x4_inc_finalize_avx512vl=OQS_SHA3_shake128_x4_inc_finalize_avx512vl
21+
+ SHA3_shake128_x4_inc_squeeze_avx512vl=OQS_SHA3_shake128_x4_inc_squeeze_avx512vl
22+
+ SHA3_shake256_x4_avx512vl=OQS_SHA3_shake256_x4_avx512vl
23+
+ SHA3_shake256_x4_inc_absorb_avx512vl=OQS_SHA3_shake256_x4_inc_absorb_avx512vl
24+
+ SHA3_shake256_x4_inc_finalize_avx512vl=OQS_SHA3_shake256_x4_inc_finalize_avx512vl
25+
+ SHA3_shake256_x4_inc_squeeze_avx512vl=OQS_SHA3_shake256_x4_inc_squeeze_avx512vl)
26+
+ target_compile_definitions(sha3_avx512vl_low PRIVATE ${_OQS_SHA3_SYMBOL_RENAMES})
27+
+ target_compile_definitions(common PRIVATE ${_OQS_SHA3_SYMBOL_RENAMES})
28+
+ target_compile_definitions(internal PRIVATE ${_OQS_SHA3_SYMBOL_RENAMES})
29+
+endif()
30+
set_property(TARGET internal PROPERTY C_VISIBILITY_PRESET default)
31+
32+
if(${OQS_USE_OPENSSL})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--- a/src/kem/ntruprime/CMakeLists.txt
2+
+++ b/src/kem/ntruprime/CMakeLists.txt
3+
@@ -10,0 +11,5 @@
4+
+ # Keep the bundled implementation's optimization blockers private to liboqs.
5+
+ target_compile_definitions(ntruprime_sntrup761_openssh PRIVATE
6+
+ crypto_int16_optblocker=OQS_SNTRUP761_crypto_int16_optblocker
7+
+ crypto_int32_optblocker=OQS_SNTRUP761_crypto_int32_optblocker
8+
+ crypto_int64_optblocker=OQS_SNTRUP761_crypto_int64_optblocker)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Backport of openssh/openssh-portable d4b4c304a202f5099f2f60be9af9ba266212bb74
2+
--- a/configure.ac
3+
+++ b/configure.ac
4+
@@ -861,0 +862 @@
5+
+ AC_CHECK_DECLS(kSBXProfilePureComputation, [], [], [#include <sandbox.h>])
6+
@@ -3968 +3969,2 @@
7+
- test "x$ac_cv_header_sandbox_h" = "xyes") ; then
8+
+ test "x$ac_cv_header_sandbox_h" = "xyes" && \
9+
+ test "x$ac_cv_have_decl_kSBXProfilePureComputation" = "xyes") ; then
10+
@@ -3970,2 +3972,3 @@
11+
- "x$ac_cv_header_sandbox_h" != "xyes" && \
12+
- AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
13+
+ "x$ac_cv_header_sandbox_h" != "xyes" -o \
14+
+ "x$ac_cv_have_decl_kSBXProfilePureComputation" != "xyes" && \
15+
+ AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h, sandbox_init() and kSBXProfilePureComputation])
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--- a/ssh-oqs.c
2+
+++ b/ssh-oqs.c
3+
@@ -30,0 +31 @@
4+
+#define SSHKEY_INTERNAL
5+
@@ -34 +34,0 @@
6+
-#define SSHKEY_INTERNAL
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--- a/kex.h
2+
+++ b/kex.h
3+
@@ -300,0 +301 @@
4+
+void kex_reset_keys(struct kex *);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--- a/Makefile.in
2+
+++ b/Makefile.in
3+
@@ -452 +452 @@
4+
- $(INSTALL) -m 4711 $(STRIP_OPT) ssh-keysign$(EXEEXT) $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)
5+
+ $(INSTALL) -m 0755 $(STRIP_OPT) ssh-keysign$(EXEEXT) $(DESTDIR)$(SSH_KEYSIGN)$(EXEEXT)

0 commit comments

Comments
 (0)