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