aboutsummaryrefslogtreecommitdiff
path: root/src/key/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/key/mod.rs')
-rw-r--r--src/key/mod.rs16
1 files changed, 16 insertions, 0 deletions
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 {