27 #if (HAL_USE_CRY == TRUE) || defined(__DOXYGEN__) 58 #if HAL_CRY_ENFORCE_FALLBACK == FALSE 74 #if defined(CRY_DRIVER_EXT_INIT_HOOK) 75 CRY_DRIVER_EXT_INIT_HOOK(cryp);
96 #if HAL_CRY_ENFORCE_FALLBACK == FALSE 119 #if HAL_CRY_ENFORCE_FALLBACK == FALSE 149 const uint8_t *keyp) {
156 #if HAL_CRY_ENFORCE_FALLBACK == FALSE 163 #if HAL_CRY_USE_FALLBACK == TRUE 165 err = cry_fallback_loadkey(cryp, algorithm, size, keyp);
204 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL));
208 #if CRY_LLD_SUPPORTS_AES == TRUE 210 #elif HAL_CRY_USE_FALLBACK == TRUE 211 return cry_fallback_encrypt_AES(cryp, key_id, in, out);
248 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL));
252 #if CRY_LLD_SUPPORTS_AES == TRUE 254 #elif HAL_CRY_USE_FALLBACK == TRUE 255 return cry_fallback_decrypt_AES(cryp, key_id, in, out);
296 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
297 ((size & (
size_t)15) == (
size_t)0));
301 #if CRY_LLD_SUPPORTS_AES_ECB == TRUE 303 #elif HAL_CRY_USE_FALLBACK == TRUE 304 return cry_fallback_encrypt_AES_ECB(cryp, key_id, size, in, out);
346 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
347 ((size & (
size_t)15) == (
size_t)0));
351 #if CRY_LLD_SUPPORTS_AES_ECB == TRUE 353 #elif HAL_CRY_USE_FALLBACK == TRUE 354 return cry_fallback_decrypt_AES_ECB(cryp, key_id, size, in, out);
398 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
399 (iv != NULL) && ((size & (
size_t)15) == (
size_t)0));
403 #if CRY_LLD_SUPPORTS_AES_CBC == TRUE 405 #elif HAL_CRY_USE_FALLBACK == TRUE 406 return cry_fallback_encrypt_AES_CBC(cryp, key_id, size, in, out, iv);
451 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
452 (iv != NULL) && ((size & (
size_t)15) == (
size_t)0));
456 #if CRY_LLD_SUPPORTS_AES_CBC == TRUE 458 #elif HAL_CRY_USE_FALLBACK == TRUE 459 return cry_fallback_decrypt_AES_CBC(cryp, key_id, size, in, out, iv);
504 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
505 (iv != NULL) && ((size & (
size_t)15) == (
size_t)0));
509 #if CRY_LLD_SUPPORTS_AES_CFB == TRUE 511 #elif HAL_CRY_USE_FALLBACK == TRUE 512 return cry_fallback_encrypt_AES_CFB(cryp, key_id, size, in, out, iv);
557 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
558 (iv != NULL) && ((size & (
size_t)15) == (
size_t)0));
562 #if CRY_LLD_SUPPORTS_AES_CFB == TRUE 564 #elif HAL_CRY_USE_FALLBACK == TRUE 565 return cry_fallback_decrypt_AES_CFB(cryp, key_id, size, in, out, iv);
611 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
612 (iv != NULL) && ((size & (
size_t)15) == (
size_t)0));
616 #if CRY_LLD_SUPPORTS_AES_CTR == TRUE 618 #elif HAL_CRY_USE_FALLBACK == TRUE 619 return cry_fallback_encrypt_AES_CTR(cryp, key_id, size, in, out, iv);
666 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
667 (iv != NULL) && ((size & (
size_t)15) == (
size_t)0));
671 #if CRY_LLD_SUPPORTS_AES_CTR == TRUE 673 #elif HAL_CRY_USE_FALLBACK == TRUE 674 return cry_fallback_decrypt_AES_CTR(cryp, key_id, size, in, out, iv);
729 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
730 (iv != NULL) && (aad != NULL) && (authtag != NULL) &&
731 ((size & (
size_t)15) == (
size_t)0) &&
732 ((aadsize & (
size_t)15) == (
size_t)0));
736 #if CRY_LLD_SUPPORTS_AES_GCM== TRUE 738 aadsize, aad, authtag);
739 #elif HAL_CRY_USE_FALLBACK == TRUE 740 return cry_fallback_encrypt_AES_GCM(cryp, key_id, size, in, out, iv,
741 aadsize, aad, authtag);
798 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
799 (iv != NULL) && (aad != NULL) && (authtag != NULL) &&
800 ((size & (
size_t)15) == (
size_t)0) &&
801 ((aadsize & (
size_t)15) == (
size_t)0));
805 #if CRY_LLD_SUPPORTS_AES_GCM== TRUE 807 aadsize, aad, authtag);
808 #elif HAL_CRY_USE_FALLBACK == TRUE 809 return cry_fallback_decrypt_AES_GCM(cryp, key_id, size, in, out, iv,
810 aadsize, aad, authtag);
852 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL));
856 #if CRY_LLD_SUPPORTS_DES == TRUE 858 #elif HAL_CRY_USE_FALLBACK == TRUE 859 return cry_fallback_encrypt_DES(cryp, key_id, in, out);
897 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL));
901 #if CRY_LLD_SUPPORTS_DES == TRUE 903 #elif HAL_CRY_USE_FALLBACK == TRUE 904 return cry_fallback_decrypt_DES(cryp, key_id, in, out);
945 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
946 ((size & (
size_t)7) == (
size_t)0));
950 #if CRY_LLD_SUPPORTS_DES_ECB == TRUE 952 #elif HAL_CRY_USE_FALLBACK == TRUE 953 return cry_fallback_encrypt_DES_ECB(cryp, key_id, size, in, out);
995 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
996 ((size & (
size_t)7) == (
size_t)0));
1000 #if CRY_LLD_SUPPORTS_DES_ECB == TRUE 1002 #elif HAL_CRY_USE_FALLBACK == TRUE 1003 return cry_fallback_decrypt_DES_ECB(cryp, key_id, size, in, out);
1045 const uint8_t *iv) {
1047 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
1048 (iv != NULL) && ((size & (
size_t)7) == (
size_t)0));
1052 #if CRY_LLD_SUPPORTS_DES_CBC == TRUE 1054 #elif HAL_CRY_USE_FALLBACK == TRUE 1055 return cry_fallback_encrypt_DES_CBC(cryp, key_id, size, in, out, iv);
1098 const uint8_t *iv) {
1100 osalDbgCheck((cryp != NULL) && (in != NULL) && (out != NULL) &&
1101 (iv != NULL) && ((size & (
size_t)7) == (
size_t)0));
1105 #if CRY_LLD_SUPPORTS_DES_CBC == TRUE 1107 #elif HAL_CRY_USE_FALLBACK == TRUE 1108 return cry_fallback_decrypt_DES_CBC(cryp, key_id, size, in, out, iv);
1140 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1142 #elif HAL_CRY_USE_FALLBACK == TRUE 1143 return cry_fallback_SHA1_init(cryp, sha1ctxp);
1168 size_t size,
const uint8_t *
in) {
1170 osalDbgCheck((cryp != NULL) && (sha1ctxp != NULL) && (in != NULL));
1174 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1176 #elif HAL_CRY_USE_FALLBACK == TRUE 1177 return cry_fallback_SHA1_update(cryp, sha1ctxp, size, in);
1204 osalDbgCheck((cryp != NULL) && (sha1ctxp != NULL) && (out != NULL));
1208 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1210 #elif HAL_CRY_USE_FALLBACK == TRUE 1211 return cry_fallback_SHA1_final(cryp, sha1ctxp, out);
1240 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1242 #elif HAL_CRY_USE_FALLBACK == TRUE 1243 return cry_fallback_SHA256_init(cryp, sha256ctxp);
1268 size_t size,
const uint8_t *
in) {
1270 osalDbgCheck((cryp != NULL) && (sha256ctxp != NULL) && (in != NULL));
1274 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1276 #elif HAL_CRY_USE_FALLBACK == TRUE 1277 return cry_fallback_SHA256_update(cryp, sha256ctxp, size, in);
1305 osalDbgCheck((cryp != NULL) && (sha256ctxp != NULL) && (out != NULL));
1309 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1311 #elif HAL_CRY_USE_FALLBACK == TRUE 1312 return cry_fallback_SHA256_final(cryp, sha256ctxp, out);
1341 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1343 #elif HAL_CRY_USE_FALLBACK == TRUE 1344 return cry_fallback_SHA512_init(cryp, sha512ctxp);
1369 size_t size,
const uint8_t *
in) {
1371 osalDbgCheck((cryp != NULL) && (sha512ctxp != NULL) && (in != NULL));
1375 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1377 #elif HAL_CRY_USE_FALLBACK == TRUE 1378 return cry_fallback_SHA512_update(cryp, sha512ctxp, size, in);
1406 osalDbgCheck((cryp != NULL) && (sha512ctxp != NULL) && (out != NULL));
1410 #if CRY_LLD_SUPPORTS_SHA1 == TRUE 1412 #elif HAL_CRY_USE_FALLBACK == TRUE 1413 return cry_fallback_SHA512_final(cryp, sha512ctxp, out);
1441 #if CRY_LLD_SUPPORTS_TRNG == TRUE 1443 #elif HAL_CRY_USE_FALLBACK == TRUE 1444 return cry_fallback_TRNG(cryp, out);
cryerror_t crySHA1Final(CRYDriver *cryp, SHA1Context *sha1ctxp, uint8_t *out)
Hash finalization using SHA1.
cryerror_t cry_lld_SHA1_init(CRYDriver *cryp, SHA1Context *sha1ctxp)
Hash initialization using SHA1.
cryerror_t cry_lld_decrypt_AES_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 cryInit(void)
Cryptographic Driver initialization.
cryerror_t cry_lld_decrypt_AES_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 cry_lld_encrypt_AES_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.
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 cry_lld_SHA1_final(CRYDriver *cryp, SHA1Context *sha1ctxp, uint8_t *out)
Hash finalization using SHA1.
cryerror_t cry_lld_SHA1_update(CRYDriver *cryp, SHA1Context *sha1ctxp, size_t size, const uint8_t *in)
Hash update using SHA1.
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.
cryerror_t cry_lld_decrypt_DES_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 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.
cryerror_t cry_lld_TRNG(CRYDriver *cryp, uint8_t *out)
True random numbers generator.
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.
cryerror_t cry_lld_encrypt_DES_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.
#define HAL_CRY_MAX_KEY_SIZE
Maximum size of a key for all supported algorithms.
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
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.
void cry_lld_stop(CRYDriver *cryp)
Deactivates the crypto peripheral.
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.
cryerror_t cry_lld_encrypt_AES_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_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.
cryerror_t cry_lld_encrypt_AES_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 cry_lld_decrypt_AES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Decryption operation using AES-ECB.
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.
void cry_lld_start(CRYDriver *cryp)
Configures and activates the crypto peripheral.
uint32_t crykey_t
CRY key identifier type.
cryerror_t cry_lld_decrypt_AES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Decryption of a single block using AES.
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 cry_lld_SHA512_init(CRYDriver *cryp, SHA512Context *sha512ctxp)
Hash initialization using SHA512.
#define osalDbgCheck(c)
Function parameters check.
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.
void cry_lld_init(void)
Low level crypto driver initialization.
cryerror_t cry_lld_SHA512_final(CRYDriver *cryp, SHA512Context *sha512ctxp, uint8_t *out)
Hash finalization using SHA512.
cryerror_t cry_lld_decrypt_AES_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.
cryerror_t crySHA512Final(CRYDriver *cryp, SHA512Context *sha512ctxp, uint8_t *out)
Hash finalization using SHA512.
cryalgorithm_t
Type of an algorithm identifier.
cryerror_t cry_lld_encrypt_AES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Encryption operation using AES-ECB.
cryerror_t cry_lld_decrypt_DES_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 cry_lld_encrypt_DES_ECB(CRYDriver *cryp, crykey_t key_id, size_t size, const uint8_t *in, uint8_t *out)
Encryption operation using (T)DES-ECB.
cryerror_t cry_lld_decrypt_DES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Decryption of a single block using (T)DES.
static void osalSysLock(void)
Enters a critical zone from thread context.
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.
cryerror_t cry_lld_encrypt_AES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Encryption of a single block using AES.
cryerror_t cry_lld_SHA512_update(CRYDriver *cryp, SHA512Context *sha512ctxp, size_t size, const uint8_t *in)
Hash update using SHA512.
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.
#define osalDbgAssert(c, remark)
Condition assertion.
cryerror_t cry_lld_SHA256_init(CRYDriver *cryp, SHA256Context *sha256ctxp)
Hash initialization using SHA256.
cryerror_t cry_lld_decrypt_AES_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 cry_lld_encrypt_DES(CRYDriver *cryp, crykey_t key_id, const uint8_t *in, uint8_t *out)
Encryption of a single block using (T)DES.
cryerror_t cry_lld_loadkey(CRYDriver *cryp, cryalgorithm_t algorithm, size_t size, const uint8_t *keyp)
Initializes the transient key for a specific algorithm.
cryerror_t cryLoadTransientKey(CRYDriver *cryp, cryalgorithm_t algorithm, size_t size, const uint8_t *keyp)
Initializes the transient key for a specific algorithm.
cryerror_t cry_lld_SHA256_update(CRYDriver *cryp, SHA256Context *sha256ctxp, size_t size, const uint8_t *in)
Hash update using SHA256.
Type of a SHA256 context.
cryerror_t cryTRNG(CRYDriver *cryp, uint8_t *out)
True random numbers generator.
cryerror_t cry_lld_SHA256_final(CRYDriver *cryp, SHA256Context *sha256ctxp, uint8_t *out)
Hash finalization using SHA256.
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.
cryerror_t cry_lld_encrypt_AES_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.
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.