pub fn sign_access_token_multiple<T, RNG>(
keys: Vec<&CoseKey>,
claims: ClaimsSet,
external_aad: Option<&[u8]>,
unprotected_header: Option<Header>,
protected_header: Option<Header>,
rng: RNG,
) -> Result<ByteString, AccessTokenError<T::Error>>Expand description
Signs the given claims with the given headers and external_aad for each recipient
by using the keys with the cipher given by type parameter T,
returning the token as a serialized bytestring of the CoseSign structure.
For each key in keys, another signature will be added, created with that respective key.
The given headers will be used for the CoseSign structure as a whole, not for each
individual signature.
§Errors
- When there’s a
CoseErrorwhile serializing the givenclaimsto CBOR. - When there’s a
CoseErrorwhile serializing theCoseSignstructure. - When the given headers conflict with the headers set by the cipher
T.
§Example
For example, assuming we have a MultipleSignCipher in FakeCrypto,
a random number generator in rng, and some claims, we can then create a token
with signatures for two recipients (with keys key1 and key2, respectively) as follows:
ⓘ
let signed = sign_access_token_multiple::<FakeCrypto, FakeRng>(
vec![&key1, &key2],
claims,
None, None, None,
rng
)?;