diff options
author | David Drysdale <drysdale@google.com> | 2022-10-07 17:01:33 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-10-07 17:01:33 +0000 |
commit | 51c0e427bd4636be935f04762aeec77cb0d500c1 (patch) | |
tree | 01fc097cd8651c4019270699e96483c600138b54 | |
parent | 84fbcac1e7458579352df11673b8aa78cdf40478 (diff) | |
parent | 38ca0b392b2c1db56e43083323a55b5f4c121f5e (diff) | |
download | coset-51c0e427bd4636be935f04762aeec77cb0d500c1.tar.gz |
Import upstream 0.3.3 am: e6c94ad233 am: 38ca0b392b
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/coset/+/2239156
Change-Id: Id48026d55e6f38bf7e53d4bc02eca0ab369f086a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 3 | ||||
-rw-r--r-- | Android.bp | 2 | ||||
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 3 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | src/key/mod.rs | 16 | ||||
-rw-r--r-- | src/key/tests.rs | 27 |
10 files changed, 58 insertions, 11 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index badef4a..505822c 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "1c107ab343537ec70c4786948c386ba7eee1188a" + "sha1": "1f265f2dd6ef6fa855dedfe185bf3ad19f05d755" }, "path_in_vcs": "" }
\ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e9ee3f..66d1a3f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: toolchain: ${{ matrix.rust }} components: rustfmt override: true - - run: for eg in `ls examples/*.rs | xargs basename --suffix=.rs`; do cargo run --example ${eg}; done + - run: cargo test --examples no_std: name: Build for a no_std target @@ -195,6 +195,7 @@ jobs: - uses: actions-rs/install@69ec87709ffb5b19a7b5ddbf610cb221498bb1eb # v0.1.2 with: crate: cargo-tarpaulin + version: 0.20.1 use-tool-cache: true - run: cargo tarpaulin --verbose --ignore-tests --all-features --timeout=600 --out Xml - name: Upload to codecov.io @@ -23,7 +23,7 @@ rust_library { host_supported: true, crate_name: "coset", cargo_env_compat: true, - cargo_pkg_version: "0.3.2", + cargo_pkg_version: "0.3.3", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ diff --git a/CHANGELOG.md b/CHANGELOG.md index a3657e5..087c02d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 0.3.3 - 2022-09-30 + +- Add `CoseKeyBuilder` methods `kty`, `key_type` and `new_okp_key`. + ## 0.3.2 - 2022-04-02 - Add basic [CWT](https://datatracker.ietf.org/doc/html/rfc8392) support in `cwt` module, via the `ClaimsSet` type. @@ -31,7 +31,7 @@ dependencies = [ [[package]] name = "coset" -version = "0.3.2" +version = "0.3.3" dependencies = [ "ciborium", "ciborium-io", @@ -12,12 +12,13 @@ [package] edition = "2018" name = "coset" -version = "0.3.2" +version = "0.3.3" authors = [ "David Drysdale <drysdale@google.com>", "Paul Crowley <paulcrowley@google.com>", ] description = "Set of types for supporting COSE" +readme = "README.md" keywords = [ "cryptography", "cose", diff --git a/Cargo.toml.orig b/Cargo.toml.orig index fe96fe2..5544745 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "coset" -version = "0.3.2" +version = "0.3.3" authors = ["David Drysdale <drysdale@google.com>", "Paul Crowley <paulcrowley@google.com>"] edition = "2018" license = "Apache-2.0" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/coset/coset-0.3.2.crate" + value: "https://static.crates.io/crates/coset/coset-0.3.3.crate" } - version: "0.3.2" + version: "0.3.3" license_type: NOTICE last_upgrade_date { year: 2022 - month: 6 - day: 28 + month: 10 + day: 6 } } diff --git a/src/key/mod.rs b/src/key/mod.rs index b81ea8c..07ee7a7 100644 --- a/src/key/mod.rs +++ b/src/key/mod.rs @@ -183,6 +183,7 @@ pub struct CoseKeyBuilder(CoseKey); impl CoseKeyBuilder { builder! {CoseKey} + builder_set! {kty: KeyType} builder_set! {key_id: Vec<u8>} builder_set! {base_iv: Vec<u8>} @@ -250,6 +251,21 @@ impl CoseKeyBuilder { }) } + /// Constructor for a octet keypair key. + pub fn new_okp_key() -> Self { + Self(CoseKey { + kty: KeyType::Assigned(iana::KeyType::OKP), + ..Default::default() + }) + } + + /// Set the key type. + #[must_use] + pub fn key_type(mut self, key_type: iana::KeyType) -> Self { + self.0.kty = KeyType::Assigned(key_type); + self + } + /// Set the algorithm. #[must_use] pub fn algorithm(mut self, alg: iana::Algorithm) -> Self { diff --git a/src/key/tests.rs b/src/key/tests.rs index 713fe1a..45f8eef 100644 --- a/src/key/tests.rs +++ b/src/key/tests.rs @@ -16,7 +16,7 @@ use super::*; use crate::{cbor::value::Value, iana, util::expect_err, CborSerializable}; -use alloc::{borrow::ToOwned, vec}; +use alloc::{borrow::ToOwned, string::ToString, vec}; #[test] fn test_cose_key_encode() { @@ -702,6 +702,31 @@ fn test_key_builder() { ..Default::default() }, ), + ( + CoseKeyBuilder::new_okp_key().build(), + CoseKey { + kty: KeyType::Assigned(iana::KeyType::OKP), + ..Default::default() + }, + ), + ( + CoseKeyBuilder::new() + .key_type(iana::KeyType::WalnutDSA) + .build(), + CoseKey { + kty: KeyType::Assigned(iana::KeyType::WalnutDSA), + ..Default::default() + }, + ), + ( + CoseKeyBuilder::new() + .kty(KeyType::Text("test".to_string())) + .build(), + CoseKey { + kty: KeyType::Text("test".to_string()), + ..Default::default() + }, + ), ]; for (got, want) in tests { assert_eq!(got, want); |