Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
44 #if (M460_CRYPTO_HASH_SUPPORT == ENABLED)
57 size_t length, uint32_t *
h,
size_t hLen)
65 SYS->IPRST0 |= SYS_IPRST0_CRPTRST_Msk;
66 SYS->IPRST0 &= ~SYS_IPRST0_CRPTRST_Msk;
69 CRPT->HMAC_CTL = CRPT_HMAC_CTL_INSWAP_Msk | CRPT_HMAC_CTL_OUTSWAP_Msk |
70 CRPT_HMAC_CTL_DMACSCAD_Msk | opmode;
77 for(i = 0; i < hLen; i++)
79 CRPT->HMAC_FDBCK[2 * i] =
h[i];
85 for(i = 0; i < hLen; i++)
87 CRPT->HMAC_FDBCK[i] =
h[i];
92 CRPT->HMAC_CTL |= CRPT_HMAC_CTL_START_Msk;
95 for(i = 0; i <
length; i += 4)
98 while((CRPT->HMAC_STS & CRPT_HMAC_STS_DATINREQ_Msk) == 0)
103 CRPT->HMAC_DATIN = __UNALIGNED_UINT32_READ(
data + i);
107 while((CRPT->HMAC_STS & CRPT_HMAC_STS_DATINREQ_Msk) == 0)
116 for(i = 0; i < hLen; i++)
118 h[i] = CRPT->HMAC_FDBCK[2 * i];
124 for(i = 0; i < hLen; i++)
126 h[i] = CRPT->HMAC_FDBCK[i];
131 CRPT->HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk;
138 #if (SHA1_SUPPORT == ENABLED)
188 if(context->
size == 64)
215 #if (SHA256_SUPPORT == ENABLED)
265 if(context->
size == 64)
292 #if (SHA512_SUPPORT == ENABLED)
342 if(context->
size == 128)
369 #if (KECCAK_SUPPORT == ENABLED)
391 else if(blockSize == 104)
395 else if(blockSize == 136)
408 SYS->IPRST0 |= SYS_IPRST0_CRPTRST_Msk;
409 SYS->IPRST0 &= ~SYS_IPRST0_CRPTRST_Msk;
412 CRPT->HMAC_CTL = CRPT_HMAC_CTL_INSWAP_Msk | CRPT_HMAC_CTL_OUTSWAP_Msk |
413 CRPT_HMAC_CTL_SHA3EN_Msk | CRPT_HMAC_CTL_DMACSCAD_Msk | opmode;
416 for(i = 0; i < 16; i++)
421 for(i = 0; i < 34; i++)
427 CRPT->HMAC_CTL |= CRPT_HMAC_CTL_START_Msk;
433 for(i = 0; i <
length; i += 4)
436 while((CRPT->HMAC_STS & CRPT_HMAC_STS_DATINREQ_Msk) == 0)
441 CRPT->HMAC_DATIN = __UNALIGNED_UINT32_READ(
data + i);
447 for(i = 0; i <
length; i += 4)
450 while((CRPT->HMAC_STS & CRPT_HMAC_STS_DATINREQ_Msk) == 0)
455 CRPT->HMAC_DATIN = 0;
460 while((CRPT->HMAC_STS & CRPT_HMAC_STS_DATINREQ_Msk) == 0)
465 for(i = 0; i < 34; i++)
470 for(i = 0; i < 16; i++)
476 CRPT->HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk;
505 (uint32_t *) context->
a);
508 input = (uint8_t *) input +
n;
523 input = (uint8_t *) input +
n;
551 (uint32_t *) context->
a);
void hashProcessData(uint32_t opmode, const uint8_t *data, size_t length, uint32_t *h, size_t hLen)
Update hash value.
SHA-256 algorithm context.
#define CRPT_HMAC_CTL_OPMODE_SHA256
void sha256ProcessBlock(Sha256Context *context)
Process message in 16-word blocks.
#define CRPT_HMAC_CTL_OPMODE_SHA3_224
void sha512ProcessBlock(Sha512Context *context)
Process message in 16-word blocks.
void keccakPermutBlock(KeccakContext *context)
Block permutation.
#define CRPT_HMAC_CTL_OPMODE_SHA512
#define CRPT_HMAC_CTL_OPMODE_SHA1
void sha1Update(Sha1Context *context, const void *data, size_t length)
Update the SHA-1 context with a portion of the message being hashed.
#define osMemcpy(dest, src, length)
M460 hash hardware accelerator.
void keccakProcessData(const uint8_t *data, size_t length, size_t blockSize, uint32_t *a)
Update state array.
SHA-512 algorithm context.
General definitions for cryptographic algorithms.
#define CRPT_HMAC_CTL_OPMODE_SHA3_256
Collection of hash algorithms.
void keccakAbsorb(KeccakContext *context, const void *input, size_t length)
Absorb data.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
#define CRPT_HMAC_CTL_OPMODE_SHA224
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void sha1ProcessBlock(Sha1Context *context)
Process message in 16-word blocks.
M460 hardware cryptographic accelerator.
uint32_t reverseInt32(uint32_t value)
Reverse bit order in a 32-bit word.
#define CRPT_HMAC_CTL_OPMODE_SHA3_512
#define CRPT_HMAC_CTL_OPMODE_SHA3_384
#define SHA256_DIGEST_SIZE
#define SHA512_DIGEST_SIZE
void sha512Update(Sha512Context *context, const void *data, size_t length)
Update the SHA-512 context with a portion of the message being hashed.
void sha256Update(Sha256Context *context, const void *data, size_t length)
Update the SHA-256 context with a portion of the message being hashed.