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 CRYPTOAesEcb NOROM_CRYPTOAesEcb
88 #define CRYPTOAesEcbStatus NOROM_CRYPTOAesEcbStatus
89 #define CRYPTOCcmAuthEncrypt NOROM_CRYPTOCcmAuthEncrypt
90 #define CRYPTOCcmAuthEncryptStatus NOROM_CRYPTOCcmAuthEncryptStatus
91 #define CRYPTOCcmAuthEncryptResultGet NOROM_CRYPTOCcmAuthEncryptResultGet
92 #define CRYPTOCcmInvAuthDecrypt NOROM_CRYPTOCcmInvAuthDecrypt
93 #define CRYPTOCcmInvAuthDecryptStatus NOROM_CRYPTOCcmInvAuthDecryptStatus
94 #define CRYPTOCcmInvAuthDecryptResultGet NOROM_CRYPTOCcmInvAuthDecryptResultGet
95 #define CRYPTODmaEnable NOROM_CRYPTODmaEnable
96 #define CRYPTODmaDisable NOROM_CRYPTODmaDisable
104 #define AES_ECB_LENGTH 16
112 #define CRYPTO_DMA_IN_DONE 0x00000002 // DMA done interrupt mask
113 #define CRYPTO_RESULT_RDY 0x00000001 // Result ready interrupt mask
114 #define CRYPTO_DMA_BUS_ERR 0x80000000 // DMA Bus error
115 #define CRYPTO_KEY_ST_WR_ERR 0x40000000 // Key Store Write failed
116 #define CRYPTO_KEY_ST_RD_ERR 0x20000000 // Key Store Read failed
118 #define CRYPTO_INT_LEVEL 0x00000001 // Crypto Level interrupt enabled
119 #define CRYPTO_INT_PULSE 0x00000000 // Crypto pulse interrupt enabled
121 #define CRYPTO_DMA_CHAN0 0x00000001 // Crypto DMA Channel 0
122 #define CRYPTO_DMA_CHAN1 0x00000002 // Crypto DMA Channel 1
124 #define CRYPTO_AES128_ENCRYPT 0x0000000C //
125 #define CRYPTO_AES128_DECRYPT 0x00000008 //
127 #define CRYPTO_DMA_READY 0x00000000 // DMA ready
128 #define CRYPTO_DMA_BSY 0x00000003 // DMA busy
129 #define CRYPTO_DMA_BUS_ERROR 0x00020000 // DMA encountered bus error
138 #define AES_SUCCESS 0
139 #define AES_KEYSTORE_READ_ERROR 1
140 #define AES_KEYSTORE_WRITE_ERROR 2
141 #define AES_DMA_BUS_ERROR 3
142 #define CCM_AUTHENTICATION_FAILED 4
143 #define AES_ECB_TEST_ERROR 8
144 #define AES_NULL_ERROR 9
145 #define AES_CCM_TEST_ERROR 10
146 #define AES_DMA_BSY 11
149 #define STATE_BLENGTH 16 // Number of bytes in State
150 #define KEY_BLENGTH 16 // Number of bytes in Key
151 #define KEY_EXP_LENGTH 176 // Nb * (Nr+1) * 4
153 #define KEY_STORE_SIZE_128 0x00000001
154 #define KEY_STORE_SIZE_192 0x00000002
155 #define KEY_STORE_SIZE_256 0x00000003
156 #define KEY_STORE_SIZE_BITS 0x00000003
165 #define CRYPTO_KEY_AREA_0 0
166 #define CRYPTO_KEY_AREA_1 1
167 #define CRYPTO_KEY_AREA_2 2
168 #define CRYPTO_KEY_AREA_3 3
169 #define CRYPTO_KEY_AREA_4 4
170 #define CRYPTO_KEY_AREA_5 5
171 #define CRYPTO_KEY_AREA_6 6
172 #define CRYPTO_KEY_AREA_7 7
179 #define CRYPTO_AES_NONE 0
180 #define CRYPTO_AES_KEYL0AD 1
181 #define CRYPTO_AES_ECB 2
182 #define CRYPTO_AES_CCM 3
183 #define CRYPTO_AES_RNG 4
190 #define CRYPTO_AES_CTR_32 0x0
191 #define CRYPTO_AES_CTR_64 0x1
192 #define CRYPTO_AES_CTR_96 0x2
193 #define CRYPTO_AES_CTR_128 0x3
228 uint32_t ui32KeyLocation);
260 extern uint32_t
CRYPTOAesEcb(uint32_t *pui32MsgIn, uint32_t *pui32MsgOut,
261 uint32_t ui32KeyLocation,
bool bEncrypt,
342 uint32_t *pui32Nonce,
343 uint32_t *pui32PlainText,
344 uint32_t ui32PlainTextLength,
345 uint32_t *pui32Header,
346 uint32_t ui32HeaderLength,
347 uint32_t ui32KeyLocation,
348 uint32_t ui32FieldLength,
383 uint32_t *pui32CcmTag);
421 uint32_t *pui32Nonce,
422 uint32_t *pui32CipherText,
423 uint32_t ui32CipherTextLength,
424 uint32_t *pui32Header,
425 uint32_t ui32HeaderLength,
426 uint32_t ui32KeyLocation,
427 uint32_t ui32FieldLength,
456 uint32_t *pui32CipherText,
457 uint32_t ui32CipherTextLength,
458 uint32_t *pui32CcmTag);
476 __STATIC_INLINE uint32_t
597 __STATIC_INLINE uint32_t
729 #if !defined(DRIVERLIB_NOROM) && !defined(DOXYGEN)
731 #ifdef ROM_CRYPTOAesLoadKey
732 #undef CRYPTOAesLoadKey
733 #define CRYPTOAesLoadKey ROM_CRYPTOAesLoadKey
735 #ifdef ROM_CRYPTOAesEcb
737 #define CRYPTOAesEcb ROM_CRYPTOAesEcb
739 #ifdef ROM_CRYPTOAesEcbStatus
740 #undef CRYPTOAesEcbStatus
741 #define CRYPTOAesEcbStatus ROM_CRYPTOAesEcbStatus
743 #ifdef ROM_CRYPTOCcmAuthEncrypt
744 #undef CRYPTOCcmAuthEncrypt
745 #define CRYPTOCcmAuthEncrypt ROM_CRYPTOCcmAuthEncrypt
747 #ifdef ROM_CRYPTOCcmAuthEncryptStatus
748 #undef CRYPTOCcmAuthEncryptStatus
749 #define CRYPTOCcmAuthEncryptStatus ROM_CRYPTOCcmAuthEncryptStatus
751 #ifdef ROM_CRYPTOCcmAuthEncryptResultGet
752 #undef CRYPTOCcmAuthEncryptResultGet
753 #define CRYPTOCcmAuthEncryptResultGet ROM_CRYPTOCcmAuthEncryptResultGet
755 #ifdef ROM_CRYPTOCcmInvAuthDecrypt
756 #undef CRYPTOCcmInvAuthDecrypt
757 #define CRYPTOCcmInvAuthDecrypt ROM_CRYPTOCcmInvAuthDecrypt
759 #ifdef ROM_CRYPTOCcmInvAuthDecryptStatus
760 #undef CRYPTOCcmInvAuthDecryptStatus
761 #define CRYPTOCcmInvAuthDecryptStatus ROM_CRYPTOCcmInvAuthDecryptStatus
763 #ifdef ROM_CRYPTOCcmInvAuthDecryptResultGet
764 #undef CRYPTOCcmInvAuthDecryptResultGet
765 #define CRYPTOCcmInvAuthDecryptResultGet ROM_CRYPTOCcmInvAuthDecryptResultGet
767 #ifdef ROM_CRYPTODmaEnable
768 #undef CRYPTODmaEnable
769 #define CRYPTODmaEnable ROM_CRYPTODmaEnable
771 #ifdef ROM_CRYPTODmaDisable
772 #undef CRYPTODmaDisable
773 #define CRYPTODmaDisable ROM_CRYPTODmaDisable
786 #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.
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.
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.
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.