pub fn sign_data(&mut self, data: &[u8], alg: AlgorithmId, slot: &SlotId) -> Result<Vec<u8>> {
        let (slot_alg, hash_alg) = match self.configured(slot) {
            Ok(PublicKeyInfo::EcP256(_)) => (AlgorithmId::EccP256, &digest::SHA256),
            Ok(PublicKeyInfo::EcP384(_)) => (AlgorithmId::EccP384, &digest::SHA384),
            Ok(_) => (AlgorithmId::Rsa2048, &digest::SHA256), // RSAish
            Err(_) => return Err(Error::Unprovisioned),
        };

        if slot_alg != alg {
            return Err(Error::WrongKeyType);
        }
        let signature = yk_sign_data(&mut self.yk, digest::digest(hash_alg, data).as_ref(), alg, *slot)?;
        Ok(signature.to_vec())
    }
/// Take data, an algorithm, and a slot and attempt to sign the data field
/// 
/// If the requested algorithm doesn't match the key in the slot (or the slot
/// is empty) this will return an error.
Take data, an algorithm, and a slot and attempt to sign the data field
If the requested algorithm doesn't match the key in the slot (or the slot
is empty) this will return an error.
Take data an algorithm and a slot and attempt to sign the data field If the requested algorithm doesn ' t match the key in the slot ( or the slot is empty ) this will return an error .
pub fn sign_data(&mut self, data: &[u8], alg: AlgorithmId, slot: &SlotId) -> Result<Vec<u8>> {
        let (slot_alg, hash_alg) = match self.configured(slot) {
            Ok(PublicKeyInfo::EcP256(_)) => (AlgorithmId::EccP256, &digest::SHA256),
            Ok(PublicKeyInfo::EcP384(_)) => (AlgorithmId::EccP384, &digest::SHA384),
            Ok(_) => (AlgorithmId::Rsa2048, &digest::SHA256), // RSAish
            Err(_) => return Err(Error::Unprovisioned),
        };
        if slot_alg != alg {
            return Err(Error::WrongKeyType);
        }
        let signature = yk_sign_data(&mut self.yk, digest::digest(hash_alg, data).as_ref(), alg, *slot)?;
        Ok(signature.to_vec())
    }
pub fn sign_data ( & mut self , data : & [ u8 ] , alg : AlgorithmId , slot : & SlotId ) -> Result < Vec < u8 > > { let ( slot_alg , hash_alg ) = match self . configured ( slot ) { Ok ( PublicKeyInfo :: EcP256 ( _ ) ) => ( AlgorithmId :: EccP256 , & digest :: SHA256 ) , Ok ( PublicKeyInfo :: EcP384 ( _ ) ) => ( AlgorithmId :: EccP384 , & digest :: SHA384 ) , Ok ( _ ) => ( AlgorithmId :: Rsa2048 , & digest :: SHA256 ) , // RSAish Err ( _ ) => return Err ( Error :: Unprovisioned ) , } ; if slot_alg != alg { return Err ( Error :: WrongKeyType ) ; } let signature = yk_sign_data ( & mut self . yk , digest :: digest ( hash_alg , data ) . as_ref ( ) , alg , * slot ) ? ; Ok ( signature . to_vec ( ) ) }
Take data, an algorithm, and a slot and attempt to sign the data field
If the requested algorithm doesn't match the key in the slot (or the slot
is empty) this will return an error.
Take data an algorithm and a slot and attempt to sign the data field If the requested algorithm doesn ' t match the key in the slot ( or the slot is empty ) this will return an error .
&mut self
data
&[u8]
alg
AlgorithmId
slot
&SlotId