From c49e0f5e261f99792dd8e9b24fbc579ceac4cbc5 Mon Sep 17 00:00:00 2001 From: pinkforest <36498018+pinkforest@users.noreply.github.com> Date: Thu, 29 Feb 2024 03:29:50 +1100 Subject: [PATCH 1/5] ci: Add `no_std` check --- .github/workflows/no_std.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/no_std.yml diff --git a/.github/workflows/no_std.yml b/.github/workflows/no_std.yml new file mode 100644 index 0000000..5b3a9c1 --- /dev/null +++ b/.github/workflows/no_std.yml @@ -0,0 +1,24 @@ +on: + workflow_dispatch: + push: + branches: [ master ] + pull_request: + branches: [ '**' ] + +jobs: + build-nostd: + name: Build on no_std target (thumbv7em-none-eabi) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + targets: thumbv7em-none-eabi + - uses: taiki-e/install-action@cargo-hack + # No default features build + - name: no_std / no feat + run: cargo build --target thumbv7em-none-eabi --release --no-default-features + # cargo hack ensures all no_std features all built-checked + - name: no_std / cargo hack features + run: cargo hack build --target thumbv7em-none-eabi --release --each-feature --exclude-features default,std,getrandom,wasm,benchmarking From 1e131e04e19e126ce9a09f00331323b829a8f2e1 Mon Sep 17 00:00:00 2001 From: pinkforest <36498018+pinkforest@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:16:12 +1100 Subject: [PATCH 2/5] Fix no_std for Cargo.toml --- Cargo.toml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 02c3371..f1eb89e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,22 +11,20 @@ description = "Fork of pqc_kyber with some safety fixes" keywords = ["kyber", "kem", "key-exchange", "kex", "post-quantum"] readme = "readme.md" +resolver = "2" + [dependencies] rand_core = { version = "0.6.4", default-features = false } wasm-bindgen = { version = "0.2.84", optional = true } -getrandom = {version = "0.2.9", features = ["js"], optional = true } zeroize = { version = "1.6.0", features = ["derive"], optional = true } -# Optional dev-deps, see https://github.com/rust-lang/cargo/issues/1596 +# wasm needs rand - TODO: remove +rand = { version = "0.8", default-features = false, optional = true } +getrandom = {version = "0.2.9", default-features = false, optional = true } criterion = { version = "0.4.0", features = ["html_reports"], optional = true } -[dependencies.rand] -version = "0.8.5" -default-features = false -features = ["getrandom"] -optional = true - [dev-dependencies] -rand = "0.8.5" +rand = { version = "0.8", default-features = false, features = ["std", "std_rng", "getrandom"] } +rand_core = { version = "0.6", default-features = false, features = ["getrandom"] } [build-dependencies] @@ -38,6 +36,7 @@ name = "api" harness = false [features] +default = [] ### Security Levels ### # Defaults to "kyber768" if none selected # Will throw a compile-time error if more than one level is chosen @@ -46,7 +45,7 @@ kyber768 = [] kyber1024 = [] # For compiling to wasm targets -wasm = ["wasm-bindgen", "getrandom", "rand"] +wasm = ["wasm-bindgen", "rand/getrandom", "rand_core/getrandom", "getrandom/js"] # Enable std library support std = [] From 993292e82ce71a7ca040a015461deb4a64f5d289 Mon Sep 17 00:00:00 2001 From: pinkforest <36498018+pinkforest@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:18:29 +1100 Subject: [PATCH 3/5] ci: Temp check own branch --- .github/workflows/no_std.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/no_std.yml b/.github/workflows/no_std.yml index 5b3a9c1..b1e8fc3 100644 --- a/.github/workflows/no_std.yml +++ b/.github/workflows/no_std.yml @@ -1,7 +1,7 @@ on: workflow_dispatch: push: - branches: [ master ] + branches: [ '**' ] pull_request: branches: [ '**' ] From a168d0cd2e4a97972d3af59a3d78132684d8dffb Mon Sep 17 00:00:00 2001 From: pinkforest <36498018+pinkforest@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:37:40 +1100 Subject: [PATCH 4/5] Ignore kyber1024 for now - pending issue #3 --- .github/workflows/no_std.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/no_std.yml b/.github/workflows/no_std.yml index b1e8fc3..17108ed 100644 --- a/.github/workflows/no_std.yml +++ b/.github/workflows/no_std.yml @@ -21,4 +21,4 @@ jobs: run: cargo build --target thumbv7em-none-eabi --release --no-default-features # cargo hack ensures all no_std features all built-checked - name: no_std / cargo hack features - run: cargo hack build --target thumbv7em-none-eabi --release --each-feature --exclude-features default,std,getrandom,wasm,benchmarking + run: cargo hack build --target thumbv7em-none-eabi --release --each-feature --exclude-features default,std,getrandom,wasm,benchmarking,kyber1024 From 7697936a497c9777c3bbb6138175692819f95475 Mon Sep 17 00:00:00 2001 From: pinkforest <36498018+pinkforest@users.noreply.github.com> Date: Thu, 29 Feb 2024 22:39:31 +1100 Subject: [PATCH 5/5] Revert "ci: Temp check own branch" This reverts commit 993292e82ce71a7ca040a015461deb4a64f5d289. --- .github/workflows/no_std.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/no_std.yml b/.github/workflows/no_std.yml index 17108ed..5c7f1d2 100644 --- a/.github/workflows/no_std.yml +++ b/.github/workflows/no_std.yml @@ -1,7 +1,7 @@ on: workflow_dispatch: push: - branches: [ '**' ] + branches: [ master ] pull_request: branches: [ '**' ]