pub trait CoseSignCipher: CoseCipher {
// Required methods
fn sign(
key: &CoseKey,
target: &[u8],
unprotected_header: &Header,
protected_header: &Header,
) -> Vec<u8> ⓘ;
fn verify(
key: &CoseKey,
signature: &[u8],
signed_data: &[u8],
unprotected_header: &Header,
protected_header: &ProtectedHeader,
unprotected_signature_header: Option<&Header>,
protected_signature_header: Option<&ProtectedHeader>,
) -> Result<(), CoseCipherError<Self::Error>>;
}
Expand description
Provides basic operations for signing and verifying COSE structures.
This will be used by sign_access_token
and verify_access_token
(as well as the
equivalents for multiple recipients: sign_access_token_multiple
and
verify_access_token_multiple
) to apply the
corresponding cryptographic operations to the constructed token bytestring.
The set_headers
method can be used to set parameters
this cipher requires to be set.
Required Methods§
Sourcefn sign(
key: &CoseKey,
target: &[u8],
unprotected_header: &Header,
protected_header: &Header,
) -> Vec<u8> ⓘ
fn sign( key: &CoseKey, target: &[u8], unprotected_header: &Header, protected_header: &Header, ) -> Vec<u8> ⓘ
Cryptographically signs the target
value with the key
and returns the signature.
Sourcefn verify(
key: &CoseKey,
signature: &[u8],
signed_data: &[u8],
unprotected_header: &Header,
protected_header: &ProtectedHeader,
unprotected_signature_header: Option<&Header>,
protected_signature_header: Option<&ProtectedHeader>,
) -> Result<(), CoseCipherError<Self::Error>>
fn verify( key: &CoseKey, signature: &[u8], signed_data: &[u8], unprotected_header: &Header, protected_header: &ProtectedHeader, unprotected_signature_header: Option<&Header>, protected_signature_header: Option<&ProtectedHeader>, ) -> Result<(), CoseCipherError<Self::Error>>
Verifies the signature
of the signed_data
with the key
.
Note that, for single recipients (i.e., CoseSign1
),
unprotected_signature_header
and protected_signature_header
will be None
.
For multiple recipients (i.e., CoseSign
), unprotected_signature_header
and
protected_signature_header
will be the headers of the individual signature for this
recipient, whereas unprotected_header
and protected_header
will be the headers
of the CoseSign
structure as a whole.
§Errors
If the signature
is invalid or does not belong to the signed_data
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.