Skip to content

Commit d14c928

Browse files
committed
Fix use case with size = 0 (md5_selftest #1)
1 parent 7348f4a commit d14c928

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

features/mbedtls/targets/TARGET_STM/md5_alt.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, s
8686
unsigned char i=0;
8787
int currentlen = ilen;
8888
/* store mechanism to handle 64 bytes per 64 bytes */
89+
if (currentlen == 0){ // change HW status is size if 0
90+
if(ctx->hhash_md5.Phase == HAL_HASH_PHASE_READY)
91+
{
92+
/* Select the MD5 mode and reset the HASH processor core, so that the HASH will be ready to compute
93+
the message digest of a new message */
94+
HASH->CR |= HASH_ALGOSELECTION_MD5 | HASH_CR_INIT;
95+
}
96+
ctx->hhash_md5.Phase = HAL_HASH_PHASE_PROCESS;
97+
}
8998
while ((currentlen+ctx->sbuf_len) >=64) {
9099
if (ctx->sbuf_len ==0) { /* straight forward */
91100
mbedtls_md5_process(ctx, input+(i*64));

0 commit comments

Comments
 (0)