@@ -50,6 +50,8 @@ void mbedtls_sha1_hw_free(crypto_sha_context *ctx)
50
50
return ;
51
51
}
52
52
53
+ CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
54
+
53
55
/* Uninit crypto module */
54
56
crypto_uninit ();
55
57
crypto_zeroize (ctx , sizeof (crypto_sha_context ));
@@ -91,8 +93,6 @@ void mbedtls_sha1_hw_finish(crypto_sha_context *ctx, unsigned char output[20])
91
93
crypto_sha_update_nobuf (ctx , ctx -> buffer , ctx -> buffer_left , 1 );
92
94
ctx -> buffer_left = 0 ;
93
95
crypto_sha_getinternstate (output , 20 );
94
-
95
- CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
96
96
} else {
97
97
mbedtls_sha1_sw_context ctx_sw ;
98
98
@@ -101,6 +101,8 @@ void mbedtls_sha1_hw_finish(crypto_sha_context *ctx, unsigned char output[20])
101
101
mbedtls_sha1_sw_finish (& ctx_sw , output );
102
102
mbedtls_sha1_sw_free (& ctx_sw );
103
103
}
104
+
105
+ CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
104
106
}
105
107
106
108
void mbedtls_sha1_hw_process (crypto_sha_context * ctx , const unsigned char data [64 ])
@@ -127,6 +129,8 @@ void mbedtls_sha256_hw_free(crypto_sha_context *ctx)
127
129
return ;
128
130
}
129
131
132
+ CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
133
+
130
134
/* Uninit crypto module */
131
135
crypto_uninit ();
132
136
crypto_zeroize (ctx , sizeof (crypto_sha_context ));
@@ -169,8 +173,6 @@ void mbedtls_sha256_hw_finish(crypto_sha_context *ctx, unsigned char output[32])
169
173
crypto_sha_update_nobuf (ctx , ctx -> buffer , ctx -> buffer_left , 1 );
170
174
ctx -> buffer_left = 0 ;
171
175
crypto_sha_getinternstate (output , ctx -> is224_384 ? 28 : 32 );
172
-
173
- CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
174
176
} else {
175
177
mbedtls_sha256_sw_context ctx_sw ;
176
178
@@ -179,6 +181,8 @@ void mbedtls_sha256_hw_finish(crypto_sha_context *ctx, unsigned char output[32])
179
181
mbedtls_sha256_sw_finish (& ctx_sw , output );
180
182
mbedtls_sha256_sw_free (& ctx_sw );
181
183
}
184
+
185
+ CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
182
186
}
183
187
184
188
void mbedtls_sha256_hw_process (crypto_sha_context * ctx , const unsigned char data [64 ])
@@ -206,6 +210,8 @@ void mbedtls_sha512_hw_free(crypto_sha_context *ctx)
206
210
return ;
207
211
}
208
212
213
+ CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
214
+
209
215
/* Uninit crypto module */
210
216
crypto_uninit ();
211
217
crypto_zeroize (ctx , sizeof (crypto_sha_context ));
@@ -248,8 +254,6 @@ void mbedtls_sha512_hw_finish(crypto_sha_context *ctx, unsigned char output[64])
248
254
crypto_sha_update_nobuf (ctx , ctx -> buffer , ctx -> buffer_left , 1 );
249
255
ctx -> buffer_left = 0 ;
250
256
crypto_sha_getinternstate (output , ctx -> is224_384 ? 48 : 64 );
251
-
252
- CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
253
257
} else {
254
258
mbedtls_sha512_sw_context ctx_sw ;
255
259
@@ -258,6 +262,8 @@ void mbedtls_sha512_hw_finish(crypto_sha_context *ctx, unsigned char output[64])
258
262
mbedtls_sha512_sw_finish (& ctx_sw , output );
259
263
mbedtls_sha512_sw_free (& ctx_sw );
260
264
}
265
+
266
+ CRPT -> HMAC_CTL |= CRPT_HMAC_CTL_STOP_Msk ;
261
267
}
262
268
263
269
void mbedtls_sha512_hw_process (crypto_sha_context * ctx , const unsigned char data [128 ])
0 commit comments