pub fn sign(
nethsm: &NetHsm,
key_id: &KeyId,
message: &[u8],
) -> Result<Vec<u8>, Error>Expand description
Generates an OpenPGP signature using a given NetHSM key for the message.
Signs the message message using the key identified by key_id
and returns a binary OpenPGP data signature.
This call requires using a user in the Operator role, which
carries a tag (see add_user_tag) matching one of the tags of
the targeted key (see add_key_tag).
§Namespaces
Operatorusers in a namespace only have access to keys in their own namespace.- System-wide
Operatorusers only have access to system-wide keys.
§Errors
Returns an crate::Error::Api if creating an OpenPGP signature for the hasher state fails:
- the NetHSM is not in
Operationalstate - no key identified by
key_idexists on the NetHSM - the
Operatoruser does not have access to the key (e.g. different namespace) - the
Operatoruser does not carry a tag matching one of the key tags - the used
Credentialsare not correct - the used
Credentialsare not those of a user in theOperatorrole - the certificate for a given key has not been generated or is invalid
- subpacket lengths exceed maximum values
- hashing signed data fails
- signature creation using the NetHSM fails
- constructing OpenPGP signature from parts fails
- writing the signature to vector fails