28 #if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__) 37 #define HAL_CRY_MAX_KEY_SIZE 32 50 #if !defined(HAL_CRY_USE_FALLBACK) || defined(__DOXYGEN__) 51 #define HAL_CRY_USE_FALLBACK FALSE 58 #if !defined(HAL_CRY_ENFORCE_FALLBACK) || defined(__DOXYGEN__) 59 #define HAL_CRY_ENFORCE_FALLBACK FALSE 66 #if HAL_CRY_ENFORCE_FALLBACK == TRUE 67 #undef HAL_CRY_USE_FALLBACK 68 #define HAL_CRY_USE_FALLBACK TRUE 112 #if HAL_CRY_ENFORCE_FALLBACK == FALSE 116 #if !defined(CRY_LLD_SUPPORTS_AES) || \ 117 !defined(CRY_LLD_SUPPORTS_AES_ECB) || \ 118 !defined(CRY_LLD_SUPPORTS_AES_CBC) || \ 119 !defined(CRY_LLD_SUPPORTS_AES_CFB) || \ 120 !defined(CRY_LLD_SUPPORTS_AES_CTR) || \ 121 !defined(CRY_LLD_SUPPORTS_AES_GCM) || \ 122 !defined(CRY_LLD_SUPPORTS_DES) || \ 123 !defined(CRY_LLD_SUPPORTS_DES_ECB) || \ 124 !defined(CRY_LLD_SUPPORTS_DES_CBC) || \ 125 !defined(CRY_LLD_SUPPORTS_SHA1) || \ 126 !defined(CRY_LLD_SUPPORTS_SHA256) || \ 127 !defined(CRY_LLD_SUPPORTS_SHA512) || \ 128 !defined(CRY_LLD_SUPPORTS_TRNG) 129 #error "CRYPTO LLD does not export the required switches" 135 #define CRY_LLD_SUPPORTS_AES FALSE 136 #define CRY_LLD_SUPPORTS_AES_ECB FALSE 137 #define CRY_LLD_SUPPORTS_AES_CBC FALSE 138 #define CRY_LLD_SUPPORTS_AES_CFB FALSE 139 #define CRY_LLD_SUPPORTS_AES_CTR FALSE 140 #define CRY_LLD_SUPPORTS_AES_GCM FALSE 141 #define CRY_LLD_SUPPORTS_DES FALSE 142 #define CRY_LLD_SUPPORTS_DES_ECB FALSE 143 #define CRY_LLD_SUPPORTS_DES_CBC FALSE 144 #define CRY_LLD_SUPPORTS_SHA1 FALSE 145 #define CRY_LLD_SUPPORTS_SHA256 FALSE 146 #define CRY_LLD_SUPPORTS_SHA512 FALSE 147 #define CRY_LLD_SUPPORTS_TRNG FALSE 167 #if HAL_CRY_USE_FALLBACK == TRUE 168 #include "hal_crypto_fallback.h" 171 #if (HAL_CRY_USE_FALLBACK == FALSE) && (CRY_LLD_SUPPORTS_SHA1 == FALSE) 179 #if (HAL_CRY_USE_FALLBACK == FALSE) && (CRY_LLD_SUPPORTS_SHA256 == FALSE) 187 #if (HAL_CRY_USE_FALLBACK == FALSE) && (CRY_LLD_SUPPORTS_SHA512 == FALSE) 219 const uint8_t *keyp);
324 size_t size,
const uint8_t *in);
329 size_t size,
const uint8_t *in);
334 size_t size,
const uint8_t *in);
cryerror_t crySHA1Final(CRYDriver *cryp, SHA1Context *sha1ctxp, uint8_t *out)
Hash finalization using SHA1.
void cryInit(void)
Cryptographic Driver initialization.
cryerror_t crySHA256Init(CRYDriver *cryp, SHA256Context *sha256ctxp)
Hash initialization using SHA256.
cryerror_t crySHA1Update(CRYDriver *cryp, SHA1Context *sha1ctxp, size_t size, const uint8_t *in)
Hash update using SHA1.
void cryStart(CRYDriver *cryp, const CRYConfig *config)
Configures and activates the cryptographic peripheral.
cryerror_t cryEncryptAES_CFB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using AES-CFB.
cryerror_t cryDecryptDES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Decryption of a single block using (T)DES.
cryerror_t cryDecryptAES_CTR(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using AES-CTR.
Type of a SHA512 context.
PLATFORM cryptographic subsystem low level driver header.
cryerror_t cryEncryptAES_GCM(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv, size_t aadsize, const uint8_t *aad, uint8_t *authtag)
Encryption operation using AES-GCM.
cryerror_t cryDecryptAES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Decryption operation using AES-ECB.
Structure representing an CRY driver.
cryerror_t cryEncryptDES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Encryption of a single block using (T)DES.
#define HAL_CRY_MAX_KEY_SIZE
Maximum size of a key for all supported algorithms.
cryerror_t cryDecryptDES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using (T)DES-CBC.
cryerror_t cryDecryptAES_GCM(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv, size_t aadsize, const uint8_t *aad, uint8_t *authtag)
Decryption operation using AES-GCM.
void cryStop(CRYDriver *cryp)
Deactivates the cryptographic peripheral.
size_t bitsize_t
Size, in bits, of a crypto field or message.
cryerror_t cryDecryptDES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Decryption operation using (T)DES-ECB.
cryerror_t crySHA1Init(CRYDriver *cryp, SHA1Context *sha1ctxp)
Hash initialization using SHA1.
cryerror_t
Driver error codes.
Driver configuration structure.
cryerror_t cryEncryptAES_CTR(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using AES-CTR.
cryalgorithm_t key0_type
Algorithm type of transient key.
cryerror_t crySHA256Update(CRYDriver *cryp, SHA256Context *sha256ctxp, size_t size, const uint8_t *in)
Hash update using SHA256.
uint32_t crykey_t
CRY key identifier type.
cryerror_t crySHA512Init(CRYDriver *cryp, SHA512Context *sha512ctxp)
Hash initialization using SHA512.
cryerror_t crySHA256Final(CRYDriver *cryp, SHA256Context *sha256ctxp, uint8_t *out)
Hash finalization using SHA256.
cryerror_t cryDecryptAES_CFB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using AES-CFB.
cryerror_t crySHA512Final(CRYDriver *cryp, SHA512Context *sha512ctxp, uint8_t *out)
Hash finalization using SHA512.
cryalgorithm_t
Type of an algorithm identifier.
size_t key0_size
Size of transient key.
cryerror_t cryEncryptAES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Encryption operation using AES-ECB.
cryerror_t cryEncryptAES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using AES-CBC.
crystate_t
Driver state machine possible states.
USBInEndpointState in
IN EP0 state.
cryerror_t cryDecryptAES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Decryption operation using AES-CBC.
crystate_t state
Driver state.
cryerror_t crySHA512Update(CRYDriver *cryp, SHA512Context *sha512ctxp, size_t size, const uint8_t *in)
Hash update using SHA512.
USBOutEndpointState out
OUT EP0 state.
cryerror_t cryLoadTransientKey(CRYDriver *cryp, cryalgorithm_t algorithm, size_t size, const uint8_t *keyp)
Initializes the transient key for a specific algorithm.
Type of a SHA256 context.
cryerror_t cryTRNG(CRYDriver *cryp, uint8_t *out)
True random numbers generator.
cryerror_t cryEncryptDES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Encryption operation using (T)DES-ECB.
const CRYConfig * config
Current configuration data.
cryerror_t cryEncryptAES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Encryption of a single block using AES.
cryerror_t cryDecryptAES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Decryption of a single block using AES.
uint8_t key0_buffer[HAL_CRY_MAX_KEY_SIZE]
Key buffer for the fall-back implementation.
void cryObjectInit(CRYDriver *cryp)
Initializes the standard part of a CRYDriver structure.
cryerror_t cryEncryptDES_CBC(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out, const uint8_t *iv)
Encryption operation using (T)DES-CBC.