Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_crypto.h@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /**************************************************************************//** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * @file crypto.h |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V1.10 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 14 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 14/10/06 1:49p $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief Cryptographic Accelerator driver header file |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * @note |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 10 | ******************************************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 11 | #ifndef __CRYPTO_H__ |
sahilmgandhi | 18:6a4db94011d3 | 12 | #define __CRYPTO_H__ |
sahilmgandhi | 18:6a4db94011d3 | 13 | |
sahilmgandhi | 18:6a4db94011d3 | 14 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 15 | extern "C" |
sahilmgandhi | 18:6a4db94011d3 | 16 | { |
sahilmgandhi | 18:6a4db94011d3 | 17 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver |
sahilmgandhi | 18:6a4db94011d3 | 20 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 21 | */ |
sahilmgandhi | 18:6a4db94011d3 | 22 | |
sahilmgandhi | 18:6a4db94011d3 | 23 | /** @addtogroup NUC472_442_CRYPTO_Driver CRYPTO Driver |
sahilmgandhi | 18:6a4db94011d3 | 24 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 25 | */ |
sahilmgandhi | 18:6a4db94011d3 | 26 | |
sahilmgandhi | 18:6a4db94011d3 | 27 | |
sahilmgandhi | 18:6a4db94011d3 | 28 | /** @addtogroup NUC472_442_CRYPTO_EXPORTED_CONSTANTS CRYPTO Exported Constants |
sahilmgandhi | 18:6a4db94011d3 | 29 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 30 | */ |
sahilmgandhi | 18:6a4db94011d3 | 31 | |
sahilmgandhi | 18:6a4db94011d3 | 32 | #define PRNG_KEY_SIZE_64 0 /*!< Select to generate 64-bit random key \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 33 | #define PRNG_KEY_SIZE_128 1 /*!< Select to generate 128-bit random key \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 34 | #define PRNG_KEY_SIZE_192 2 /*!< Select to generate 192-bit random key \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 35 | #define PRNG_KEY_SIZE_256 3 /*!< Select to generate 256-bit random key \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 36 | |
sahilmgandhi | 18:6a4db94011d3 | 37 | #define PRNG_SEED_CONT 0 /*!< PRNG using current seed \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 38 | #define PRNG_SEED_RELOAD 1 /*!< PRNG reload new seed \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 39 | |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define AES_KEY_SIZE_128 0 /*!< AES select 128-bit key length \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 41 | #define AES_KEY_SIZE_192 1 /*!< AES select 192-bit key length \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 42 | #define AES_KEY_SIZE_256 2 /*!< AES select 256-bit key length \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 43 | |
sahilmgandhi | 18:6a4db94011d3 | 44 | #define AES_MODE_ECB 0 /*!< AES select ECB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 45 | #define AES_MODE_CBC 1 /*!< AES select CBC mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 46 | #define AES_MODE_CFB 2 /*!< AES select CFB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 47 | #define AES_MODE_OFB 3 /*!< AES select OFB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 48 | #define AES_MODE_CTR 4 /*!< AES select CTR mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 49 | #define AES_MODE_CBC_CS1 0x10 /*!< AES select CBC CS1 mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 50 | #define AES_MODE_CBC_CS2 0x11 /*!< AES select CBC CS2 mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 51 | #define AES_MODE_CBC_CS3 0x12 /*!< AES select CBC CS3 mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 52 | |
sahilmgandhi | 18:6a4db94011d3 | 53 | #define AES_NO_SWAP 0 /*!< AES do not swap input and output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 54 | #define AES_OUT_SWAP 1 /*!< AES swap output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 55 | #define AES_IN_SWAP 2 /*!< AES swap input data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 56 | #define AES_IN_OUT_SWAP 3 /*!< AES swap both input and output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 57 | |
sahilmgandhi | 18:6a4db94011d3 | 58 | #define DES_MODE_ECB 0x000 /*!< DES select ECB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 59 | #define DES_MODE_CBC 0x100 /*!< DES select CBC mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 60 | #define DES_MODE_CFB 0x200 /*!< DES select CFB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 61 | #define DES_MODE_OFB 0x300 /*!< DES select OFB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 62 | #define DES_MODE_CTR 0x400 /*!< DES select CTR mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 63 | #define TDES_MODE_ECB 0x004 /*!< TDES select ECB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 64 | #define TDES_MODE_CBC 0x104 /*!< TDES select CBC mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 65 | #define TDES_MODE_CFB 0x204 /*!< TDES select CFB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 66 | #define TDES_MODE_OFB 0x304 /*!< TDES select OFB mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 67 | #define TDES_MODE_CTR 0x404 /*!< TDES select CTR mode \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 68 | |
sahilmgandhi | 18:6a4db94011d3 | 69 | #define TDES_NO_SWAP 0 /*!< TDES do not swap data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 70 | #define TDES_WHL_SWAP 1 /*!< TDES swap high-low word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 71 | #define TDES_OUT_SWAP 2 /*!< TDES swap output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 72 | #define TDES_OUT_WHL_SWAP 3 /*!< TDES swap output data and high-low word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 73 | #define TDES_IN_SWAP 4 /*!< TDES swap input data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 74 | #define TDES_IN_WHL_SWAP 5 /*!< TDES swap input data and high-low word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 75 | #define TDES_IN_OUT_SWAP 6 /*!< TDES swap both input and output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 76 | #define TDES_IN_OUT_WHL_SWAP 7 /*!< TDES swap input, output and high-low word \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 77 | |
sahilmgandhi | 18:6a4db94011d3 | 78 | #define SHA_MODE_SHA1 0 /*!< SHA select SHA-1 160-bit \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 79 | #define SHA_MODE_SHA224 5 /*!< SHA select SHA-224 224-bit \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 80 | #define SHA_MODE_SHA256 4 /*!< SHA select SHA-256 256-bit \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 81 | |
sahilmgandhi | 18:6a4db94011d3 | 82 | #define SHA_NO_SWAP 0 /*!< SHA do not swap input and output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 83 | #define SHA_OUT_SWAP 1 /*!< SHA swap output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 84 | #define SHA_IN_SWAP 2 /*!< SHA swap input data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 85 | #define SHA_IN_OUT_SWAP 3 /*!< SHA swap both input and output data \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 86 | |
sahilmgandhi | 18:6a4db94011d3 | 87 | #define CRYPTO_DMA_ONE_SHOT 0x5 /*!< Do one shot encrypt/decrypt with DMA \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 88 | #define CRYPTO_DMA_CONTINUE 0x6 /*!< Do one continuous encrypt/decrypt with DMA \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 89 | #define CRYPTO_DMA_LAST 0x6 /*!< Do last encrypt/decrypt with DMA \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 90 | |
sahilmgandhi | 18:6a4db94011d3 | 91 | /*@}*/ /* end of group NUC472_442_CRYPTO_EXPORTED_CONSTANTS */ |
sahilmgandhi | 18:6a4db94011d3 | 92 | |
sahilmgandhi | 18:6a4db94011d3 | 93 | |
sahilmgandhi | 18:6a4db94011d3 | 94 | |
sahilmgandhi | 18:6a4db94011d3 | 95 | |
sahilmgandhi | 18:6a4db94011d3 | 96 | /** @addtogroup NUC472_442_CRYPTO_EXPORTED_FUNCTIONS CRYPTO Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 97 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 98 | */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | /*----------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 101 | /* Macros */ |
sahilmgandhi | 18:6a4db94011d3 | 102 | /*----------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 103 | |
sahilmgandhi | 18:6a4db94011d3 | 104 | /** |
sahilmgandhi | 18:6a4db94011d3 | 105 | * @brief This macro enables PRNG interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 106 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 107 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 108 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 109 | */ |
sahilmgandhi | 18:6a4db94011d3 | 110 | #define PRNG_ENABLE_INT() (CRPT->INTEN |= CRPT_INTEN_PRNGIEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 111 | |
sahilmgandhi | 18:6a4db94011d3 | 112 | /** |
sahilmgandhi | 18:6a4db94011d3 | 113 | * @brief This macro disables PRNG interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 114 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 115 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 116 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 117 | */ |
sahilmgandhi | 18:6a4db94011d3 | 118 | #define PRNG_DISABLE_INT() (CRPT->INTEN &= ~CRPT_INTEN_PRNGIEN_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 119 | |
sahilmgandhi | 18:6a4db94011d3 | 120 | /** |
sahilmgandhi | 18:6a4db94011d3 | 121 | * @brief This macro gets PRNG interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 122 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 123 | * @return PRNG interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 124 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 125 | */ |
sahilmgandhi | 18:6a4db94011d3 | 126 | #define PRNG_GET_INT_FLAG() (CRPT->INTSTS & CRPT_INTSTS_PRNGIF_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 127 | |
sahilmgandhi | 18:6a4db94011d3 | 128 | /** |
sahilmgandhi | 18:6a4db94011d3 | 129 | * @brief This macro clears PRNG interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 130 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 131 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 132 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 133 | */ |
sahilmgandhi | 18:6a4db94011d3 | 134 | #define PRNG_CLR_INT_FLAG() (CRPT->INTSTS = CRPT_INTSTS_PRNGIF_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 135 | |
sahilmgandhi | 18:6a4db94011d3 | 136 | /** |
sahilmgandhi | 18:6a4db94011d3 | 137 | * @brief This macro enables AES interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 138 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 139 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 140 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 141 | */ |
sahilmgandhi | 18:6a4db94011d3 | 142 | #define AES_ENABLE_INT() (CRPT->INTEN |= (CRPT_INTEN_AESIEN_Msk|CRPT_INTEN_AESERRIEN_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 143 | |
sahilmgandhi | 18:6a4db94011d3 | 144 | /** |
sahilmgandhi | 18:6a4db94011d3 | 145 | * @brief This macro disables AES interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 146 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 147 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 148 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 149 | */ |
sahilmgandhi | 18:6a4db94011d3 | 150 | #define AES_DISABLE_INT() (CRPT->INTEN &= ~(CRPT_INTEN_AESIEN_Msk|CRPT_INTEN_AESERRIEN_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 151 | |
sahilmgandhi | 18:6a4db94011d3 | 152 | /** |
sahilmgandhi | 18:6a4db94011d3 | 153 | * @brief This macro gets AES interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 154 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 155 | * @return AES interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 156 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 157 | */ |
sahilmgandhi | 18:6a4db94011d3 | 158 | #define AES_GET_INT_FLAG() (CRPT->INTSTS & (CRPT_INTSTS_AESIF_Msk|CRPT_INTSTS_AESERRIF_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 159 | |
sahilmgandhi | 18:6a4db94011d3 | 160 | /** |
sahilmgandhi | 18:6a4db94011d3 | 161 | * @brief This macro clears AES interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 162 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 163 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 164 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 165 | */ |
sahilmgandhi | 18:6a4db94011d3 | 166 | #define AES_CLR_INT_FLAG() (CRPT->INTSTS = (CRPT_INTSTS_AESIF_Msk|CRPT_INTSTS_AESERRIF_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 167 | |
sahilmgandhi | 18:6a4db94011d3 | 168 | /** |
sahilmgandhi | 18:6a4db94011d3 | 169 | * @brief This macro enables AES key protection. |
sahilmgandhi | 18:6a4db94011d3 | 170 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 171 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 172 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 173 | */ |
sahilmgandhi | 18:6a4db94011d3 | 174 | #define AES_ENABLE_KEY_PROTECT() (CRPT->AES_CTL |= CRPT_AES_CTL_KEYPRT_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 175 | |
sahilmgandhi | 18:6a4db94011d3 | 176 | /** |
sahilmgandhi | 18:6a4db94011d3 | 177 | * @brief This macro disables AES key protection. |
sahilmgandhi | 18:6a4db94011d3 | 178 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 179 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 180 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 181 | */ |
sahilmgandhi | 18:6a4db94011d3 | 182 | #define AES_DISABLE_KEY_PROTECT() (CRPT->AES_CTL = (CRPT->AES_CTL & ~CRPT_AES_CTL_KEYPRT_Msk) | (0x16<<CRPT_AES_CTL_KEYUNPRT_Pos)) |
sahilmgandhi | 18:6a4db94011d3 | 183 | |
sahilmgandhi | 18:6a4db94011d3 | 184 | /** |
sahilmgandhi | 18:6a4db94011d3 | 185 | * @brief This macro enables TDES interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 186 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 187 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 188 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 189 | */ |
sahilmgandhi | 18:6a4db94011d3 | 190 | #define TDES_ENABLE_INT() (CRPT->INTEN |= (CRPT_INTEN_TDESIEN_Msk|CRPT_INTEN_TDESERRIEN_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 191 | |
sahilmgandhi | 18:6a4db94011d3 | 192 | /** |
sahilmgandhi | 18:6a4db94011d3 | 193 | * @brief This macro disables TDES interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 194 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 195 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 196 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 197 | */ |
sahilmgandhi | 18:6a4db94011d3 | 198 | #define TDES_DISABLE_INT() (CRPT->INTEN &= ~(CRPT_INTEN_TDESIEN_Msk|CRPT_INTEN_TDESERRIEN_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 199 | |
sahilmgandhi | 18:6a4db94011d3 | 200 | /** |
sahilmgandhi | 18:6a4db94011d3 | 201 | * @brief This macro gets TDES interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 202 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 203 | * @return TDES interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 204 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 205 | */ |
sahilmgandhi | 18:6a4db94011d3 | 206 | #define TDES_GET_INT_FLAG() (CRPT->INTSTS & (CRPT_INTSTS_TDESIF_Msk|CRPT_INTSTS_TDESERRIF_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 207 | |
sahilmgandhi | 18:6a4db94011d3 | 208 | /** |
sahilmgandhi | 18:6a4db94011d3 | 209 | * @brief This macro clears TDES interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 210 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 211 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 212 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 213 | */ |
sahilmgandhi | 18:6a4db94011d3 | 214 | #define TDES_CLR_INT_FLAG() (CRPT->INTSTS = (CRPT_INTSTS_TDESIF_Msk|CRPT_INTSTS_TDESERRIF_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 215 | |
sahilmgandhi | 18:6a4db94011d3 | 216 | /** |
sahilmgandhi | 18:6a4db94011d3 | 217 | * @brief This macro enables TDES key protection. |
sahilmgandhi | 18:6a4db94011d3 | 218 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 219 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 220 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 221 | */ |
sahilmgandhi | 18:6a4db94011d3 | 222 | #define TDES_ENABLE_KEY_PROTECT() (CRPT->TDES_CTL |= CRPT_TDES_CTL_KEYPRT_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 223 | |
sahilmgandhi | 18:6a4db94011d3 | 224 | /** |
sahilmgandhi | 18:6a4db94011d3 | 225 | * @brief This macro disables TDES key protection. |
sahilmgandhi | 18:6a4db94011d3 | 226 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 227 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 228 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 229 | */ |
sahilmgandhi | 18:6a4db94011d3 | 230 | #define TDES_DISABLE_KEY_PROTECT() (CRPT->TDES_CTL = (CRPT->TDES_CTL & ~CRPT_TDES_CTL_KEYPRT_Msk) | (0x16<<CRPT_TDES_CTL_KEYUNPRT_Pos)) |
sahilmgandhi | 18:6a4db94011d3 | 231 | |
sahilmgandhi | 18:6a4db94011d3 | 232 | /** |
sahilmgandhi | 18:6a4db94011d3 | 233 | * @brief This macro enables SHA interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 234 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 235 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 236 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 237 | */ |
sahilmgandhi | 18:6a4db94011d3 | 238 | #define SHA_ENABLE_INT() (CRPT->INTEN |= (CRPT_INTEN_SHAIEN_Msk|CRPT_INTEN_SHAERRIEN_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 239 | |
sahilmgandhi | 18:6a4db94011d3 | 240 | /** |
sahilmgandhi | 18:6a4db94011d3 | 241 | * @brief This macro disables SHA interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 242 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 243 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 244 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 245 | */ |
sahilmgandhi | 18:6a4db94011d3 | 246 | #define SHA_DISABLE_INT() (CRPT->INTEN &= ~(CRPT_INTEN_SHAIEN_Msk|CRPT_INTEN_SHAERRIEN_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 247 | |
sahilmgandhi | 18:6a4db94011d3 | 248 | /** |
sahilmgandhi | 18:6a4db94011d3 | 249 | * @brief This macro gets SHA interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 250 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 251 | * @return SHA interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 252 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 253 | */ |
sahilmgandhi | 18:6a4db94011d3 | 254 | #define SHA_GET_INT_FLAG() (CRPT->INTSTS & (CRPT_INTSTS_SHAIF_Msk|CRPT_INTSTS_SHAERRIF_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 255 | |
sahilmgandhi | 18:6a4db94011d3 | 256 | /** |
sahilmgandhi | 18:6a4db94011d3 | 257 | * @brief This macro clears SHA interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 258 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 259 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 260 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 261 | */ |
sahilmgandhi | 18:6a4db94011d3 | 262 | #define SHA_CLR_INT_FLAG() (CRPT->INTSTS = (CRPT_INTSTS_SHAIF_Msk|CRPT_INTSTS_SHAERRIF_Msk)) |
sahilmgandhi | 18:6a4db94011d3 | 263 | |
sahilmgandhi | 18:6a4db94011d3 | 264 | |
sahilmgandhi | 18:6a4db94011d3 | 265 | |
sahilmgandhi | 18:6a4db94011d3 | 266 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 267 | /* Functions */ |
sahilmgandhi | 18:6a4db94011d3 | 268 | /*---------------------------------------------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 269 | |
sahilmgandhi | 18:6a4db94011d3 | 270 | void PRNG_Open(uint32_t u32KeySize, uint32_t u32SeedReload, uint32_t u32Seed); |
sahilmgandhi | 18:6a4db94011d3 | 271 | void PRNG_Start(void); |
sahilmgandhi | 18:6a4db94011d3 | 272 | void PRNG_Read(uint32_t u32RandKey[]); |
sahilmgandhi | 18:6a4db94011d3 | 273 | void AES_Open(uint32_t u32Channel, uint32_t u32EncDec, uint32_t u32OpMode, uint32_t u32KeySize, uint32_t u32SwapType); |
sahilmgandhi | 18:6a4db94011d3 | 274 | void AES_Start(int32_t u32Channel, uint32_t u32DMAMode); |
sahilmgandhi | 18:6a4db94011d3 | 275 | void AES_SetKey(uint32_t u32Channel, uint32_t au32Keys[], uint32_t u32KeySize); |
sahilmgandhi | 18:6a4db94011d3 | 276 | void AES_SetInitVect(uint32_t u32Channel, uint32_t au32IV[]); |
sahilmgandhi | 18:6a4db94011d3 | 277 | void AES_SetDMATransfer(uint32_t u32Channel, uint32_t u32SrcAddr, uint32_t u32DstAddr, uint32_t u32TransCnt); |
sahilmgandhi | 18:6a4db94011d3 | 278 | void TDES_Open(uint32_t u32Channel, uint32_t u32EncDec, uint32_t u32OpMode, uint32_t u32SwapType); |
sahilmgandhi | 18:6a4db94011d3 | 279 | void TDES_Start(int32_t u32Channel, uint32_t u32DMAMode); |
sahilmgandhi | 18:6a4db94011d3 | 280 | void TDES_SetKey(uint32_t u32Channel, uint8_t au8Keys[3][8]); |
sahilmgandhi | 18:6a4db94011d3 | 281 | void TDES_SetInitVect(uint32_t u32Channel, uint32_t u32IVH, uint32_t u32IVL); |
sahilmgandhi | 18:6a4db94011d3 | 282 | void TDES_SetDMATransfer(uint32_t u32Channel, uint32_t u32SrcAddr, uint32_t u32DstAddr, uint32_t u32TransCnt); |
sahilmgandhi | 18:6a4db94011d3 | 283 | void SHA_Open(uint32_t u32OpMode, uint32_t u32SwapType); |
sahilmgandhi | 18:6a4db94011d3 | 284 | void SHA_Start(uint32_t u32DMAMode); |
sahilmgandhi | 18:6a4db94011d3 | 285 | void SHA_SetDMATransfer(uint32_t u32SrcAddr, uint32_t u32TransCnt); |
sahilmgandhi | 18:6a4db94011d3 | 286 | void SHA_Read(uint32_t u32Digest[]); |
sahilmgandhi | 18:6a4db94011d3 | 287 | |
sahilmgandhi | 18:6a4db94011d3 | 288 | |
sahilmgandhi | 18:6a4db94011d3 | 289 | /*@}*/ /* end of group NUC472_442_CRYPTO_EXPORTED_FUNCTIONS */ |
sahilmgandhi | 18:6a4db94011d3 | 290 | |
sahilmgandhi | 18:6a4db94011d3 | 291 | /*@}*/ /* end of group NUC472_442_CRYPTO_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 292 | |
sahilmgandhi | 18:6a4db94011d3 | 293 | /*@}*/ /* end of group NUC472_442_Device_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 294 | |
sahilmgandhi | 18:6a4db94011d3 | 295 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 296 | } |
sahilmgandhi | 18:6a4db94011d3 | 297 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 298 | |
sahilmgandhi | 18:6a4db94011d3 | 299 | #endif // __CRYPTO_H__ |
sahilmgandhi | 18:6a4db94011d3 | 300 | |
sahilmgandhi | 18:6a4db94011d3 | 301 | /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ |
sahilmgandhi | 18:6a4db94011d3 | 302 |