diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6d2d20b..bd5718b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -27,7 +27,10 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - run: cargo test && cargo test --doc + - run: | + cargo test + cargo test --doc + cargo test --package tsp --features nacl cargo-deny: runs-on: ubuntu-latest diff --git a/.github/workflows/check_BACKUP_126343.yml b/.github/workflows/check_BACKUP_126343.yml deleted file mode 100644 index 3d66b8c..0000000 --- a/.github/workflows/check_BACKUP_126343.yml +++ /dev/null @@ -1,142 +0,0 @@ -name: Check - -on: - pull_request: - branches: [ "main" ] - -jobs: - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --workspace --tests -- --deny "warnings" - - rust-fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo fmt --all --check - - cargo-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo test && cargo test --doc - - cargo-deny: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check - arguments: --workspace - -<<<<<<< HEAD - - name: Test - run: cargo test -- --nocapture && cargo test --doc - shell: bash - - check-wasm32-unknown-unknown: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '16' - - - name: Install wasm-pack - run: cargo install wasm-pack - - - name: Run tests with wasm-pack - working-directory: tsp - run: wasm-pack test --node -- -p tsp --no-default-features --features "resolve" - -======= ->>>>>>> b469444 (Add nacl and essr features) - fuzz: - name: run cargo-fuzz - runs-on: ubuntu-latest - strategy: - matrix: - features: - - "" - steps: - - uses: actions/checkout@v4 - - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 - with: - toolchain: nightly - - uses: Swatinem/rust-cache@v2 - - name: Install cargo fuzz - uses: taiki-e/install-action@8984d603c208823d3c1a1b796f4081736f3ae3f9 - with: - tool: cargo-fuzz - - name: Smoke-test fuzz targets - run: | - cargo fuzz build ${{ matrix.features }} - for target in $(cargo fuzz list ${{ matrix.features }}) ; do - cargo fuzz run ${{ matrix.features }} $target -- -max_total_time=10 - done - - check-python: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add clippy - - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - - name: Install maturin - run: pip install maturin - - - name: Create and activate virtual environment - working-directory: tsp-python - run: | - python -m venv venv - source venv/bin/activate - pip install maturin - - - name: Build and test - working-directory: tsp-python - run: | - source venv/bin/activate - maturin develop - python3 test.py diff --git a/.github/workflows/check_BASE_126343.yml b/.github/workflows/check_BASE_126343.yml deleted file mode 100644 index b0a5da7..0000000 --- a/.github/workflows/check_BASE_126343.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Check - -on: - pull_request: - branches: [ "main" ] - -jobs: - check: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add clippy - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - - name: Check, clippy and format - run: cargo check && cargo clippy --tests -- --deny "warnings" && cargo fmt --check - - - name: Deny - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check - arguments: --workspace - - - name: Test - run: cargo test -- --nocapture && cargo test --doc - shell: bash - - fuzz: - name: run cargo-fuzz - runs-on: ubuntu-22.04 - strategy: - matrix: - features: - - "" - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add clippy - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 - with: - toolchain: nightly - - name: Install cargo fuzz - uses: taiki-e/install-action@8984d603c208823d3c1a1b796f4081736f3ae3f9 - with: - tool: cargo-fuzz - - name: Smoke-test fuzz targets - run: | - cargo fuzz build ${{ matrix.features }} - for target in $(cargo fuzz list ${{ matrix.features }}) ; do - cargo fuzz run ${{ matrix.features }} $target -- -max_total_time=10 - done diff --git a/.github/workflows/check_LOCAL_126343.yml b/.github/workflows/check_LOCAL_126343.yml deleted file mode 100644 index 3922762..0000000 --- a/.github/workflows/check_LOCAL_126343.yml +++ /dev/null @@ -1,143 +0,0 @@ -name: Check - -on: - pull_request: - branches: [ "main" ] - -jobs: - check: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add clippy - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - - name: Check, clippy and format - run: cargo check && cargo clippy --tests -- --deny "warnings" && cargo fmt --check - - - name: Deny - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check - arguments: --workspace - - - name: Test - run: cargo test -- --nocapture && cargo test --doc - shell: bash - - check-wasm32-unknown-unknown: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '16' - - - name: Install wasm-pack - run: cargo install wasm-pack - - - name: Run tests with wasm-pack - working-directory: tsp - run: wasm-pack test --node -- -p tsp --no-default-features --features "resolve" - - fuzz: - name: run cargo-fuzz - runs-on: ubuntu-22.04 - strategy: - matrix: - features: - - "" - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add clippy - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 - with: - toolchain: nightly - - name: Install cargo fuzz - uses: taiki-e/install-action@8984d603c208823d3c1a1b796f4081736f3ae3f9 - with: - tool: cargo-fuzz - - name: Smoke-test fuzz targets - run: | - cargo fuzz build ${{ matrix.features }} - for target in $(cargo fuzz list ${{ matrix.features }}) ; do - cargo fuzz run ${{ matrix.features }} $target -- -max_total_time=10 - done - - check-python: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - run: rustup toolchain install stable --profile minimal - - run: rustup component add clippy - - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: "3.10" - - - uses: actions/cache/restore@v3 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: linux-x86-64-gnu-${{ hashFiles('Cargo.toml') }} - restore-keys: linux-x86-64-gnu- - - - name: Install maturin - run: pip install maturin - - - name: Create and activate virtual environment - working-directory: tsp-python - run: | - python -m venv venv - source venv/bin/activate - pip install maturin - - - name: Build and test - working-directory: tsp-python - run: | - source venv/bin/activate - maturin develop - python3 test.py diff --git a/.github/workflows/check_REMOTE_126343.yml b/.github/workflows/check_REMOTE_126343.yml deleted file mode 100644 index f778462..0000000 --- a/.github/workflows/check_REMOTE_126343.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Check - -on: - pull_request: - branches: [ "main" ] - -jobs: - clippy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo clippy --workspace --tests -- --deny "warnings" - - rust-fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo fmt --all --check - - cargo-test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - run: cargo test && cargo test --doc - - cargo-deny: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: EmbarkStudios/cargo-deny-action@v1 - with: - command: check - arguments: --workspace - - fuzz: - name: run cargo-fuzz - runs-on: ubuntu-latest - strategy: - matrix: - features: - - "" - steps: - - uses: actions/checkout@v4 - - name: Install nightly toolchain - uses: dtolnay/rust-toolchain@be73d7920c329f220ce78e0234b8f96b7ae60248 - with: - toolchain: nightly - - uses: Swatinem/rust-cache@v2 - - name: Install cargo fuzz - uses: taiki-e/install-action@8984d603c208823d3c1a1b796f4081736f3ae3f9 - with: - tool: cargo-fuzz - - name: Smoke-test fuzz targets - run: | - cargo fuzz build ${{ matrix.features }} - for target in $(cargo fuzz list ${{ matrix.features }}) ; do - cargo fuzz run ${{ matrix.features }} $target -- -max_total_time=10 - done diff --git a/tsp/Cargo.toml b/tsp/Cargo.toml index 865ffaf..687ec7e 100644 --- a/tsp/Cargo.toml +++ b/tsp/Cargo.toml @@ -12,13 +12,12 @@ rust-version.workspace = true [features] cesr-t = [ ] -default = ["async", "hpke"] +default = ["async"] essr = [ ] strict = [ ] fuzzing = ["dep:arbitrary"] demo = [ ] nacl = ["dep:crypto_box", "essr"] -hpke = ["dep:hpke"] async = [ "resolve", "aries-askar", @@ -55,7 +54,7 @@ tracing = { workspace = true, optional = true } once_cell = { workspace = true } # crypto ed25519-dalek = { workspace = true } -hpke = { workspace = true, optional = true } +hpke = { workspace = true } rand = { workspace = true } sha2 = { workspace = true } crypto_box = { workspace = true, optional = true } diff --git a/tsp/src/crypto/error.rs b/tsp/src/crypto/error.rs index c456fd0..77babdf 100644 --- a/tsp/src/crypto/error.rs +++ b/tsp/src/crypto/error.rs @@ -4,7 +4,7 @@ pub enum CryptoError { Encode(#[from] crate::cesr::error::EncodeError), #[error("failed to decode message {0}")] Decode(#[from] crate::cesr::error::DecodeError), - #[cfg(feature = "hpke")] + #[cfg(not(feature = "nacl"))] #[error("encryption or decryption failed: {0}")] Cryptographic(#[from] hpke::HpkeError), #[cfg(feature = "nacl")] diff --git a/tsp/src/crypto/mod.rs b/tsp/src/crypto/mod.rs index b47001f..13abda9 100644 --- a/tsp/src/crypto/mod.rs +++ b/tsp/src/crypto/mod.rs @@ -12,18 +12,18 @@ mod nonconfidential; #[cfg(feature = "nacl")] mod tsp_nacl; -#[cfg(feature = "hpke")] +#[cfg(not(feature = "nacl"))] mod tsp_hpke; pub use error::CryptoError; -#[cfg(feature = "hpke")] +#[cfg(not(feature = "nacl"))] pub type Aead = hpke::aead::ChaCha20Poly1305; -#[cfg(feature = "hpke")] +#[cfg(not(feature = "nacl"))] pub type Kdf = hpke::kdf::HkdfSha256; -#[cfg(feature = "hpke")] +#[cfg(not(feature = "nacl"))] pub type Kem = hpke::kem::X25519HkdfSha256; type ObservingClosure<'a> = &'a mut dyn FnMut(&[u8]); @@ -35,7 +35,7 @@ pub fn seal( nonconfidential_data: Option, payload: Payload<&[u8]>, ) -> Result { - #[cfg(feature = "hpke")] + #[cfg(not(feature = "nacl"))] return tsp_hpke::seal::(sender, receiver, nonconfidential_data, payload, None); #[cfg(feature = "nacl")] @@ -51,7 +51,7 @@ pub fn seal_and_hash( ) -> Result<(TSPMessage, Digest), CryptoError> { let digest = &mut Default::default(); - #[cfg(feature = "hpke")] + #[cfg(not(feature = "nacl"))] let msg = tsp_hpke::seal::( sender, receiver, @@ -84,7 +84,7 @@ pub fn open<'a>( sender: &dyn VerifiedVid, tsp_message: &'a mut [u8], ) -> Result, CryptoError> { - #[cfg(feature = "hpke")] + #[cfg(not(feature = "nacl"))] return tsp_hpke::open::(receiver, sender, tsp_message); #[cfg(feature = "nacl")] @@ -108,7 +108,7 @@ pub fn verify<'a>( nonconfidential::verify(sender, tsp_message) } -#[cfg(feature = "hpke")] +#[cfg(not(feature = "nacl"))] /// Generate a new encryption / decryption key pair pub fn gen_encrypt_keypair() -> (PrivateKeyData, PublicKeyData) { use hpke::Serializable;