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
impl CoseHeader
Sourcepub fn new() -> CoseHeader
pub fn new() -> CoseHeader
Creates empty CoseHeader structure.
Sourcepub fn alg(&mut self, alg: i32, prot: bool, crit: bool)
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.
Sourcepub fn kid(&mut self, kid: Vec<u8>, prot: bool, crit: bool)
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.
Sourcepub fn iv(&mut self, iv: Vec<u8>, prot: bool, crit: bool)
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.
Sourcepub fn partial_iv(&mut self, partial_iv: Vec<u8>, prot: bool, crit: bool)
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.
Sourcepub fn salt(&mut self, salt: Vec<u8>, prot: bool, crit: bool)
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.
Sourcepub fn content_type(
&mut self,
content_type: ContentTypeTypes,
prot: bool,
crit: bool,
)
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.
Sourcepub fn party_identity(
&mut self,
identity: Vec<u8>,
prot: bool,
crit: bool,
u: bool,
)
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).
Sourcepub fn party_nonce(&mut self, nonce: Vec<u8>, prot: bool, crit: bool, u: bool)
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).
Sourcepub fn party_other(&mut self, other: Vec<u8>, prot: bool, crit: bool, u: bool)
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).
Sourcepub fn x5bag(&mut self, x5bag: Vec<Vec<u8>>, prot: bool, crit: bool)
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).
Sourcepub fn x5chain(&mut self, x5chain: Vec<Vec<u8>>, prot: bool, crit: bool)
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).
Sourcepub fn x5u(&mut self, x5u: String, prot: bool, crit: bool)
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).
Sourcepub fn x5chain_sender(&mut self, x5chain: Vec<Vec<u8>>, prot: bool, crit: bool)
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).
Sourcepub fn x5t(
&mut self,
x5: Vec<u8>,
alg: i32,
prot: bool,
crit: bool,
) -> CoseResult
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).
Sourcepub fn x5_private(&mut self, x5: Vec<u8>)
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).
Sourcepub fn x5t_sender(
&mut self,
x5: Vec<u8>,
alg: i32,
prot: bool,
crit: bool,
) -> CoseResult
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).
Sourcepub fn x5u_sender(&mut self, x5u: String, prot: bool, crit: bool)
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).
Sourcepub fn ephemeral_key(&mut self, key: CoseKey, prot: bool, crit: bool)
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.
Sourcepub fn static_key(&mut self, key: CoseKey, prot: bool, crit: bool)
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.
Sourcepub fn static_key_id(
&mut self,
kid: Vec<u8>,
key: CoseKey,
prot: bool,
crit: bool,
)
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.
Sourcepub fn ecdh_key(&mut self, key: CoseKey)
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.
Sourcepub fn get_counter(&self, kid: &Vec<u8>) -> CoseResultWithRet<Vec<usize>>
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
impl Clone for CoseHeader
Source§fn clone(&self) -> CoseHeader
fn clone(&self) -> CoseHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more