64 #include <inc/hw_types.h>
65 #include <inc/hw_memmap.h>
66 #include <inc/hw_ints.h>
67 #include <inc/hw_crypto.h>
86 #define CRYPTOAesLoadKey NOROM_CRYPTOAesLoadKey
87 #define CRYPTOAesCbc NOROM_CRYPTOAesCbc
88 #define CRYPTOAesCbcStatus NOROM_CRYPTOAesCbcStatus
89 #define CRYPTOAesEcb NOROM_CRYPTOAesEcb
90 #define CRYPTOAesEcbStatus NOROM_CRYPTOAesEcbStatus
91 #define CRYPTOCcmAuthEncrypt NOROM_CRYPTOCcmAuthEncrypt
92 #define CRYPTOCcmAuthEncryptStatus NOROM_CRYPTOCcmAuthEncryptStatus
93 #define CRYPTOCcmAuthEncryptResultGet NOROM_CRYPTOCcmAuthEncryptResultGet
94 #define CRYPTOCcmInvAuthDecrypt NOROM_CRYPTOCcmInvAuthDecrypt
95 #define CRYPTOCcmInvAuthDecryptStatus NOROM_CRYPTOCcmInvAuthDecryptStatus
96 #define CRYPTOCcmInvAuthDecryptResultGet NOROM_CRYPTOCcmInvAuthDecryptResultGet
97 #define CRYPTODmaEnable NOROM_CRYPTODmaEnable
98 #define CRYPTODmaDisable NOROM_CRYPTODmaDisable
106 #define AES_ECB_LENGTH 16
114 #define CRYPTO_DMA_IN_DONE 0x00000002 // DMA done interrupt mask
115 #define CRYPTO_RESULT_RDY 0x00000001 // Result ready interrupt mask
116 #define CRYPTO_DMA_BUS_ERR 0x80000000 // DMA Bus error
117 #define CRYPTO_KEY_ST_WR_ERR 0x40000000 // Key Store Write failed
118 #define CRYPTO_KEY_ST_RD_ERR 0x20000000 // Key Store Read failed
121 #define CRYPTO_IRQTYPE_PULSE 0x00000000 // Crypto pulse interrupt enabled
123 #define CRYPTO_DMA_CHAN0 0x00000001 // Crypto DMA Channel 0
124 #define CRYPTO_DMA_CHAN1 0x00000002 // Crypto DMA Channel 1
126 #define CRYPTO_AES128_ENCRYPT 0x0000000C //
127 #define CRYPTO_AES128_DECRYPT 0x00000008 //
129 #define CRYPTO_DMA_READY 0x00000000 // DMA ready
130 #define CRYPTO_DMA_BSY 0x00000003 // DMA busy
131 #define CRYPTO_DMA_BUS_ERROR 0x00020000 // DMA encountered bus error
140 #define AES_SUCCESS 0
141 #define AES_KEYSTORE_READ_ERROR 1
142 #define AES_KEYSTORE_WRITE_ERROR 2
143 #define AES_DMA_BUS_ERROR 3
144 #define CCM_AUTHENTICATION_FAILED 4
145 #define AES_ECB_TEST_ERROR 8
146 #define AES_NULL_ERROR 9
147 #define AES_CCM_TEST_ERROR 10
148 #define AES_DMA_BSY 11
151 #define STATE_BLENGTH 16 // Number of bytes in State
152 #define KEY_BLENGTH 16 // Number of bytes in Key
153 #define KEY_EXP_LENGTH 176 // Nb * (Nr+1) * 4
155 #define KEY_STORE_SIZE_128 0x00000001
156 #define KEY_STORE_SIZE_192 0x00000002
157 #define KEY_STORE_SIZE_256 0x00000003
158 #define KEY_STORE_SIZE_BITS 0x00000003
167 #define CRYPTO_KEY_AREA_0 0
168 #define CRYPTO_KEY_AREA_1 1
169 #define CRYPTO_KEY_AREA_2 2
170 #define CRYPTO_KEY_AREA_3 3
171 #define CRYPTO_KEY_AREA_4 4
172 #define CRYPTO_KEY_AREA_5 5
173 #define CRYPTO_KEY_AREA_6 6
174 #define CRYPTO_KEY_AREA_7 7
181 #define CRYPTO_AES_NONE 0
182 #define CRYPTO_AES_KEYL0AD 1
183 #define CRYPTO_AES_ECB 2
184 #define CRYPTO_AES_CCM 3
185 #define CRYPTO_AES_RNG 4
186 #define CRYPTO_AES_CBC 5
193 #define CRYPTO_AES_CTR_32 0x0
194 #define CRYPTO_AES_CTR_64 0x1
195 #define CRYPTO_AES_CTR_96 0x2
196 #define CRYPTO_AES_CTR_128 0x3
231 uint32_t ui32KeyLocation);
266 extern uint32_t
CRYPTOAesCbc(uint32_t *pui32MsgIn, uint32_t *pui32MsgOut,
267 uint32_t ui32MsgLength, uint32_t *pui32Nonce,
268 uint32_t ui32KeyLocation,
bool bEncrypt,
318 extern uint32_t
CRYPTOAesEcb(uint32_t *pui32MsgIn, uint32_t *pui32MsgOut,
319 uint32_t ui32KeyLocation,
bool bEncrypt,
423 uint32_t *pui32Nonce,
424 uint32_t *pui32PlainText,
425 uint32_t ui32PlainTextLength,
426 uint32_t *pui32Header,
427 uint32_t ui32HeaderLength,
428 uint32_t ui32KeyLocation,
429 uint32_t ui32FieldLength,
464 uint32_t *pui32CcmTag);
502 uint32_t *pui32Nonce,
503 uint32_t *pui32CipherText,
504 uint32_t ui32CipherTextLength,
505 uint32_t *pui32Header,
506 uint32_t ui32HeaderLength,
507 uint32_t ui32KeyLocation,
508 uint32_t ui32FieldLength,
537 uint32_t *pui32CipherText,
538 uint32_t ui32CipherTextLength,
539 uint32_t *pui32CcmTag);
557 __STATIC_INLINE uint32_t
678 __STATIC_INLINE uint32_t
767 IntRegister(INT_CRYPTO_RESULT_AVAIL_IRQ, pfnHandler);
810 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
812 #ifdef ROM_CRYPTOAesLoadKey
813 #undef CRYPTOAesLoadKey
814 #define CRYPTOAesLoadKey ROM_CRYPTOAesLoadKey
816 #ifdef ROM_CRYPTOAesCbc
818 #define CRYPTOAesCbc ROM_CRYPTOAesCbc
820 #ifdef ROM_CRYPTOAesCbcStatus
821 #undef CRYPTOAesCbcStatus
822 #define CRYPTOAesCbcStatus ROM_CRYPTOAesCbcStatus
824 #ifdef ROM_CRYPTOAesEcb
826 #define CRYPTOAesEcb ROM_CRYPTOAesEcb
828 #ifdef ROM_CRYPTOAesEcbStatus
829 #undef CRYPTOAesEcbStatus
830 #define CRYPTOAesEcbStatus ROM_CRYPTOAesEcbStatus
832 #ifdef ROM_CRYPTOCcmAuthEncrypt
833 #undef CRYPTOCcmAuthEncrypt
834 #define CRYPTOCcmAuthEncrypt ROM_CRYPTOCcmAuthEncrypt
836 #ifdef ROM_CRYPTOCcmAuthEncryptStatus
837 #undef CRYPTOCcmAuthEncryptStatus
838 #define CRYPTOCcmAuthEncryptStatus ROM_CRYPTOCcmAuthEncryptStatus
840 #ifdef ROM_CRYPTOCcmAuthEncryptResultGet
841 #undef CRYPTOCcmAuthEncryptResultGet
842 #define CRYPTOCcmAuthEncryptResultGet ROM_CRYPTOCcmAuthEncryptResultGet
844 #ifdef ROM_CRYPTOCcmInvAuthDecrypt
845 #undef CRYPTOCcmInvAuthDecrypt
846 #define CRYPTOCcmInvAuthDecrypt ROM_CRYPTOCcmInvAuthDecrypt
848 #ifdef ROM_CRYPTOCcmInvAuthDecryptStatus
849 #undef CRYPTOCcmInvAuthDecryptStatus
850 #define CRYPTOCcmInvAuthDecryptStatus ROM_CRYPTOCcmInvAuthDecryptStatus
852 #ifdef ROM_CRYPTOCcmInvAuthDecryptResultGet
853 #undef CRYPTOCcmInvAuthDecryptResultGet
854 #define CRYPTOCcmInvAuthDecryptResultGet ROM_CRYPTOCcmInvAuthDecryptResultGet
856 #ifdef ROM_CRYPTODmaEnable
857 #undef CRYPTODmaEnable
858 #define CRYPTODmaEnable ROM_CRYPTODmaEnable
860 #ifdef ROM_CRYPTODmaDisable
861 #undef CRYPTODmaDisable
862 #define CRYPTODmaDisable ROM_CRYPTODmaDisable
875 #endif // __CRYPTO_H__
static uint32_t CRYPTODmaStatus(void)
Get the current status of the Crypto DMA controller.
uint32_t CRYPTOCcmAuthEncryptStatus(void)
Check the result of an AES CCM operation.
#define CRYPTO_RESULT_RDY
static void CRYPTOIntClear(uint32_t ui32IntFlags)
Clears Crypto interrupt sources.
uint32_t CRYPTOAesCbc(uint32_t *pui32MsgIn, uint32_t *pui32MsgOut, uint32_t ui32MsgLength, uint32_t *pui32Nonce, uint32_t ui32KeyLocation, bool bEncrypt, bool bIntEnable)
Start an AES-CBC operation (encryption or decryption).
static void CRYPTOIntUnregister(void)
Unregisters an interrupt handler for a Crypto interrupt.
uint32_t CRYPTOCcmInvAuthDecrypt(bool bDecrypt, uint32_t ui32AuthLength, uint32_t *pui32Nonce, uint32_t *pui32CipherText, uint32_t ui32CipherTextLength, uint32_t *pui32Header, uint32_t ui32HeaderLength, uint32_t ui32KeyLocation, uint32_t ui32FieldLength, bool bIntEnable)
Start a CCM Decryption and Inverse Authentication operation.
static void CRYPTOIntEnable(uint32_t ui32IntFlags)
Enables individual Crypto interrupt sources.
uint32_t CRYPTOAesLoadKey(uint32_t *pui32AesKey, uint32_t ui32KeyLocation)
Write the key into the Key Ram.
static void CRYPTOAesCbcFinish(void)
Finish the encryption operation by resetting the operation mode.
uint32_t CRYPTOCcmAuthEncryptResultGet(uint32_t ui32TagLength, uint32_t *pui32CcmTag)
Get the result of an AES CCM operation.
#define CRYPTO_DMA_IN_DONE
uint32_t CRYPTOCcmInvAuthDecryptStatus(void)
Checks CCM decrypt and Inverse Authentication result.
static void CRYPTOIntRegister(void(*pfnHandler)(void))
Registers an interrupt handler for a Crypto interrupt.
static void CRYPTOIntDisable(uint32_t ui32IntFlags)
Disables individual CRYPTO interrupt sources.
uint32_t CRYPTOCcmInvAuthDecryptResultGet(uint32_t ui32AuthLength, uint32_t *pui32CipherText, uint32_t ui32CipherTextLength, uint32_t *pui32CcmTag)
Get the result of the CCM operation.
uint32_t CRYPTOAesEcbStatus(void)
Check the result of an AES ECB operation.
static void CRYPTOAesEcbFinish(void)
Finish the encryption operation by resetting the operation mode.
void IntUnregister(uint32_t ui32Interrupt)
Unregisters the function to be called when an interrupt occurs.
static uint32_t CRYPTOIntStatus(bool bMasked)
Gets the current interrupt status.
void CRYPTODmaDisable(uint32_t ui32Channels)
Disable Crypto DMA operation.
uint32_t CRYPTOAesEcb(uint32_t *pui32MsgIn, uint32_t *pui32MsgOut, uint32_t ui32KeyLocation, bool bEncrypt, bool bIntEnable)
Start an AES-ECB operation (encryption or decryption).
void CRYPTODmaEnable(uint32_t ui32Channels)
Enable Crypto DMA operation.
uint32_t CRYPTOAesCbcStatus(void)
Check the result of an AES CBC operation.
void IntDisable(uint32_t ui32Interrupt)
Disables an interrupt.
void IntRegister(uint32_t ui32Interrupt, void(*pfnHandler)(void))
Registers a function to be called when an interrupt occurs.
void IntEnable(uint32_t ui32Interrupt)
Enables an interrupt.
uint32_t CRYPTOCcmAuthEncrypt(bool bEncrypt, uint32_t ui32AuthLength, uint32_t *pui32Nonce, uint32_t *pui32PlainText, uint32_t ui32PlainTextLength, uint32_t *pui32Header, uint32_t ui32HeaderLength, uint32_t ui32KeyLocation, uint32_t ui32FieldLength, bool bIntEnable)
Start CCM operation.