pub enum TpmHash {
Sha1,
Sha256,
Sha384,
Sha512,
Sm3_256,
Sha3_256,
Sha3_384,
Sha3_512,
Shake128,
Shake256,
Null,
}Expand description
TPM 2.0 hash algorithms.
Variants§
Implementations§
Source§impl TpmHash
impl TpmHash
Sourcepub fn digest(&self, data_chunks: &[&[u8]]) -> Result<Vec<u8>, TpmCryptoError>
pub fn digest(&self, data_chunks: &[&[u8]]) -> Result<Vec<u8>, TpmCryptoError>
Computes a cryptographic digest over a series of data chunks.
§Errors
Returns InvalidHash
when the hash algorithm is not recognized.
Returns OperationFailed
when the digest computation fails.
Returns OutOfMemory when an allocation fails.
Sourcepub fn hmac(
&self,
key: &[u8],
data_chunks: &[&[u8]],
) -> Result<Vec<u8>, TpmCryptoError>
pub fn hmac( &self, key: &[u8], data_chunks: &[&[u8]], ) -> Result<Vec<u8>, TpmCryptoError>
Computes an HMAC digest over a series of data chunks.
§Errors
Returns InvalidHash
when the hash algorithm is not recognized.
Returns KeyIsEmpty when the provided key is empty.
Returns OperationFailed
when the HMAC computation fails.
Returns OutOfMemory when an allocation fails.
Sourcepub fn hmac_verify(
&self,
key: &[u8],
data_chunks: &[&[u8]],
signature: &[u8],
) -> Result<(), TpmCryptoError>
pub fn hmac_verify( &self, key: &[u8], data_chunks: &[&[u8]], signature: &[u8], ) -> Result<(), TpmCryptoError>
Verifies an HMAC signature over a series of data chunks.
§Errors
Returns PermissionDenied
when the HMAC does not match the expected value.
Returns InvalidHash
when the hash algorithm is not recognized.
Returns OperationFailed
when the HMAC computation fails.
Returns OutOfMemory when an allocation fails.
Sourcepub fn kdfa(
&self,
hmac_key: &[u8],
label: &str,
context_a: &[u8],
context_b: &[u8],
key_bits: u16,
) -> Result<Vec<u8>, TpmCryptoError>
pub fn kdfa( &self, hmac_key: &[u8], label: &str, context_a: &[u8], context_b: &[u8], key_bits: u16, ) -> Result<Vec<u8>, TpmCryptoError>
Implements the KDFa key derivation function from the TPM specification.
§Errors
Returns InvalidHash
when the hash algorithm is not recognized.
Returns KeyIsEmpty when the provided key is empty.
Returns OperationFailed
when the HMAC computation fails.
Returns OutOfMemory when an allocation fails.
Sourcepub fn kdfe(
&self,
z: &[u8],
label: &str,
context_u: &[u8],
context_v: &[u8],
key_bits: u16,
) -> Result<Vec<u8>, TpmCryptoError>
pub fn kdfe( &self, z: &[u8], label: &str, context_u: &[u8], context_v: &[u8], key_bits: u16, ) -> Result<Vec<u8>, TpmCryptoError>
Implements the KDFe key derivation function from SP 800-56A for ECDH.
§Errors
Returns InvalidHash
when the hash algorithm is not recognized.
Returns OperationFailed
when the digest computation fails.
Returns OutOfMemory when an allocation fails.