1 /* 2 * Copyright (c) 2001-2019, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _SBRT_INT_FUNC_H 8 #define _SBRT_INT_FUNC_H 9 10 #ifdef __cplusplus 11 extern "C" 12 { 13 #endif 14 15 #include "secureboot_gen_defs.h" 16 17 /* The AES block size in words and in bytes */ 18 #define AES_BLOCK_SIZE_IN_WORDS 4 19 /* The size of the AES KEY in words and bytes */ 20 #define AES_KEY_SIZE_IN_WORDS AES_BLOCK_SIZE_IN_WORDS 21 /* The size of the IV or counter buffer */ 22 #define AES_IV_COUNTER_SIZE_IN_WORDS AES_BLOCK_SIZE_IN_WORDS 23 #define AES_IV_COUNTER_SIZE_IN_BYTES (AES_IV_COUNTER_SIZE_IN_WORDS * sizeof(uint32_t)) 24 25 /* Defines the AES key buffer */ 26 typedef uint32_t AES_Key_t[AES_KEY_SIZE_IN_WORDS]; 27 /* Defines the IV counter buffer - 16 bytes array */ 28 typedef uint32_t AES_Iv_t[AES_IV_COUNTER_SIZE_IN_WORDS]; 29 30 CCError_t SBRT_ImageLoadAndVerify(CCSbFlashReadFunc preHashflashRead_func, 31 void *preHashUserContext, 32 unsigned long hwBaseAddress, 33 uint8_t isLoadFromFlash, 34 uint8_t isVerifyImage, 35 bsvCryptoMode_t cryptoMode, 36 CCBsvKeyType_t keyType, 37 AES_Iv_t AESIv, 38 uint8_t *pSwRecSignedData, 39 uint32_t *pSwRecNoneSignedData, 40 uint32_t *workspace_ptr, 41 uint32_t workspaceSize); 42 43 CCError_t SBRT_RSA_PSS_Verify(unsigned long hwBaseAddress, /* [in] HW base address of registers. */ 44 CCHashResult_t mHash, /* [in] Pointer to the SHA256 hash of the message. */ 45 uint32_t *pN, /* [in] Pointer to the RSA modulus (LE words array). */ 46 uint32_t *pNp, /* [in] Pointer to the Barrett tag of the RSA modulus (LE words array). */ 47 uint32_t *pSign /* [out] Pointer to the signature output (it is placed as BE bytes 48 array into words buffer for alignments goal). */); 49 50 void SBRT_HalClearInterruptBit(unsigned long hwBaseAddress, uint32_t data); 51 52 void SBRT_HalMaskInterrupt(unsigned long hwBaseAddress, uint32_t data); 53 54 CCError_t SBRT_HalWaitInterrupt(unsigned long hwBaseAddress, uint32_t data); 55 56 CCError_t SBRT_LcsGet(unsigned long hwBaseAddress, uint32_t *pLcs); 57 58 CCError_t SBRT_OTPWordRead(unsigned long hwBaseAddress, uint32_t otpAddress, uint32_t *pOtpWord); 59 60 CCError_t SBRT_SwVersionGet(unsigned long hwBaseAddress, CCSbPubKeyIndexType_t keyIndex, uint32_t *swVersion); 61 62 CCError_t SBRT_PubKeyHashGet(unsigned long hwBaseAddress, CCSbPubKeyIndexType_t keyIndex, uint32_t *hashedPubKey, uint32_t hashResultSizeWords); 63 64 CCError_t SBRT_SHA256( unsigned long hwBaseAddress, 65 uint8_t *pDataIn, 66 size_t dataSize, 67 CCHashResult_t hashBuff); 68 69 CCError_t SBRT_CryptoImageInit( unsigned long hwBaseAddress, 70 bsvCryptoMode_t mode, 71 CCBsvKeyType_t keyType); 72 73 CCError_t SBRT_CryptoImageUpdate( unsigned long hwBaseAddress, 74 bsvCryptoMode_t mode, 75 CCBsvKeyType_t keyType, 76 uint32_t *pCtrStateBuf, 77 uint8_t *pDataIn, 78 uint8_t *pDataOut, 79 size_t dataSize, 80 CCHashResult_t hashBuff, 81 uint8_t isLoadIV); 82 83 CCError_t SBRT_CryptoImageFinish( unsigned long hwBaseAddress, 84 bsvCryptoMode_t mode, 85 CCHashResult_t hashBuff); 86 87 uint32_t SBRT_MemCmp( uint8_t *pBuff1 , uint8_t *pBuff2 , uint32_t size); 88 89 void SBRT_ReverseMemCopy( uint8_t *pDst, uint8_t *pSrc, uint32_t size); 90 91 #ifdef __cplusplus 92 } 93 #endif 94 95 #endif 96 97 98 99