aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Drysdale <drysdale@google.com>2022-10-07 17:01:33 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-10-07 17:01:33 +0000
commit51c0e427bd4636be935f04762aeec77cb0d500c1 (patch)
tree01fc097cd8651c4019270699e96483c600138b54
parent84fbcac1e7458579352df11673b8aa78cdf40478 (diff)
parent38ca0b392b2c1db56e43083323a55b5f4c121f5e (diff)
downloadcoset-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.json2
-rw-r--r--.github/workflows/ci.yml3
-rw-r--r--Android.bp2
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml3
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA8
-rw-r--r--src/key/mod.rs16
-rw-r--r--src/key/tests.rs27
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
diff --git a/Android.bp b/Android.bp
index a50f099..58f6f67 100644
--- a/Android.bp
+++ b/Android.bp
@@ -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.
diff --git a/Cargo.lock b/Cargo.lock
index f7425cf..2a26bd5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -31,7 +31,7 @@ dependencies = [
[[package]]
name = "coset"
-version = "0.3.2"
+version = "0.3.3"
dependencies = [
"ciborium",
"ciborium-io",
diff --git a/Cargo.toml b/Cargo.toml
index f47e6ae..21938e6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/METADATA b/METADATA
index a0d1f4a..969a18f 100644
--- a/METADATA
+++ b/METADATA
@@ -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);