diff --git a/.github/workflows/base16ct.yml b/.github/workflows/base16ct.yml index 17df14529..9b3429a55 100644 --- a/.github/workflows/base16ct.yml +++ b/.github/workflows/base16ct.yml @@ -35,8 +35,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release - - run: cargo build --target ${{ matrix.target }} --release --features alloc + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -52,9 +52,8 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release - - run: cargo test --release --features alloc - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset bench: runs-on: ubuntu-latest diff --git a/.github/workflows/base64ct.yml b/.github/workflows/base64ct.yml index ad470207b..5cee787a7 100644 --- a/.github/workflows/base64ct.yml +++ b/.github/workflows/base64ct.yml @@ -35,8 +35,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release - - run: cargo build --target ${{ matrix.target }} --release --features alloc + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -52,9 +52,8 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release - - run: cargo test --release --features alloc - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset bench: runs-on: ubuntu-latest diff --git a/.github/workflows/const-oid.yml b/.github/workflows/const-oid.yml index 019206fe2..ac38b56a8 100644 --- a/.github/workflows/const-oid.yml +++ b/.github/workflows/const-oid.yml @@ -35,7 +35,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -51,5 +52,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/der.yml b/.github/workflows/der.yml index a0ceebfc4..5d0afafc8 100644 --- a/.github/workflows/der.yml +++ b/.github/workflows/der.yml @@ -36,13 +36,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release - - run: cargo build --target ${{ matrix.target }} --release --features alloc - - run: cargo build --target ${{ matrix.target }} --release --features derive - - run: cargo build --target ${{ matrix.target }} --release --features oid - - run: cargo build --target ${{ matrix.target }} --release --features pem - - run: cargo build --target ${{ matrix.target }} --release --features time - - run: cargo build --target ${{ matrix.target }} --release --features alloc,derive,oid,pem,time + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: strategy: @@ -83,10 +78,8 @@ jobs: profile: minimal override: true - run: ${{ matrix.deps }} - - run: cargo test --target ${{ matrix.target }} --release - - run: cargo test --target ${{ matrix.target }} --release --features oid - - run: cargo test --target ${{ matrix.target }} --release --features pem - - run: cargo test --target ${{ matrix.target }} --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset derive: runs-on: ubuntu-latest @@ -102,5 +95,6 @@ jobs: toolchain: ${{ matrix.rust }} override: true profile: minimal - - run: cargo test --release + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset working-directory: der/derive diff --git a/.github/workflows/pem-rfc7468.yml b/.github/workflows/pem-rfc7468.yml index 9c1cd16f5..041ccea4e 100644 --- a/.github/workflows/pem-rfc7468.yml +++ b/.github/workflows/pem-rfc7468.yml @@ -36,8 +36,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release - - run: cargo build --target ${{ matrix.target }} --release --features alloc + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -53,6 +53,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/pkcs1.yml b/.github/workflows/pkcs1.yml index a38e53037..43cdb6ca6 100644 --- a/.github/workflows/pkcs1.yml +++ b/.github/workflows/pkcs1.yml @@ -39,12 +39,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release --no-default-features - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8 - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features zeroize - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc,pem,pkcs8,zeroize + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -60,6 +56,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/pkcs5.yml b/.github/workflows/pkcs5.yml index 02df1bebb..06f8a5417 100644 --- a/.github/workflows/pkcs5.yml +++ b/.github/workflows/pkcs5.yml @@ -38,14 +38,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release - - run: cargo build --target ${{ matrix.target }} --release --features alloc - - run: cargo build --target ${{ matrix.target }} --release --features pbes2 - - run: cargo build --target ${{ matrix.target }} --release --features scrypt - - run: cargo build --target ${{ matrix.target }} --release --features alloc,pbes2 - - run: cargo build --target ${{ matrix.target }} --release --features sha1 - - run: cargo build --target ${{ matrix.target }} --release --features 3des - - run: cargo build --target ${{ matrix.target }} --release --features des-insecure + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -61,11 +55,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release - - run: cargo test --release --features alloc - - run: cargo test --release --features pbes2 - - run: cargo test --release --features scrypt - - run: cargo test --release --features sha1 - - run: cargo test --release --features 3des - - run: cargo test --release --features des-insecure - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/pkcs7.yml b/.github/workflows/pkcs7.yml index d5368f74d..859a8b4a4 100644 --- a/.github/workflows/pkcs7.yml +++ b/.github/workflows/pkcs7.yml @@ -37,7 +37,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --release --target ${{ matrix.target }} --no-default-features + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset test: runs-on: ubuntu-latest @@ -53,6 +54,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/pkcs8.yml b/.github/workflows/pkcs8.yml index 0145440bb..cc739360a 100644 --- a/.github/workflows/pkcs8.yml +++ b/.github/workflows/pkcs8.yml @@ -40,16 +40,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --release --target ${{ matrix.target }} --no-default-features - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features alloc - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features 3des - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features des-insecure - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features encryption - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features pem - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features pkcs5 - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features sha1 - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features subtle - - run: cargo build --release --target ${{ matrix.target }} --no-default-features --features zeroize + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std,rand test: runs-on: ubuntu-latest @@ -65,14 +57,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --features alloc - - run: cargo test --release --features 3des - - run: cargo test --release --features des-insecure - - run: cargo test --release --features encryption - - run: cargo test --release --features pem - - run: cargo test --release --features pkcs5 - - run: cargo test --release --features sha1 - - run: cargo test --release --features std - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/sec1.yml b/.github/workflows/sec1.yml index 4e32f3753..c8d42dd27 100644 --- a/.github/workflows/sec1.yml +++ b/.github/workflows/sec1.yml @@ -39,14 +39,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release --no-default-features - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pem - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features pkcs8 - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features subtle - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features zeroize - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc,pem,pkcs8,serde,subtle,zeroize + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -62,6 +56,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/spki.yml b/.github/workflows/spki.yml index e5281660d..998f73dc0 100644 --- a/.github/workflows/spki.yml +++ b/.github/workflows/spki.yml @@ -38,11 +38,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --release --target ${{ matrix.target }} - - run: cargo build --release --target ${{ matrix.target }} --features alloc - - run: cargo build --release --target ${{ matrix.target }} --features fingerprint - - run: cargo build --release --target ${{ matrix.target }} --features pem - - run: cargo build --release --target ${{ matrix.target }} --features alloc,fingerprint,pem + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -58,5 +55,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/ssh-key.yml b/.github/workflows/ssh-key.yml index 02a84763f..ea0ed7155 100644 --- a/.github/workflows/ssh-key.yml +++ b/.github/workflows/ssh-key.yml @@ -37,10 +37,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release --no-default-features - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features sec1 - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features alloc,sec1 + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -56,6 +54,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/tai64.yml b/.github/workflows/tai64.yml index d64f1552f..10b779d16 100644 --- a/.github/workflows/tai64.yml +++ b/.github/workflows/tai64.yml @@ -35,9 +35,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --release --no-default-features - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features serde - - run: cargo build --target ${{ matrix.target }} --release --no-default-features --features zeroize + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std,default test: runs-on: ubuntu-latest @@ -53,6 +52,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release --no-default-features - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/tls_codec.yml b/.github/workflows/tls_codec.yml index db4603e63..b18f939c9 100644 --- a/.github/workflows/tls_codec.yml +++ b/.github/workflows/tls_codec.yml @@ -27,27 +27,6 @@ jobs: - stable target: - wasm32-unknown-unknown - steps: - - uses: actions/checkout@v1 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - target: ${{ matrix.target }} - override: true - - run: cargo build --target ${{ matrix.target }} --release - - run: cargo build --target ${{ matrix.target }} --release --features derive - - run: cargo build --target ${{ matrix.target }} --release --features serde_serialize - - run: cargo build --target ${{ matrix.target }} --release --all-features - - no_std: - runs-on: ubuntu-latest - strategy: - matrix: - rust: - - 1.56.0 # MSRV - - stable - target: - thumbv7em-none-eabi steps: - uses: actions/checkout@v1 @@ -57,7 +36,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --target ${{ matrix.target }} --no-default-features --release + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std,default,derive,serde_serialize test: runs-on: ubuntu-latest @@ -86,7 +66,5 @@ jobs: profile: minimal override: true - run: ${{ matrix.deps }} - - run: cargo test --target ${{ matrix.target }} --release - - run: cargo test --target ${{ matrix.target }} --release --features derive - - run: cargo test --target ${{ matrix.target }} --release --features serde_serialize - - run: cargo test --target ${{ matrix.target }} --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/.github/workflows/x509.yml b/.github/workflows/x509.yml index 16042a81e..9d4f42d29 100644 --- a/.github/workflows/x509.yml +++ b/.github/workflows/x509.yml @@ -38,7 +38,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true - - run: cargo build --release --target ${{ matrix.target }} + - run: cargo install cargo-hack + - run: cargo hack build --release --target ${{ matrix.target }} --feature-powerset --exclude-features std test: runs-on: ubuntu-latest @@ -54,5 +55,5 @@ jobs: profile: minimal toolchain: ${{ matrix.rust }} override: true - - run: cargo test --release - - run: cargo test --release --all-features + - run: cargo install cargo-hack + - run: cargo hack test --release --feature-powerset diff --git a/Cargo.toml b/Cargo.toml index fbc091107..3ec27af5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ +# Trigger a full workspace run [workspace] resolver = "2" members = [ diff --git a/der/tests/derive.rs b/der/tests/derive.rs index 9a019a896..a448aa9d3 100644 --- a/der/tests/derive.rs +++ b/der/tests/derive.rs @@ -7,7 +7,7 @@ //! //! $ cargo expand --test derive --all-features -#![cfg(feature = "derive")] +#![cfg(all(feature = "derive", feature = "alloc"))] /// Custom derive test cases for the `Choice` macro. mod choice { @@ -199,6 +199,7 @@ mod enumerated { } /// Custom derive test cases for the `Sequence` macro. +#[cfg(feature = "oid")] mod sequence { use der::{ asn1::{Any, ObjectIdentifier, SetOf}, diff --git a/pem-rfc7468/src/lib.rs b/pem-rfc7468/src/lib.rs index aac1b0645..1e1a74bf1 100644 --- a/pem-rfc7468/src/lib.rs +++ b/pem-rfc7468/src/lib.rs @@ -4,7 +4,7 @@ //! //! ``` //! # fn main() -> Result<(), Box> { -//! # #[cfg(feature = "alloc")] +//! # #[cfg(feature = "std")] //! # { //! /// Example PEM document //! /// NOTE: do not actually put private key literals into your source code!!! diff --git a/pkcs1/Cargo.toml b/pkcs1/Cargo.toml index 57a9a2433..e1c5aabbe 100644 --- a/pkcs1/Cargo.toml +++ b/pkcs1/Cargo.toml @@ -27,7 +27,7 @@ hex-literal = "0.3" [features] alloc = ["der/alloc", "pkcs8/alloc", "zeroize/alloc"] pem = ["alloc", "der/pem", "pkcs8/pem"] -std = ["der/std"] +std = ["der/std", "alloc"] [package.metadata.docs.rs] all-features = true diff --git a/pkcs1/src/private_key/document.rs b/pkcs1/src/private_key/document.rs index f154ab1ad..dc03b4b76 100644 --- a/pkcs1/src/private_key/document.rs +++ b/pkcs1/src/private_key/document.rs @@ -14,7 +14,7 @@ use { }; #[cfg(feature = "std")] -use std::{path::Path, str}; +use std::path::Path; /// PKCS#1 `RSA PRIVATE KEY` document. /// diff --git a/pkcs1/src/traits.rs b/pkcs1/src/traits.rs index e9195ad06..5fad55460 100644 --- a/pkcs1/src/traits.rs +++ b/pkcs1/src/traits.rs @@ -17,7 +17,7 @@ use std::path::Path; #[cfg(all(feature = "alloc", feature = "pkcs8"))] use der::Document; -#[cfg(any(feature = "pem", feature = "std"))] +#[cfg(feature = "pem")] use zeroize::Zeroizing; /// Parse an [`RsaPrivateKey`] from a PKCS#1-encoded document. diff --git a/pkcs8/Cargo.toml b/pkcs8/Cargo.toml index c5dd08613..7a6b6ea84 100644 --- a/pkcs8/Cargo.toml +++ b/pkcs8/Cargo.toml @@ -34,7 +34,7 @@ alloc = ["der/alloc", "spki/alloc", "zeroize"] des-insecure = ["encryption", "pkcs5/des-insecure"] encryption = ["alloc", "pkcs5/alloc", "pkcs5/pbes2", "rand_core"] pem = ["alloc", "der/pem", "spki/pem"] -rand = ["rand_core/std"] +rand = ["std", "rand_core/std"] sha1 = ["encryption", "pkcs5/sha1"] std = ["alloc", "der/std", "spki/std"] diff --git a/pkcs8/tests/encrypted_private_key.rs b/pkcs8/tests/encrypted_private_key.rs index 36df69c8c..98e1fa0f3 100644 --- a/pkcs8/tests/encrypted_private_key.rs +++ b/pkcs8/tests/encrypted_private_key.rs @@ -8,7 +8,7 @@ use pkcs8::{pkcs5::pbes2, EncryptedPrivateKeyInfo}; #[cfg(feature = "encryption")] use pkcs8::PrivateKeyDocument; -#[cfg(feature = "pem")] +#[cfg(any(feature = "std", feature = "pem"))] use pkcs8::EncryptedPrivateKeyDocument; #[cfg(feature = "std")] diff --git a/sec1/Cargo.toml b/sec1/Cargo.toml index fac49d64b..5e374b34a 100644 --- a/sec1/Cargo.toml +++ b/sec1/Cargo.toml @@ -31,7 +31,7 @@ hex-literal = "0.3" [features] alloc = ["der/alloc", "pkcs8/alloc", "zeroize/alloc"] pem = ["alloc", "der/pem", "pkcs8/pem"] -std = ["der/std"] +std = ["der/std", "alloc"] [package.metadata.docs.rs] all-features = true diff --git a/sec1/src/private_key/document.rs b/sec1/src/private_key/document.rs index ab5f8ea3a..48e8cb487 100644 --- a/sec1/src/private_key/document.rs +++ b/sec1/src/private_key/document.rs @@ -14,7 +14,7 @@ use { }; #[cfg(feature = "std")] -use std::{path::Path, str}; +use std::path::Path; /// SEC1 `EC PRIVATE KEY` document. /// diff --git a/sec1/src/traits.rs b/sec1/src/traits.rs index b8f8cbce2..56e249d62 100644 --- a/sec1/src/traits.rs +++ b/sec1/src/traits.rs @@ -20,7 +20,7 @@ use der::Document; #[cfg(feature = "std")] use std::path::Path; -#[cfg(any(feature = "pem", feature = "std"))] +#[cfg(feature = "pem")] use zeroize::Zeroizing; /// Parse an [`EcPrivateKey`] from a SEC1-encoded document. diff --git a/spki/Cargo.toml b/spki/Cargo.toml index cd2ec59c9..6ac8e988c 100644 --- a/spki/Cargo.toml +++ b/spki/Cargo.toml @@ -28,7 +28,7 @@ hex-literal = "0.3" alloc = ["base64ct/alloc", "der/alloc"] fingerprint = ["sha2"] pem = ["alloc", "der/pem"] -std = ["der/std"] +std = ["der/std", "alloc"] [package.metadata.docs.rs] all-features = true diff --git a/spki/tests/spki.rs b/spki/tests/spki.rs index 47d1295b0..40e320f1e 100644 --- a/spki/tests/spki.rs +++ b/spki/tests/spki.rs @@ -1,12 +1,12 @@ //! `SubjectPublicKeyInfo` tests. -#[cfg(feature = "alloc")] +#[cfg(all(feature = "alloc", feature = "fingerprint"))] use spki::der::Encodable; #[cfg(feature = "fingerprint")] use {hex_literal::hex, spki::SubjectPublicKeyInfo}; -#[cfg(feature = "pem")] +#[cfg(all(feature = "pem", feature = "fingerprint"))] use spki::{der::Document, EncodePublicKey, PublicKeyDocument}; #[cfg(feature = "fingerprint")] @@ -15,7 +15,7 @@ use spki::{der::Document, EncodePublicKey, PublicKeyDocument}; const ED25519_DER_EXAMPLE: &[u8] = include_bytes!("examples/ed25519-pub.der"); /// Ed25519 public key encoded as PEM -#[cfg(feature = "pem")] +#[cfg(all(feature = "pem", feature = "fingerprint"))] const ED25519_PEM_EXAMPLE: &str = include_str!("examples/ed25519-pub.pem"); /// The SPKI fingerprint for `ED25519_SPKI_FINGERPRINT` as a Base64 string @@ -31,8 +31,8 @@ const ED25519_SPKI_FINGERPRINT_BASE64: &str = "Vd1MdLDkhTTi9OFzzs61DfjyenrCqomRz const ED25519_SPKI_FINGERPRINT: &[u8] = &hex!("55dd4c74b0e48534e2f4e173ceceb50df8f27a7ac2aa8991cc7ae914e030bced"); -#[cfg(all(feature = "fingerprint", feature = "alloc"))] #[test] +#[cfg(all(feature = "fingerprint", feature = "alloc"))] fn decode_and_base64fingerprint_spki() { // Repeat the decode test from the pkcs8 crate let spki = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap(); @@ -51,8 +51,8 @@ fn decode_and_base64fingerprint_spki() { ); } -#[cfg(feature = "fingerprint")] #[test] +#[cfg(feature = "fingerprint")] fn decode_and_fingerprint_spki() { // Repeat the decode test from the pkcs8 crate let spki = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap(); @@ -72,7 +72,7 @@ fn decode_and_fingerprint_spki() { } #[test] -#[cfg(feature = "pem")] +#[cfg(all(feature = "pem", feature = "fingerprint"))] fn decode_ed25519_pem() { let doc: PublicKeyDocument = ED25519_PEM_EXAMPLE.parse().unwrap(); assert_eq!(doc.as_ref(), ED25519_DER_EXAMPLE); @@ -83,7 +83,7 @@ fn decode_ed25519_pem() { } #[test] -#[cfg(feature = "alloc")] +#[cfg(all(feature = "alloc", feature = "fingerprint"))] fn encode_ed25519_der() { let pk = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap(); let pk_encoded = pk.to_vec().unwrap(); @@ -91,7 +91,7 @@ fn encode_ed25519_der() { } #[test] -#[cfg(feature = "pem")] +#[cfg(all(feature = "pem", feature = "fingerprint"))] fn encode_ed25519_pem() { let pk = SubjectPublicKeyInfo::try_from(ED25519_DER_EXAMPLE).unwrap(); let pk_encoded = PublicKeyDocument::try_from(pk) diff --git a/tls_codec/Cargo.toml b/tls_codec/Cargo.toml index 12bd1b7b6..8f3461de8 100644 --- a/tls_codec/Cargo.toml +++ b/tls_codec/Cargo.toml @@ -23,7 +23,7 @@ criterion = "0.3" [features] default = [ "std" ] derive = [ "std", "tls_codec_derive" ] -serde_serialize = [ "serde" ] +serde_serialize = [ "std", "serde" ] std = [] [[bench]] diff --git a/tls_codec/src/lib.rs b/tls_codec/src/lib.rs index ac9b18db1..cd3f1eadf 100644 --- a/tls_codec/src/lib.rs +++ b/tls_codec/src/lib.rs @@ -5,6 +5,8 @@ //! ## Usage //! //! ``` +//! # #[cfg(feature = "std")] +//! # { //! use tls_codec::{TlsVecU8, Serialize, Deserialize}; //! let mut b = &[1u8, 4, 77, 88, 1, 99] as &[u8]; //! @@ -13,6 +15,7 @@ //! println!("b: {:?}", b); //! let v = TlsVecU8::::tls_deserialize(&mut b).expect("Unable to tls_deserialize"); //! assert_eq!(&[77, 88, 1, 99], v.as_slice()); +//! # } //! ``` #[cfg_attr(feature = "std", macro_use)] diff --git a/tls_codec/tests/decode.rs b/tls_codec/tests/decode.rs index a9173ef9d..a12143e41 100644 --- a/tls_codec/tests/decode.rs +++ b/tls_codec/tests/decode.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "std")] + use tls_codec::{ Deserialize, Serialize, Size, TlsByteSliceU16, TlsByteVecU16, TlsByteVecU8, TlsSliceU16, TlsVecU16, TlsVecU32, TlsVecU8, diff --git a/tls_codec/tests/encode.rs b/tls_codec/tests/encode.rs index df0da8753..af0924482 100644 --- a/tls_codec/tests/encode.rs +++ b/tls_codec/tests/encode.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "std")] + use tls_codec::{Serialize, TlsVecU16}; #[test]