1 /* 2 * Copyright (c) 2017-2020 ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _BSV_CRYPTO_API_H 8 #define _BSV_CRYPTO_API_H 9 10 #ifdef __cplusplus 11 extern "C" 12 { 13 #endif 14 15 /*! 16 @file 17 @brief This file contains the cryptographic ROM APIs of the Boot Services. 18 19 @defgroup cc_bsv_crypto_api CryptoCell Boot Services cryptographic ROM APIs 20 @{ 21 @ingroup cc_bsv 22 */ 23 24 #include "cc_pal_types.h" 25 #include "cc_sec_defs.h" 26 #include "cc_address_defs.h" 27 #include "bsv_crypto_defs.h" 28 29 /*---------------------------- 30 PUBLIC FUNCTIONS 31 -----------------------------------*/ 32 33 /*! 34 @brief This function calculates the SHA-256 digest over contiguous memory 35 in an integrated operation. 36 37 @return \c CC_OK on success. 38 @return A non-zero value from bsv_error.h on failure. 39 */ 40 CCError_t CC_BsvSha256( 41 unsigned long hwBaseAddress, /*!< [in] The base address of the CryptoCell HW registers. */ 42 uint8_t *pDataIn, /*!< [in] A pointer to the input buffer to be hashed. The buffer must be contiguous. */ 43 size_t dataSize, /*!< [in] The size of the data to be hashed, in bytes. */ 44 CCHashResult_t hashBuff /*!< [out] A pointer to a word-aligned 32-byte buffer. */ 45 ); 46 47 48 /*! 49 @brief This function allows you to calculate SHA256 digest of an image with decryption base on AES-CTR, 50 with HW or user key. 51 52 @return \c CC_OK on success. 53 @return A non-zero value from bsv_error.h on failure. (in this case, hashBuff will be returned clean, while the output data should be cleaned by the user). 54 */ 55 CCError_t CC_BsvCryptoImageDecrypt( unsigned long hwBaseAddress, /*!< [in] The base address of the CryptoCell HW registers. */ 56 CCBsvflowMode_t flow, /*!< [in] The supported operations are: HASH, AES to HASH, AES and HASH. */ 57 CCBsvKeyType_t keyType, /*!< [in] The key type to use: Kce, Kceicv, or user key. */ 58 uint8_t *pUserKey, /*!< [in] A pointer to the user key buffer in case keyType is CC_BSV_USER_KEY. */ 59 size_t userKeySize, /*!< [in] The user key size in bytes (128bits) in case keyType is CC_BSV_USER_KEY. */ 60 uint8_t *pIvBuf, /*!< [in] A pointer to the IV / counter buffer. */ 61 uint8_t *pInputData, /*!< [in] A pointer to the input data. */ 62 uint8_t *pOutputData, /*!< [out] A pointer to the output buffer. (optional – should be null in case of hash only). */ 63 size_t dataSize, /*!< [in] The size of the input data in bytes. MUST be multiple of AES block size. */ 64 CCHashResult_t hashBuff /*!< [out] A pointer to a word-aligned 32-byte digest output buffer. */ 65 ); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif 72 73 /** 74 @} 75 */ 76 77