1*53ee8cc1Swenshuai.xi /* 2*53ee8cc1Swenshuai.xi Copyright (c) NDS Limited 2010 3*53ee8cc1Swenshuai.xi 4*53ee8cc1Swenshuai.xi P R O P R I E T A R Y & C O N F I D E N T I A L 5*53ee8cc1Swenshuai.xi 6*53ee8cc1Swenshuai.xi The copyright of this code and related documentation together with 7*53ee8cc1Swenshuai.xi any other associated intellectual property rights are vested in 8*53ee8cc1Swenshuai.xi NDS Limited and may not be used except in accordance with the terms 9*53ee8cc1Swenshuai.xi of the license that you have entered into with NDS Limited. 10*53ee8cc1Swenshuai.xi Use of this material without an express license from NDS Limited 11*53ee8cc1Swenshuai.xi shall be an infringement of copyright and any other intellectual 12*53ee8cc1Swenshuai.xi property rights that may be incorporated with this material. 13*53ee8cc1Swenshuai.xi */ 14*53ee8cc1Swenshuai.xi 15*53ee8cc1Swenshuai.xi #ifndef NSK2HDI_BL_H_ 16*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_H_ 17*53ee8cc1Swenshuai.xi 18*53ee8cc1Swenshuai.xi /** 19*53ee8cc1Swenshuai.xi * @mainpage NSK2 API - HDI Bootloader API for NSK2 Chips 20*53ee8cc1Swenshuai.xi * 21*53ee8cc1Swenshuai.xi * @author Reuben Sumner, Julia Rabinovich 22*53ee8cc1Swenshuai.xi * @date 28/06/2011 23*53ee8cc1Swenshuai.xi * @version 4.01 24*53ee8cc1Swenshuai.xi * 25*53ee8cc1Swenshuai.xi * @file nsk2hdi_bl.h 26*53ee8cc1Swenshuai.xi 27*53ee8cc1Swenshuai.xi * @brief NSK2 API - HDI Bootloader API for NSK2 Chips 28*53ee8cc1Swenshuai.xi 29*53ee8cc1Swenshuai.xi * This file contains the definitions and functions of the NSK2 Bootloader supplement 30*53ee8cc1Swenshuai.xi 31*53ee8cc1Swenshuai.xi * 32*53ee8cc1Swenshuai.xi */ 33*53ee8cc1Swenshuai.xi 34*53ee8cc1Swenshuai.xi #include "ndstypes.h" 35*53ee8cc1Swenshuai.xi //#include "nsk2hdi_3014.h" 36*53ee8cc1Swenshuai.xi //#include "nsk2hdi.h" 37*53ee8cc1Swenshuai.xi #include "nsk_3014.h" 38*53ee8cc1Swenshuai.xi #include "nsk_282.h" 39*53ee8cc1Swenshuai.xi /** 40*53ee8cc1Swenshuai.xi ** @addtogroup NSK2HDI_BL BL Device 41*53ee8cc1Swenshuai.xi ** @{ 42*53ee8cc1Swenshuai.xi */ 43*53ee8cc1Swenshuai.xi 44*53ee8cc1Swenshuai.xi 45*53ee8cc1Swenshuai.xi /** 46*53ee8cc1Swenshuai.xi ** @addtogroup NSK2HDI_BL_REQUEST BL Request IDs 47*53ee8cc1Swenshuai.xi ** @{ 48*53ee8cc1Swenshuai.xi */ 49*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_ALL_DESCRIPTORS_REQUEST 0x00U /*!< @brief request for reading all BL descriptors*/ 50*53ee8cc1Swenshuai.xi /** @} 51*53ee8cc1Swenshuai.xi * End of NSK2HDI_BL_REQUEST group belonging 52*53ee8cc1Swenshuai.xi */ 53*53ee8cc1Swenshuai.xi 54*53ee8cc1Swenshuai.xi 55*53ee8cc1Swenshuai.xi /** 56*53ee8cc1Swenshuai.xi ** @addtogroup NSK2HDI_BL_HASH BL Hashing Algorithms 57*53ee8cc1Swenshuai.xi ** @{ 58*53ee8cc1Swenshuai.xi */ 59*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_SHA1_HASH_ALG_TYPE 0x01U /*!< @brief SHA1 hash type*/ 60*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_SHA256_HASH_ALG_TYPE 0x02U /*!< @brief SHA256 hash type*/ 61*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_MD5_HASH_ALG_TYPE 0x03U /*!< @brief MD5 hash type */ 62*53ee8cc1Swenshuai.xi /** @} 63*53ee8cc1Swenshuai.xi * End of NSK2HDI_BL_HASH group belonging 64*53ee8cc1Swenshuai.xi */ 65*53ee8cc1Swenshuai.xi 66*53ee8cc1Swenshuai.xi /** 67*53ee8cc1Swenshuai.xi ** @addtogroup NSK2HDI_BL_DESCRIPTOR_TAGS BL Descriptor Tags 68*53ee8cc1Swenshuai.xi ** @{ 69*53ee8cc1Swenshuai.xi */ 70*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_ALGORITHM_DESC_TAG 0x01U /*!< @brief Algorithm descriptor*/ 71*53ee8cc1Swenshuai.xi #define NSK2HDI_BL_CAPABILITY_DESC_TAG 0x02U /*!< @brief Device capability descriptor*/ 72*53ee8cc1Swenshuai.xi /** @} 73*53ee8cc1Swenshuai.xi * End of NSK2HDI_BL_DESCRIPTOR_TAGS group belonging 74*53ee8cc1Swenshuai.xi */ 75*53ee8cc1Swenshuai.xi 76*53ee8cc1Swenshuai.xi 77*53ee8cc1Swenshuai.xi /*===========================================================================*/ 78*53ee8cc1Swenshuai.xi /** @brief This function is used to query the capabilities of the provided hashing engine. 79*53ee8cc1Swenshuai.xi 80*53ee8cc1Swenshuai.xi @param[in] request_id - the ID of the request. See \ref NSK2HDI_BL_REQUEST for the list of the possible values. 81*53ee8cc1Swenshuai.xi @param[in, out] desc_size - size of the buffer allocated by the caller for the device properties as an input, actual size of the device properties returned by the device as an output. 82*53ee8cc1Swenshuai.xi @param[out] desc - pointer to the buffer receiving the descriptors with device properties. See \ref NSK2HDI_BL_DESCRIPTOR_TAGS 83*53ee8cc1Swenshuai.xi 84*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_OK if the operation completed successfully or 85*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_INVALID_REQUEST if one or more parameters are invalid or 86*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_FAILED if the operation failed. 87*53ee8cc1Swenshuai.xi 88*53ee8cc1Swenshuai.xi */ 89*53ee8cc1Swenshuai.xi NSK2HDI_STATUS NSK2HDI_BL_GetHashCapabilities( 90*53ee8cc1Swenshuai.xi NDS_ULONG request_id, 91*53ee8cc1Swenshuai.xi NDS_ULONG *desc_size, 92*53ee8cc1Swenshuai.xi NDS_UBYTE *desc 93*53ee8cc1Swenshuai.xi ); 94*53ee8cc1Swenshuai.xi 95*53ee8cc1Swenshuai.xi /*===========================================================================*/ 96*53ee8cc1Swenshuai.xi /** @brief This function is used to initialize the hash operation cycle. 97*53ee8cc1Swenshuai.xi 98*53ee8cc1Swenshuai.xi @param[in] desc_size - Size of the buffer carrying the descriptors. 99*53ee8cc1Swenshuai.xi @param[in] desc - Buffer carrying the descriptors. Should contain #NSK2HDI_BL_ALGORITHM_DESC_TAG descriptor. 100*53ee8cc1Swenshuai.xi 101*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_OK if the operation completed successfully or 102*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_INVALID_REQUEST if one or more parameters are invalid or 103*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_FAILED if the operation failed. 104*53ee8cc1Swenshuai.xi 105*53ee8cc1Swenshuai.xi */ 106*53ee8cc1Swenshuai.xi NSK2HDI_STATUS NSK2HDI_BL_InitializeHashOperation( 107*53ee8cc1Swenshuai.xi NDS_ULONG desc_size, 108*53ee8cc1Swenshuai.xi NDS_UBYTE *desc 109*53ee8cc1Swenshuai.xi ); 110*53ee8cc1Swenshuai.xi 111*53ee8cc1Swenshuai.xi /*===========================================================================*/ 112*53ee8cc1Swenshuai.xi /** @brief This function is used to perform the hashing of the data block. 113*53ee8cc1Swenshuai.xi 114*53ee8cc1Swenshuai.xi @param[in] data_size - Size of data block to be hashed in bytes. Must be a multiple of underlying hash block size (generally 64-bytes) and the minimum granularity as specified by #NSK2HDI_BL_CAPABILITY_DESC_TAG. 115*53ee8cc1Swenshuai.xi @param[in] data - Pointer to the data to be hashed. The data must be aligned according to the device capability as reported by #NSK2HDI_BL_CAPABILITY_DESC_TAG. 116*53ee8cc1Swenshuai.xi 117*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_OK if the operation completed successfully or 118*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_INVALID_REQUEST if one or more parameters are invalid or 119*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_FAILED if the operation failed. 120*53ee8cc1Swenshuai.xi */ 121*53ee8cc1Swenshuai.xi 122*53ee8cc1Swenshuai.xi NSK2HDI_STATUS NSK2HDI_BL_PerformHashOperation( 123*53ee8cc1Swenshuai.xi NDS_ULONG data_size, 124*53ee8cc1Swenshuai.xi const NDS_UBYTE *data 125*53ee8cc1Swenshuai.xi ); 126*53ee8cc1Swenshuai.xi 127*53ee8cc1Swenshuai.xi /*===========================================================================*/ 128*53ee8cc1Swenshuai.xi /** @brief This function is used to commit the completion of the hash operation cycle 129*53ee8cc1Swenshuai.xi and retrieve the digest. 130*53ee8cc1Swenshuai.xi 131*53ee8cc1Swenshuai.xi @param[in] data - Pointer to the last block of data to be hashed. The data must be aligned according to the device capability as reported by #NSK2HDI_BL_CAPABILITY_DESC_TAG. This value may be NULL if and only if data_size is 0. 132*53ee8cc1Swenshuai.xi @param[in] data_size - Size of the final data in bytes. Size in bytes of the final block of data to hash. Must be a multiple of the minimum granularity as reported by #NSK2HDI_BL_CAPABILITY_DESC_TAG. This does not need to be a multiple of the underlying hash block size. 133*53ee8cc1Swenshuai.xi @param[in, out] digest_size - size of the buffer allocated by the caller for the hash digest as an input, actual digest size written to the buffer as an output. 134*53ee8cc1Swenshuai.xi @param[out] digest - pointer to the buffer receiving the digest 135*53ee8cc1Swenshuai.xi 136*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_OK if the operation completed successfully or 137*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_INVALID_REQUEST if one or more parameters are invalid or 138*53ee8cc1Swenshuai.xi @retval #NSK2HDI_STATUS_FAILED if the operation failed. 139*53ee8cc1Swenshuai.xi */ 140*53ee8cc1Swenshuai.xi NSK2HDI_STATUS NSK2HDI_BL_CompleteHashOperation( 141*53ee8cc1Swenshuai.xi NDS_ULONG data_size, 142*53ee8cc1Swenshuai.xi const NDS_UBYTE *data, 143*53ee8cc1Swenshuai.xi NDS_ULONG *digest_size, 144*53ee8cc1Swenshuai.xi NDS_UBYTE *digest 145*53ee8cc1Swenshuai.xi ); 146*53ee8cc1Swenshuai.xi 147*53ee8cc1Swenshuai.xi /** @} 148*53ee8cc1Swenshuai.xi * End of NSK2HDI_BL group belonging 149*53ee8cc1Swenshuai.xi */ 150*53ee8cc1Swenshuai.xi 151*53ee8cc1Swenshuai.xi #endif /*NSK2HDI_BL_H_*/ 152