diff --git a/.github/workflows/ecdsa.yml b/.github/workflows/ecdsa.yml new file mode 100644 index 0000000..38788fa --- /dev/null +++ b/.github/workflows/ecdsa.yml @@ -0,0 +1,111 @@ +name: ecdsa +on: + pull_request: + paths: + - "ecdsa/**" + - "Cargo.*" + push: + branches: master + paths: + - "ecdsa/**" + - "Cargo.*" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - thumbv7em-none-eabi + - wasm32-unknown-unknown + toolchain: + - 1.40.0 # MSRV + - stable + steps: + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-rust-${{ matrix.toolchain }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('Cargo.lock') }} + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + target: ${{ matrix.target }} + toolchain: ${{ matrix.toolchain }} + override: true + + - name: Run cargo build --no-default-features + working-directory: ecdsa + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + run: cargo build --no-default-features --release --target ${{ matrix.target }} + + test: + strategy: + matrix: + platform: + - ubuntu-latest + - macos-latest + - windows-latest + toolchain: + - 1.40.0 # MSRV + - stable + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-rust-${{ matrix.toolchain }}-cargo-build-target-${{ hashFiles('Cargo.lock') }} + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + + - name: Run cargo test --lib + working-directory: ecdsa + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + run: cargo test --lib --release + + - name: Run cargo test --all-features + working-directory: ecdsa + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + run: cargo test --all-features --release diff --git a/.github/workflows/ed25519.yml b/.github/workflows/ed25519.yml new file mode 100644 index 0000000..e6231f9 --- /dev/null +++ b/.github/workflows/ed25519.yml @@ -0,0 +1,111 @@ +name: ed25519 +on: + pull_request: + paths: + - "ed25519/**" + - "Cargo.*" + push: + branches: master + paths: + - "ed25519/**" + - "Cargo.*" + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + target: + - thumbv7em-none-eabi + - wasm32-unknown-unknown + toolchain: + - 1.40.0 # MSRV + - stable + steps: + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-rust-${{ matrix.toolchain }}-${{ matrix.target }}-cargo-build-target-${{ hashFiles('Cargo.lock') }} + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + target: ${{ matrix.target }} + toolchain: ${{ matrix.toolchain }} + override: true + + - name: Run cargo build --no-default-features + working-directory: ed25519 + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + run: cargo build --no-default-features --release --target ${{ matrix.target }} + + test: + strategy: + matrix: + platform: + - ubuntu-latest + - macos-latest + - windows-latest + toolchain: + - 1.40.0 # MSRV + - stable + runs-on: ${{ matrix.platform }} + steps: + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-rust-${{ matrix.toolchain }}-cargo-build-target-${{ hashFiles('Cargo.lock') }} + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.toolchain }} + override: true + + - name: Run cargo test --lib + working-directory: ed25519 + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + run: cargo test --lib --release + + - name: Run cargo test --all-features + working-directory: ed25519 + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -D warnings + run: cargo test --all-features --release diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml new file mode 100644 index 0000000..373efc4 --- /dev/null +++ b/.github/workflows/security-audit.yml @@ -0,0 +1,24 @@ +name: Security Audit +on: + pull_request: + paths: Cargo.lock + push: + branches: develop + paths: Cargo.lock + schedule: + - cron: '0 0 * * *' + +jobs: + security_audit: + name: Security Audit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Cache cargo bin + uses: actions/cache@v1 + with: + path: ~/.cargo/bin + key: ${{ runner.os }}-cargo-audit-v0.11.2 + - uses: actions-rs/audit-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml new file mode 100644 index 0000000..e090d25 --- /dev/null +++ b/.github/workflows/workspace.yml @@ -0,0 +1,88 @@ +name: Workspace +on: + pull_request: + paths-ignore: + - README.md + push: + branches: master + paths-ignore: + - README.md + +jobs: + rustfmt: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v1 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt + + - name: Run cargo fmt + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: clippy + - run: cargo clippy --all-features -- -D warnings + + codecov: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-coverage-cargo-build-target-${{ hashFiles('Cargo.lock') }} + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Run cargo-tarpaulin + uses: actions-rs/tarpaulin@v0.1 + env: + CARGO_INCREMENTAL: 0 + with: + version: 0.11.0 + args: --all --exclude armistice_usbarmory -- --test-threads 1 + + - name: Upload to codecov.io + uses: codecov/codecov-action@v1.0.2 + with: + token: ${{secrets.CODECOV_TOKEN}} + + - name: Archive code coverage results + uses: actions/upload-artifact@v1 + with: + name: code-coverage-report + path: cobertura.xml diff --git a/.gitignore b/.gitignore index 4c1bf0e..c6262ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -Cargo.lock target -*.sw* +*.swp diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d2b8355..0000000 --- a/.travis.yml +++ /dev/null @@ -1,44 +0,0 @@ -language: rust -cache: cargo - -rust: - - 1.37.0 - - stable - - beta - - nightly - -env: - global: - - RUSTFLAGS="-D warnings" - -script: - - cargo test --verbose --release - - cargo test --verbose --all-features --release - -matrix: - fast_finish: true - allow_failures: - - rust: nightly - include: - - name: "Rust: stable (thumbv7em-none-eabihf)" - rust: stable - install: rustup target add thumbv7em-none-eabi - script: ./build_nostd.sh - - name: "Rust: stable (wasm32-unknown-unknown)" - rust: stable - install: rustup target add wasm32-unknown-unknown - script: ./build_wasm.sh - - name: rustfmt - rust: stable - install: rustup component add rustfmt - script: cargo fmt --all -- --check - - name: clippy - install: rustup component add clippy - rust: stable - script: cargo clippy --all - - name: docs - script: cargo doc --all --no-deps - -branches: - only: - - master diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..b9277f7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,198 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ecdsa" +version = "0.5.0-pre" +dependencies = [ + "elliptic-curve", + "generic-array", + "k256", + "p256", + "p384", + "sha2", + "signature", +] + +[[package]] +name = "ed25519" +version = "1.0.0-pre.2" +dependencies = [ + "serde", + "signature", +] + +[[package]] +name = "elliptic-curve" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01f69be7d1feb7a7a04f158aaf32c7deaa7604e9bd58145525e536438c4e5096" +dependencies = [ + "generic-array", + "getrandom", + "subtle", + "zeroize", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "k256" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4407bc616f76afb6bccd8a813b86fe622752b15b43c5e60fec94d21af2393a72" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "libc" +version = "0.2.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb147597cdf94ed43ab7a9038716637d2d1bf2bc571da995d0028dec06bd3018" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "p256" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812a058a5afc96a52a8ab6e250325d025254ff030ff737dc5b62576e4e604c42" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "p384" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3aee0d9bdeedaea6cdd47f9281a9f8e1037d3037088b70e2af13c64ce65608ec" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "serde" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" + +[[package]] +name = "sha2" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +dependencies = [ + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", +] + +[[package]] +name = "signature" +version = "1.0.0-pre.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7633506bfb9bb78fd228f8fa51d46802fc72fe642e707b42a64f57b07eaf8fb8" +dependencies = [ + "digest", +] + +[[package]] +name = "subtle" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c65d530b10ccaeac294f349038a597e435b18fb456aadd0840a623f83b9e941" + +[[package]] +name = "typenum" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "zeroize" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbac2ed2ba24cc90f5e06485ac8c7c1e5449fe8911aef4d8877218af021a5b8" diff --git a/README.md b/README.md index daad745..0c556fe 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@ -# RustCrypto: signatures - -[![Build Status][build-image]][build-link] -[![Dependency Status][deps-image]][deps-link] -![Rust Version][rustc-image] +# RustCrypto: signatures [![Dependency Status][deps-image]][deps-link] ![Rust Version][rustc-image] Support for [digital signatures][1], which provide authentication of data using public-key cryptography. @@ -22,7 +18,7 @@ and can be easily used for bare-metal or lightweight WebAssembly programming. ## Minimum Supported Rust Version -All crates in this repository support Rust **1.37** or higher. In future minimum +All crates in this repository support Rust **1.40** or higher. In future minimum supported Rust version can be changed, but it will be done with the minor version bump. @@ -48,11 +44,9 @@ dual licensed as above, without any additional terms or conditions. [//]: # (badges) -[build-image]: https://travis-ci.org/RustCrypto/signatures.svg?branch=master -[build-link]: https://travis-ci.org/RustCrypto/signatures [deps-image]: https://deps.rs/repo/github/RustCrypto/signatures/status.svg [deps-link]: https://deps.rs/repo/github/RustCrypto/signatures -[rustc-image]: https://img.shields.io/badge/rustc-1.37+-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.40+-blue.svg [//]: # (general links) diff --git a/build_nostd.sh b/build_nostd.sh deleted file mode 100755 index 4483949..0000000 --- a/build_nostd.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -set -eux - -# Due to the fact that cargo does not disable default features when we use -# cargo build --all --no-default-features we have to explicitly iterate over -# all crates (see https://github.com/rust-lang/cargo/issues/4753 ) -DIRS=`ls -d */` -TARGET="thumbv7em-none-eabi" - -for dir in $DIRS; do - if [ $dir = "target/" ] - then - continue - fi - cd $dir - cargo build --no-default-features --verbose --target $TARGET --release || { - echo $dir failed - exit 1 - } - cd - -done diff --git a/build_wasm.sh b/build_wasm.sh deleted file mode 100755 index 811d7ad..0000000 --- a/build_wasm.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -set -eux - -# Due to the fact that cargo does not disable default features when we use -# cargo build --all --no-default-features we have to explicitly iterate over -# all crates (see https://github.com/rust-lang/cargo/issues/4753 ) -DIRS=`ls -d */` -TARGET="wasm32-unknown-unknown" - -for dir in $DIRS; do - if [ $dir = "target/" ] - then - continue - fi - cd $dir - cargo build --verbose --target $TARGET --release || { - echo $dir failed - exit 1 - } - cd - -done diff --git a/ecdsa/README.md b/ecdsa/README.md index 140fd91..a93bc57 100644 --- a/ecdsa/README.md +++ b/ecdsa/README.md @@ -24,7 +24,7 @@ ECDSA implementations, including HSMs or Cloud KMS services. ## Requirements -- Rust **1.37+** +- Rust **1.40+** ## License @@ -48,9 +48,9 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/ecdsa/badge.svg [docs-link]: https://docs.rs/ecdsa/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.37+-blue.svg -[build-image]: https://travis-ci.org/RustCrypto/signatures.svg?branch=master -[build-link]: https://travis-ci.org/RustCrypto/signatures +[rustc-image]: https://img.shields.io/badge/rustc-1.40+-blue.svg +[build-image]: https://github.com/RustCrypto/signatures/workflows/ecdsa/badge.svg?branch=master&event=push +[build-link]: https://github.com/RustCrypto/signatures/actions [//]: # (general links) diff --git a/ed25519/README.md b/ed25519/README.md index 530a350..9076be0 100644 --- a/ed25519/README.md +++ b/ed25519/README.md @@ -23,7 +23,7 @@ Ed25519 implementations, including HSMs or Cloud KMS services. ## Requirements -- Rust **1.37+** +- Rust **1.40+** ## License @@ -47,9 +47,9 @@ dual licensed as above, without any additional terms or conditions. [docs-image]: https://docs.rs/ed25519/badge.svg [docs-link]: https://docs.rs/ed25519/ [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg -[rustc-image]: https://img.shields.io/badge/rustc-1.37+-blue.svg -[build-image]: https://travis-ci.org/RustCrypto/signatures.svg?branch=master -[build-link]: https://travis-ci.org/RustCrypto/signatures +[rustc-image]: https://img.shields.io/badge/rustc-1.40+-blue.svg +[build-image]: https://github.com/RustCrypto/signatures/workflows/ed25519/badge.svg?branch=master&event=push +[build-link]: https://github.com/RustCrypto/signatures/actions [//]: # (general links) diff --git a/ed25519/src/lib.rs b/ed25519/src/lib.rs index d52d99e..bdae794 100644 --- a/ed25519/src/lib.rs +++ b/ed25519/src/lib.rs @@ -65,15 +65,16 @@ impl AsRef<[u8]> for Signature { // can't derive `Debug`, `PartialEq`, or `Eq` below because core array types // only have trait implementations for lengths 0..=32 -// TODO(tarcieri): derive `PartialEq` and `Eq` after const generics are available impl Debug for Signature { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "ed25519::Signature({:?})", &self.0[..]) } } +// TODO(tarcieri): derive `Eq` after const generics are available impl Eq for Signature {} +// TODO(tarcieri): derive `PartialEq` after const generics are available impl PartialEq for Signature { fn eq(&self, other: &Self) -> bool { self.as_ref().eq(other.as_ref()) @@ -140,8 +141,8 @@ impl<'de> Deserialize<'de> for Signature { use de::Error; let mut arr = [0u8; SIGNATURE_LENGTH]; - for i in 0..SIGNATURE_LENGTH { - arr[i] = seq + for (i, byte) in arr.iter_mut().enumerate() { + *byte = seq .next_element()? .ok_or_else(|| Error::invalid_length(i, &self))?; }