@@ -70,15 +70,15 @@ void mbedtls_md5_starts( mbedtls_md5_context *ctx )
70
70
}
71
71
}
72
72
73
- void mbedtls_md5_process ( mbedtls_md5_context * ctx , const unsigned char data [64 ] )
73
+ void mbedtls_md5_process ( mbedtls_md5_context * ctx , const unsigned char data [MBEDTLS_MD5_BLOCK_SIZE ] )
74
74
{
75
- HAL_HASH_MD5_Accumulate (& ctx -> hhash_md5 , (uint8_t * )data , 64 );
75
+ HAL_HASH_MD5_Accumulate (& ctx -> hhash_md5 , (uint8_t * )data , MBEDTLS_MD5_BLOCK_SIZE );
76
76
}
77
77
78
78
void mbedtls_md5_update ( mbedtls_md5_context * ctx , const unsigned char * input , size_t ilen )
79
79
{
80
80
size_t currentlen = ilen ;
81
- // store mechanism to handle 64 bytes per 64 bytes
81
+ // store mechanism to handle MBEDTLS_MD5_BLOCK_SIZE bytes per MBEDTLS_MD5_BLOCK_SIZE bytes
82
82
if (currentlen == 0 ){ // only change HW status is size if 0
83
83
if (ctx -> hhash_md5 .Phase == HAL_HASH_PHASE_READY )
84
84
{
@@ -87,18 +87,18 @@ void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, s
87
87
HASH -> CR |= HASH_ALGOSELECTION_MD5 | HASH_CR_INIT ;
88
88
}
89
89
ctx -> hhash_md5 .Phase = HAL_HASH_PHASE_PROCESS ;
90
- } else if (currentlen < (64 - ctx -> sbuf_len )) {
90
+ } else if (currentlen < (MBEDTLS_MD5_BLOCK_SIZE - ctx -> sbuf_len )) {
91
91
// only buffurize
92
92
memcpy (ctx -> sbuf + ctx -> sbuf_len , input , currentlen );
93
93
ctx -> sbuf_len += currentlen ;
94
94
} else {
95
95
// fill buffer and process it
96
- memcpy (ctx -> sbuf + ctx -> sbuf_len , input , (64 - ctx -> sbuf_len ));
97
- currentlen -= (64 - ctx -> sbuf_len );
96
+ memcpy (ctx -> sbuf + ctx -> sbuf_len , input , (MBEDTLS_MD5_BLOCK_SIZE - ctx -> sbuf_len ));
97
+ currentlen -= (MBEDTLS_MD5_BLOCK_SIZE - ctx -> sbuf_len );
98
98
mbedtls_md5_process (ctx , ctx -> sbuf );
99
99
// now process every input as long as it is %4 bytes
100
100
size_t iter = currentlen / 4 ;
101
- HAL_HASH_MD5_Accumulate (& ctx -> hhash_md5 , (uint8_t * )(input + 64 - ctx -> sbuf_len ), (iter * 4 ));
101
+ HAL_HASH_MD5_Accumulate (& ctx -> hhash_md5 , (uint8_t * )(input + MBEDTLS_MD5_BLOCK_SIZE - ctx -> sbuf_len ), (iter * 4 ));
102
102
// sbuf is now fully accumulated, now copy 1 / 2 or 3 remaining bytes
103
103
ctx -> sbuf_len = currentlen % 4 ;
104
104
if (ctx -> sbuf_len != 0 ) {
@@ -112,7 +112,7 @@ void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] )
112
112
if (ctx -> sbuf_len > 0 ) {
113
113
HAL_HASH_MD5_Accumulate (& ctx -> hhash_md5 , ctx -> sbuf , ctx -> sbuf_len );
114
114
}
115
- mbedtls_zeroize ( ctx -> sbuf , 64 );
115
+ mbedtls_zeroize ( ctx -> sbuf , MBEDTLS_MD5_BLOCK_SIZE );
116
116
ctx -> sbuf_len = 0 ;
117
117
__HAL_HASH_START_DIGEST ();
118
118
0 commit comments