blob: bddfdc6a6196d04b0188a4fcb7758cadbcf3d775 [file] [log] [blame]
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_KDF_H_
#define OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_KDF_H_
/**
* @file
* @brief Key derivation functions for the OpenTitan cryptography library.
*
* Includes HMAC- and KMAC-based KDFs.
*/
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* Enum to define the supported KDF constructions.
*
* Values are hardened.
*/
typedef enum kdf_type {
// KDF construction with HMAC as a PRF.
kKdfTypeHmac = 0xfa3b,
// KDF construction with KMAC as a PRF.
kKdfTypeKmac = 0x0f47,
} kdf_type_t;
/**
* Performs the key derivation function in counter mode.
*
* The required PRF engine for the KDF function is selected using the
* `kdf_mode` parameter.
*
* @param key_derivation_key Pointer to the blinded key derivation key
* @param kdf_mode Required KDF mode, with HMAC or KMAC as a PRF
* @param key_mode Crypto mode for which the derived key is intended
* @param required_bit_len Required length of the derived key in bits
* @param keying_material Pointer to the blinded keying material
* @return Result of the key derivation operation
*/
crypto_status_t otcrypto_kdf_ctr(const crypto_blinded_key_t key_derivation_key,
kdf_type_t kdf_mode, key_mode_t key_mode,
size_t required_bit_len,
crypto_blinded_key_t keying_material);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // OPENTITAN_SW_DEVICE_LIB_CRYPTO_INCLUDE_KDF_H_