Struct CoseHeader

Source
pub struct CoseHeader {
Show 30 fields pub protected: Vec<i32>, pub unprotected: Vec<i32>, pub alg: Option<i32>, pub crit: Vec<i32>, pub content_type: Option<ContentTypeTypes>, pub kid: Option<Vec<u8>>, pub iv: Option<Vec<u8>>, pub partial_iv: Option<Vec<u8>>, pub salt: Option<Vec<u8>>, pub counters: Vec<CoseAgent>, pub party_u_identity: Option<Vec<u8>>, pub party_u_nonce: Option<Vec<u8>>, pub party_u_other: Option<Vec<u8>>, pub party_v_identity: Option<Vec<u8>>, pub party_v_nonce: Option<Vec<u8>>, pub party_v_other: Option<Vec<u8>>, pub pub_other: Option<Vec<u8>>, pub priv_info: Option<Vec<u8>>, pub ecdh_key: CoseKey, pub static_kid: Option<Vec<u8>>, pub x5bag: Option<Vec<Vec<u8>>>, pub x5chain: Option<Vec<Vec<u8>>>, pub x5t: Option<Vec<u8>>, pub x5t_alg: Option<i32>, pub x5u: Option<String>, pub x5t_sender: Option<Vec<u8>>, pub x5t_sender_alg: Option<i32>, pub x5u_sender: Option<String>, pub x5chain_sender: Option<Vec<Vec<u8>>>, pub x5_private: Vec<u8>, /* private fields */
}
Expand description

Structure for COSE message headers.

Fields§

§protected: Vec<i32>

List of labels to be included in the protected header.

§unprotected: Vec<i32>

List of labels to be included in the unprotected header.

§alg: Option<i32>

COSE Algorithm.

§crit: Vec<i32>

List of critical header labels.

§content_type: Option<ContentTypeTypes>

COSE content-type.

§kid: Option<Vec<u8>>

COSE Key ID.

§iv: Option<Vec<u8>>

Initialization Vector.

§partial_iv: Option<Vec<u8>>

Partial Initialization Vector.

§salt: Option<Vec<u8>>

Salt for the key agreement algorithms.

§counters: Vec<CoseAgent>

List of COSE counter signatures.

§party_u_identity: Option<Vec<u8>>

PartyU identity for key agreement.

§party_u_nonce: Option<Vec<u8>>

PartyU nonce for key agreement.

§party_u_other: Option<Vec<u8>>

PartyU other information for key agreement.

§party_v_identity: Option<Vec<u8>>

PartyV identity for key agreement.

§party_v_nonce: Option<Vec<u8>>

PartyV nonce for key agreement.

§party_v_other: Option<Vec<u8>>

PartyV other information for key agreement.

§pub_other: Option<Vec<u8>>

SuppPubInfo other

§priv_info: Option<Vec<u8>>

SuppPrivInfo

§ecdh_key: CoseKey

ECDH key of the message sender.

§static_kid: Option<Vec<u8>>

Static COSE ECDH key ID of the message sender.

§x5bag: Option<Vec<Vec<u8>>>

X509 bag of certificates.

§x5chain: Option<Vec<Vec<u8>>>

X509 chain of certificates.

§x5t: Option<Vec<u8>>

End-entity x509 thumbprint.

§x5t_alg: Option<i32>

End-entity x509 thumbprint Hash algorithm.

§x5u: Option<String>

X509 URI.

§x5t_sender: Option<Vec<u8>>

x509 sender ECDH thumbprint.

§x5t_sender_alg: Option<i32>

x509 sender ECDH thumbprint algorithm.

§x5u_sender: Option<String>

X509 ECDH sender URI.

§x5chain_sender: Option<Vec<Vec<u8>>>

x509 chain of certificates sender ECDH.

§x5_private: Vec<u8>

x509 private key.

Implementations§

Source§

impl CoseHeader

Source

pub fn new() -> CoseHeader

Creates empty CoseHeader structure.

Source

pub fn alg(&mut self, alg: i32, prot: bool, crit: bool)

Adds algorithm to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn kid(&mut self, kid: Vec<u8>, prot: bool, crit: bool)

Adds Key ID to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn iv(&mut self, iv: Vec<u8>, prot: bool, crit: bool)

Adds Initialization Vector to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn partial_iv(&mut self, partial_iv: Vec<u8>, prot: bool, crit: bool)

Adds Partial Initialization Vector to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn salt(&mut self, salt: Vec<u8>, prot: bool, crit: bool)

Adds salt to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn content_type( &mut self, content_type: ContentTypeTypes, prot: bool, crit: bool, )

Adds content-type to the header, this can either be a text string or u32.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn party_identity( &mut self, identity: Vec<u8>, prot: bool, crit: bool, u: bool, )

Adds a Party identity to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn party_nonce(&mut self, nonce: Vec<u8>, prot: bool, crit: bool, u: bool)

Adds a Party nonce to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn party_other(&mut self, other: Vec<u8>, prot: bool, crit: bool, u: bool)

Adds a Party Other information to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn pub_other(&mut self, other: Vec<u8>)

Adds other to SuppPubInfo to the message.

Source

pub fn priv_info(&mut self, info: Vec<u8>)

Adds SuppPrivInfo to the message.

Source

pub fn x5bag(&mut self, x5bag: Vec<Vec<u8>>, prot: bool, crit: bool)

Adds a X509 bag of certificates.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5chain(&mut self, x5chain: Vec<Vec<u8>>, prot: bool, crit: bool)

Adds a X509 chain of certificates.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5u(&mut self, x5u: String, prot: bool, crit: bool)

Adds a X509 certificate URI.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5chain_sender(&mut self, x5chain: Vec<Vec<u8>>, prot: bool, crit: bool)

Adds sender X509 chain of certificates for ECDH.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5t( &mut self, x5: Vec<u8>, alg: i32, prot: bool, crit: bool, ) -> CoseResult

Compute and add X509 thumbprint, by providing x509 certificate and the algorithm ID to be used.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5_private(&mut self, x5: Vec<u8>)

Adds sender X509 private key in DER format, to be used when encoding a message with ECDH.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5t_sender( &mut self, x5: Vec<u8>, alg: i32, prot: bool, crit: bool, ) -> CoseResult

Compute and add X509 sender thumbprint for ECDH, by providing x509 certificate and the algorithm ID to be used.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn x5u_sender(&mut self, x5u: String, prot: bool, crit: bool)

Adds sender X509 certificate URI.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label. u parameter is used to specify if this is for PartyU or not (PartyV).

Source

pub fn ephemeral_key(&mut self, key: CoseKey, prot: bool, crit: bool)

Adds an Ephemeral ECDH COSE Key to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn static_key(&mut self, key: CoseKey, prot: bool, crit: bool)

Adds an Static ECDH COSE Key to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn static_key_id( &mut self, kid: Vec<u8>, key: CoseKey, prot: bool, crit: bool, )

Adds an Static ECDH COSE Key ID to the header.

prot parameter is used to specify if it is to be included in protected header or not. crit parameter is used to specify if this is a critical label.

Source

pub fn ecdh_key(&mut self, key: CoseKey)

Adds an ECDH COSE Key to the header structure (It will not be included in encoding).

This is meant to be used when decoding a message that uses static kid.

Source

pub fn get_counter(&self, kid: &Vec<u8>) -> CoseResultWithRet<Vec<usize>>

Method that returns a copy of all counter signatures with the key ID provided

Trait Implementations§

Source§

impl Clone for CoseHeader

Source§

fn clone(&self) -> CoseHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V