pub struct CoseKey {
pub kty: RegisteredLabel<KeyType>,
pub key_id: Vec<u8>,
pub alg: Option<RegisteredLabelWithPrivate<Algorithm>>,
pub key_ops: BTreeSet<RegisteredLabel<KeyOperation>>,
pub base_iv: Vec<u8>,
pub params: Vec<(Label, Value)>,
}Expand description
Structure representing a cryptographic key.
COSE_Key = {
1 => tstr / int, ; kty
? 2 => bstr, ; kid
? 3 => tstr / int, ; alg
? 4 => [+ (tstr / int) ], ; key_ops
? 5 => bstr, ; Base IV
* label => values
}Fields§
§kty: RegisteredLabel<KeyType>Key type identification.
key_id: Vec<u8>Key identification.
alg: Option<RegisteredLabelWithPrivate<Algorithm>>Key use restriction to this algorithm.
key_ops: BTreeSet<RegisteredLabel<KeyOperation>>Restrict set of possible operations.
base_iv: Vec<u8>Base IV to be xor-ed with partial IVs.
params: Vec<(Label, Value)>Any additional parameter (label,value) pairs. If duplicate labels are present, CBOR-encoding will fail.
Implementations§
Source§impl CoseKey
impl CoseKey
Sourcepub fn canonicalize(&mut self, ordering: CborOrdering)
pub fn canonicalize(&mut self, ordering: CborOrdering)
Re-order the contents of the key so that the contents will be emitted in one of the standard CBOR sorted orders.
Trait Implementations§
Source§impl AsCborValue for CoseKey
impl AsCborValue for CoseKey
Source§impl CborSerializable for CoseKey
impl CborSerializable for CoseKey
Source§impl CoseKeyDecode for CoseKey
impl CoseKeyDecode for CoseKey
Source§fn decode_public(&self) -> Result<PublicKey, KeyDecodingError>
fn decode_public(&self) -> Result<PublicKey, KeyDecodingError>
Decodes the COSE key as a public key.
Source§fn decode_secret(&self) -> Result<SecretKey, KeyDecodingError>
fn decode_secret(&self) -> Result<SecretKey, KeyDecodingError>
Decodes the COSE key as a secret key.
Source§fn require_param(&self, label: &Label) -> Result<&Value, KeyDecodingError>
fn require_param(&self, label: &Label) -> Result<&Value, KeyDecodingError>
Requires the given key parameter. Read more
Source§fn parse_required_param<'a, T>(
&'a self,
label: &Label,
f: impl FnOnce(&'a Value) -> Option<T>,
) -> Result<T, KeyDecodingError>
fn parse_required_param<'a, T>( &'a self, label: &Label, f: impl FnOnce(&'a Value) -> Option<T>, ) -> Result<T, KeyDecodingError>
Requires and parses the given key parameter. Read more
Source§impl CoseKeyEncode for CoseKey
impl CoseKeyEncode for CoseKey
fn encode_public(key: &PublicKey) -> Result<Self, KeyEncodingError>
fn encode_secret(key: &SecretKey) -> Result<Self, KeyEncodingError>
fn encode_public_with_id( key: &PublicKey, id: Vec<u8>, ) -> Result<CoseKey, KeyEncodingError>
fn encode_secret_with_id( key: &SecretKey, id: Vec<u8>, ) -> Result<CoseKey, KeyEncodingError>
Source§impl CoseKeyGenerate for CoseKey
impl CoseKeyGenerate for CoseKey
fn generate_p256() -> Self
fn generate_p256_from(rng: &mut (impl RngCore + CryptoRng)) -> Self
Source§impl CoseKeyResolver for CoseKey
impl CoseKeyResolver for CoseKey
Source§async fn fetch_public_cose_key(
&self,
_id: Option<&[u8]>,
) -> Result<Cow<'_, CoseKey>, ProofValidationError>
async fn fetch_public_cose_key( &self, _id: Option<&[u8]>, ) -> Result<Cow<'_, CoseKey>, ProofValidationError>
Fetches the COSE key associated to the give identifier.
Source§impl CoseSigner for CoseKey
impl CoseSigner for CoseKey
Source§async fn fetch_info(&self) -> Result<CoseSignerInfo, SignatureError>
async fn fetch_info(&self) -> Result<CoseSignerInfo, SignatureError>
Fetches the information about the signing key. Read more
Source§async fn sign_bytes(
&self,
signing_bytes: &[u8],
) -> Result<Vec<u8>, SignatureError>
async fn sign_bytes( &self, signing_bytes: &[u8], ) -> Result<Vec<u8>, SignatureError>
Signs the given bytes.
Source§async fn sign(
&self,
payload: &(impl ?Sized + CosePayload),
additional_data: Option<&[u8]>,
tagged: bool,
) -> Result<CoseSign1BytesBuf, SignatureError>
async fn sign( &self, payload: &(impl ?Sized + CosePayload), additional_data: Option<&[u8]>, tagged: bool, ) -> Result<CoseSign1BytesBuf, SignatureError>
Signs the given payload. Read more
impl StructuralPartialEq for CoseKey
Auto Trait Implementations§
impl Freeze for CoseKey
impl RefUnwindSafe for CoseKey
impl Send for CoseKey
impl Sync for CoseKey
impl Unpin for CoseKey
impl UnwindSafe for CoseKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
Returns a reference to the resource of type
T.