#[non_exhaustive]pub enum TpmHash {
Sha1,
Sha256,
Sha384,
Sha512,
Sm3_256,
Sha3_256,
Sha3_384,
Sha3_512,
Shake128,
Shake256,
}Expand description
TPM 2.0 hash algorithms.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
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 Crypto when libcrypto fails.
Sourcepub fn digest_into(
&self,
data_chunks: &[&[u8]],
output: &mut [u8],
) -> Result<usize, TpmCryptoError>
pub fn digest_into( &self, data_chunks: &[&[u8]], output: &mut [u8], ) -> Result<usize, TpmCryptoError>
Computes a cryptographic digest into output.
Returns the number of bytes written to output.
§Errors
Returns BufferTooSmall when
output is too small for the digest.
Returns Crypto when libcrypto 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 Crypto when libcrypto fails.
Sourcepub fn hmac_into(
&self,
key: &[u8],
data_chunks: &[&[u8]],
output: &mut [u8],
) -> Result<usize, TpmCryptoError>
pub fn hmac_into( &self, key: &[u8], data_chunks: &[&[u8]], output: &mut [u8], ) -> Result<usize, TpmCryptoError>
Computes an HMAC digest into output.
Returns the number of bytes written to output.
§Errors
Returns BufferTooSmall when
output is too small for the HMAC digest.
Returns KeyIsEmpty when the
provided key is empty.
Returns Crypto when libcrypto 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 MacMismatch
when the HMAC does not match the expected value.
Returns InvalidHash when the
hash algorithm is not recognized.
Returns Crypto when libcrypto fails.
Sourcepub fn kdfa(
&self,
hmac_key: &[u8],
label: &[u8],
context_a: &[u8],
context_b: &[u8],
key_bits: usize,
) -> Result<Vec<u8>, TpmCryptoError>
pub fn kdfa( &self, hmac_key: &[u8], label: &[u8], context_a: &[u8], context_b: &[u8], key_bits: usize, ) -> 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 InvalidKdfKeyBits
when key_bits does not fit in a TPM UINT32.
Returns Crypto when libcrypto fails.
Sourcepub fn kdfa_into(
&self,
hmac_key: &[u8],
label: &[u8],
context_a: &[u8],
context_b: &[u8],
key_bits: usize,
output: &mut [u8],
) -> Result<usize, TpmCryptoError>
pub fn kdfa_into( &self, hmac_key: &[u8], label: &[u8], context_a: &[u8], context_b: &[u8], key_bits: usize, output: &mut [u8], ) -> Result<usize, TpmCryptoError>
Implements KDFa into output.
Returns the number of bytes written to output.
§Errors
Returns BufferTooSmall when
output is too small for the requested key size.
Returns KeyIsEmpty when the
provided key is empty.
Returns InvalidKdfKeyBits
when key_bits does not fit in a TPM UINT32.
Returns Crypto when libcrypto fails.
Sourcepub fn kdfe(
&self,
z: &[u8],
label: &[u8],
context_u: &[u8],
context_v: &[u8],
key_bits: usize,
) -> Result<Vec<u8>, TpmCryptoError>
pub fn kdfe( &self, z: &[u8], label: &[u8], context_u: &[u8], context_v: &[u8], key_bits: usize, ) -> 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 InvalidKdfKeyBits
when key_bits does not fit in a TPM UINT32.
Returns Crypto when libcrypto fails.
Sourcepub fn kdfe_into(
&self,
z: &[u8],
label: &[u8],
context_u: &[u8],
context_v: &[u8],
key_bits: usize,
output: &mut [u8],
) -> Result<usize, TpmCryptoError>
pub fn kdfe_into( &self, z: &[u8], label: &[u8], context_u: &[u8], context_v: &[u8], key_bits: usize, output: &mut [u8], ) -> Result<usize, TpmCryptoError>
Implements KDFe into output.
Returns the number of bytes written to output.
§Errors
Returns BufferTooSmall when
output is too small for the requested key size.
Returns InvalidKdfKeyBits
when key_bits does not fit in a TPM UINT32.
Returns Crypto when libcrypto fails.