Struct aws_nitro_enclaves_cose::sign::SigStructure

source ·
pub struct SigStructure(/* private fields */);
Expand description

Implementation of the Sig_structure as defined in RFC8152.

In order to create a signature, a well-defined byte stream is needed. The Sig_structure is used to create the canonical form. This signing and verification process takes in the body information (COSE_Sign or COSE_Sign1), the signer information (COSE_Signature), and the application data (external source). A Sig_structure is a CBOR array. The fields of the Sig_structure in order are:

  1. A text string identifying the context of the signature. The context string is:

    “Signature” for signatures using the COSE_Signature structure.

    “Signature1” for signatures using the COSE_Sign1 structure.

    “CounterSignature” for signatures used as counter signature attributes.

  2. The protected attributes from the body structure encoded in a bstr type. If there are no protected attributes, a bstr of length zero is used.

  3. The protected attributes from the signer structure encoded in a bstr type. If there are no protected attributes, a bstr of length zero is used. This field is omitted for the COSE_Sign1 signature structure.

  4. The protected attributes from the application encoded in a bstr type. If this field is not supplied, it defaults to a zero- length binary string. (See Section 4.3 for application guidance on constructing this field.)

  5. The payload to be signed encoded in a bstr type. The payload is placed here independent of how it is transported.

Note: A struct serializes to a map, while a tuple serializes to an array, which is why this struct is actually a tuple Note: This structure only needs to be serializable, since it’s used for generating a signature and not transported anywhere. Both sides need to generate it independently.

Implementations§

source§

impl SigStructure

source

pub fn new_sign1( body_protected: &[u8], payload: &[u8] ) -> Result<Self, CborError>

Takes the protected field of the COSE_Sign object and a raw slice of bytes as payload and creates a SigStructure for one signer from it

source

pub fn new_sign1_cbor_value( body_protected: &[u8], payload: &CborValue ) -> Result<Self, CborError>

Takes the protected field of the COSE_Sign object and a CborValue as payload and creates a SigStructure for one signer from it

source

pub fn as_bytes(&self) -> Result<Vec<u8>, CborError>

Serializes the SigStructure to . We don’t care about deserialization, since both sides are supposed to compute the SigStructure and compare.

Trait Implementations§

source§

impl Clone for SigStructure

source§

fn clone(&self) -> SigStructure

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for SigStructure

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Serialize for SigStructure

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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,

§

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>,

§

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>,

§

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.