Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
35 #include "stm32f2xx.h"
36 #include "stm32f2xx_hal.h"
44 #if (STM32F2XX_CRYPTO_HASH_SUPPORT == ENABLED)
55 __HAL_RCC_HASH_CLK_ENABLE();
72 uint32_t *
h,
size_t hLen)
82 HASH->CR |= HASH_CR_INIT;
85 for(i = 0; i < hLen; i++)
87 HASH->CSR[6 + i] =
h[i];
88 HASH->CSR[14 + i] =
h[i];
95 HASH->DIN = __UNALIGNED_UINT32_READ(
data);
98 while((HASH->SR & HASH_SR_BUSY) != 0)
103 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 4);
104 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 8);
105 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 12);
106 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 16);
107 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 20);
108 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 24);
109 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 28);
110 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 32);
111 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 36);
112 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 40);
113 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 44);
114 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 48);
115 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 52);
116 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 56);
117 HASH->DIN = __UNALIGNED_UINT32_READ(
data + 60);
129 while((HASH->SR & HASH_SR_BUSY) != 0)
134 for(i = 0; i < hLen; i++)
136 h[i] = HASH->CSR[14 + i];
144 #if (MD5_SUPPORT == ENABLED)
194 if(context->
size == 64)
221 #if (SHA1_SUPPORT == ENABLED)
271 if(context->
size == 64)
STM32F2 hardware cryptographic accelerator.
#define HASH_CR_ALGO_SHA1
void sha1Update(Sha1Context *context, const void *data, size_t length)
Update the SHA-1 context with a portion of the message being hashed.
void md5Update(Md5Context *context, const void *data, size_t length)
Update the MD5 context with a portion of the message being hashed.
#define osMemcpy(dest, src, length)
OsMutex stm32f2xxCryptoMutex
General definitions for cryptographic algorithms.
void sha1ProcessBlock(Sha1Context *context)
Process message in 16-word blocks.
Collection of hash algorithms.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
void hashProcessData(uint32_t algo, const uint8_t *data, size_t length, uint32_t *h, size_t hLen)
Update hash value.
#define HASH_CR_DATATYPE_8B
error_t hashInit(void)
HASH module initialization.
void md5ProcessBlock(Md5Context *context)
Process message in 16-word blocks.
STM32F2 hash hardware accelerator.