/* * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _BSV_CRYPTO_API_H #define _BSV_CRYPTO_API_H #ifdef __cplusplus extern "C" { #endif /*! @file @brief This file contains cryptographic ROM APIs : SHA256, CMAC KDF, and CCM. */ #include "cc_pal_types.h" #include "bsv_crypto_defs.h" #include "cc_sec_defs.h" /*---------------------------- PUBLIC FUNCTIONS -----------------------------------*/ /*! @brief This function calculates SHA256 digest over contiguous memory in an integrated operation. @return CC_OK on success. @return A non-zero value from bsv_error.h on failure. */ CCError_t CC_BsvSHA256( unsigned long hwBaseAddress, /*!< [in] CryptoCell HW registers' base address. */ uint8_t *pDataIn, /*!< [in] Pointer to the input data to be HASHed. Buffer must be contiguous. */ size_t dataSize, /*!< [in] The size of the data to be hashed in Bytes. Limited to 64KB. */ CCHashResult_t hashBuff /*!< [out] Pointer to a word-aligned 32 Byte buffer. */ ); /*! @brief The key derivation function is as specified in the "KDF in Counter Mode" section of NIST Special Publication 800-108: Recommendation for Key Derivation Using Pseudorandom Functions. Key derivation is based on length l, label L, context C and derivation key Ki. AES-CMAC is used as the pseudorandom function (PRF). \note When using this API the label and context for each use-case must be well defined. \note We recommend to derive only 256-bit keys from HUK or 256-bit user keys. @return CC_OK on success. @return A non-zero value from bsv_error.h on failure. */ /* A key derivation functions can iterates n times until l bits of keying material are generated. For each of the iteration of the PRF, i=1 to n, do: result(0) = 0; K(i) = PRF (Ki, [i] || Label || 0x00 || Context || length); results(i) = result(i-1) || K(i); concisely, result(i) = K(i) || k(i-1) || .... || k(0)*/ CCError_t CC_BsvKeyDerivation( unsigned long hwBaseAddress, /*!< [in] CryptoCell HW registers' base address. */ CCBsvKeyType_t keyType, /*!< [in] One of the following key types used as an input to a key derivation function: