Skip to content

Commit a97a93c

Browse files
Package cleanup (#97)
* Remove WASM support * Copyedit crate description * Clean up macro export/import * Switch to dtolnay/rust-toolchain * Replace two more actions-rs reusable workflows * Check for rustdoc warnings * Replace deprecated command line flag * Fix test compilation when serde feature is enabled * Disable everything if no features are enabled If no KEM, KDF, or AEAD is enabled, we get compilation errors because an empty enum cannot have #[repr(u16)] applied to it. Additionally, if neither base-mode-open or base-mode-seal is enabled, the library can do no useful work. * Fix conditional compilation issues with open/seal * Add configuration for cargo-all-features * Test/check additional feature combinations in CI
1 parent 3566a89 commit a97a93c

25 files changed

+65
-7252
lines changed

.cargo/config.toml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,84 +15,40 @@ jobs:
1515
os: [ubuntu-latest, macOS-latest, windows-latest]
1616
rust: [stable, nightly]
1717
env:
18-
# This environment variable would override the RUSTFLAGS value set in .config/cargo.toml when
19-
# building for WASM. Thus, we only use it on host builds.
2018
RUSTFLAGS: -Dwarnings
2119
steps:
2220
- uses: actions/checkout@v6
2321
- name: Install ${{ matrix.rust }}
24-
uses: actions-rs/toolchain@v1
22+
uses: dtolnay/rust-toolchain@master
2523
with:
2624
toolchain: ${{ matrix.rust }}
27-
override: true
2825

2926
- name: Rust Cache
3027
uses: Swatinem/[email protected]
3128

3229
- name: Run tests
33-
uses: actions-rs/cargo@v1
34-
with:
35-
command: test
36-
args: --all --no-fail-fast
30+
run: cargo test --workspace --no-fail-fast
31+
- name: Run tests (all features)
32+
run: cargo test --workspace --no-fail-fast --all-features
3733

3834
check_fmt_and_docs:
3935
name: Lints and Docs
4036
runs-on: ubuntu-latest
4137
env:
42-
# This environment variable would override the RUSTFLAGS value set in .config/cargo.toml when
43-
# building for WASM. Thus, we only use it on host builds.
4438
RUSTFLAGS: -Dwarnings
39+
RUSTDOCFLAGS: -Dwarnings
4540
steps:
4641
- uses: actions/checkout@v6
47-
- uses: actions-rs/toolchain@v1
42+
- uses: dtolnay/rust-toolchain@stable
4843
with:
49-
toolchain: stable
5044
components: rustfmt, clippy
51-
override: true
5245

53-
- uses: actions-rs/clippy-check@v1
54-
with:
55-
token: ${{ secrets.GITHUB_TOKEN }}
56-
46+
# Check using Clippy with the feature combinations listed in the README.
47+
- run: cargo clippy
48+
- run: cargo clippy --no-default-features --features algo-all,base-mode-open,serde
49+
5750
- name: Format
5851
run: cargo fmt --all -- --check
5952

6053
- name: Docs
6154
run: cargo doc --no-deps
62-
63-
64-
65-
wasm-pack:
66-
name: Wasm stuff
67-
runs-on: ubuntu-latest
68-
steps:
69-
- uses: actions/checkout@v6
70-
- uses: actions-rs/toolchain@v1
71-
with:
72-
toolchain: nightly
73-
override: true
74-
target: wasm32-unknown-unknown
75-
- uses: actions/setup-node@v6
76-
with:
77-
node-version: "22"
78-
- name: install cargo-binstall
79-
uses: cargo-bins/[email protected]
80-
- name: install wasm-pack
81-
run: cargo binstall wasm-pack --version 0.13.1
82-
- name: build with default features
83-
run: wasm-pack build
84-
- name: node test
85-
run: wasm-pack test --node
86-
js:
87-
name: TS tests
88-
runs-on: ubuntu-latest
89-
steps:
90-
- uses: actions/checkout@v6
91-
- uses: actions/setup-node@v6
92-
with:
93-
node-version: "22"
94-
- run: npm ci
95-
- run: npm run build
96-
- run: npm run test
97-
98-

.github/workflows/docs.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v6
13-
- uses: actions-rs/toolchain@v1
13+
- uses: dtolnay/rust-toolchain@stable
1414
with:
15-
toolchain: stable
1615
components: rustfmt, clippy
17-
override: true
1816

1917
- name: Build Documentation
20-
run: cargo doc --all
18+
run: cargo doc --workspace
2119

2220
- name: Deploy Docs
2321
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
/target
22
/Cargo.lock
3-
.log
4-
/node_modules

Cargo.toml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
name = "hpke-dispatch"
33
version = "0.8.0"
44
edition = "2021"
5-
description = "runtime algorithmic selection for hybrid public key encryption"
5+
description = "Runtime algorithm selection for hybrid public key encryption"
66
license = "MPL-2.0"
77
repository = "https://github.com/divviup/hpke-dispatch"
88
readme = "./README.md"
99
keywords = ["hpke", "encryption"]
1010
categories = ["cryptography"]
1111

1212
[features]
13-
cfg_eval = []
1413
base-mode-open = []
1514
base-mode-seal = []
1615
serde = ["serde_crate"]
@@ -43,19 +42,17 @@ features = ["derive"]
4342
optional = true
4443
package = "serde"
4544

46-
[target.wasm32-unknown-unknown.dependencies]
47-
wasm-bindgen = "0.2.87"
48-
getrandom_2 = { package = "getrandom", version = "0.2.16", features = ["js", "js-sys"] } # for getrandom 0.2
49-
getrandom_3 = { package = "getrandom", version = "0.3.3", features = ["wasm_js"] } # for getrandom 0.3
50-
51-
[lib]
52-
crate-type = ["cdylib", "rlib"]
53-
54-
[profile.release]
55-
lto = true
56-
5745
[dev-dependencies]
5846
hex = { version = "0.4.3", features = ["serde"] }
59-
serde = { version = "1.0.185", features = ["derive"] }
47+
serde_crate = { package = "serde", version = "1.0.185", features = ["derive"] }
6048
serde_json = "1.0.105"
61-
wasm-bindgen-test = "0.3.37"
49+
50+
[package.metadata.cargo-all-features]
51+
# These features are redundant, as they only enable other features.
52+
denylist = ["algo-all", "aead-all", "kdf-all", "kem-all"]
53+
# We don't use the implicit "serde_crate" feature, only our explicitly defined
54+
# "serde" feature.
55+
skip_optional_dependencies = true
56+
# Allow for one of base-mode-open/base-mode-seal, one KEM, one KDF, one AEAD,
57+
# plus serde or another feature
58+
max_combination_size = 5

README.md

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,8 @@ single-shot message encryption/decryption, as defined in [RFC9180§6][section-6]
1313
[hpke]: https://github.com/rozbb/rust-hpke
1414
[section-6]: https://www.rfc-editor.org/rfc/rfc9180.html#section-6
1515

16-
## WebAssembly ready
17-
18-
This crate is also published to npm as [`hpke`][npm] as a
19-
typescript/javascript package, and can also be custom built for
20-
specific wasm use cases (omitting unused algorithms) with
21-
[`wasm-pack`][wasm-pack]. For an example of using the library from
22-
node, see [examples/example.ts][example-ts]
23-
24-
[npm]: https://www.npmjs.com/package/hpke
25-
[wasm-pack]: https://github.com/rustwasm/wasm-pack
26-
[example-ts]: https://github.com/jbr/hpke-dispatch/blob/main/examples/example.ts
27-
28-
## Nightly-only feature to work around a wasm-bindgen bug: `cfg_eval`
29-
30-
In order to opt out of `algo-all` for a wasm build, you must use
31-
nightly and enable the `cfg_eval` cargo feature. This is due to
32-
[wasm-bindgen#2058][wasm-bindgen-2058]. This is not necessary for use
33-
from rust, even when opting out of `algo-all`.
34-
35-
[hpke]: https://docs.rs/hpke/latest/hpke/
36-
[wasm-bindgen-2058]: https://github.com/rustwasm/wasm-bindgen/issues/2058
37-
3816
## Available cargo features:
3917

40-
* *`cfg_eval`*: allows this crate to be built on nightly rust for wasm
41-
without `algo-all`. Note that `algo-all` (all
42-
algorithms) will build for wasm on any channel without this feature.
43-
disabled by default. Attempting to build for wasm with a subset.
44-
4518
* *base-mode-open*: Enables hpke base-mode one-shot open behavior
4619
(receiver functionality). Enabled by default.
4720

@@ -66,19 +39,9 @@ from rust, even when opting out of `algo-all`.
6639

6740
## Example feature usage:
6841

69-
To depend on this crate from rust with all algorithms,
42+
To depend on this crate with all algorithms,
7043
`base-mode-open`, and `base-mode-seal`, use default features.
7144

72-
To depend on this crate from rust with all algorithms and serde
45+
To depend on this crate with all algorithms and serde
7346
enabled, but without `base-mode-seal`: `default-features = false,
7447
features = ["algo-all", "base-mode-open", "serde"]`
75-
76-
To build for wasm without `kem-x25519-hkdf-sha256` or
77-
`base-mode-open`: `wasm-pack build --no-default-features --features
78-
aead-all,kdf-all,kem-dh-p256-hkdf-sha256,base-mode-seal,cfg_eval`
79-
80-
To build for wasm with all algorithms but without base-mode-open:
81-
`wasm-pack build --no-default-features --features
82-
algo-all,base-mode-seal`
83-
84-

examples/example.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)