Skip to main content

tr31_wrap_with_header_string

Function tr31_wrap_with_header_string 

Source
pub fn tr31_wrap_with_header_string<P, K: ?Sized>(
    provider: &P,
    kbpk: &K,
    kbpk_size: AesKeySize,
    header_str: &str,
    key: &[u8],
    masked_key_len: usize,
    random_seed: &[u8],
) -> Result<String, Tr31CryptoError<P::Error>>
Expand description

Wrap a cryptographic key according to TR-31 version D using a header supplied as a string.

This is a convenience wrapper around tr31_wrap. The supplied header is first parsed into a KeyBlockHeader and then passed to the normal wrapping operation.

§Parameters

  • provider - Cryptographic provider.
  • kbpk - Provider-specific Key Block Protection Key.
  • kbpk_size - AES size of the KBPK.
  • header_str - String representation of the TR-31 header.
  • key - Cryptographic key or sensitive data to protect.
  • masked_key_len - Optional masked key length.
  • random_seed - Random data used for payload padding.

§Returns

The complete ASCII-encoded TR-31 key block.

§Errors

Returns Tr31CryptoError::Tr31 if the header cannot be parsed or if any TR-31 wrapping, payload, or header operation fails.

Returns Tr31CryptoError::Crypto if the cryptographic provider reports a key-derivation, AES-CMAC, or AES-CBC encryption error.