File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,9 @@ STATIC mp_obj_t sha256_digest(mp_obj_t self_in) {
88
88
mp_obj_hash_t * self = MP_OBJ_TO_PTR (self_in );
89
89
vstr_t vstr ;
90
90
vstr_init_len (& vstr , 32 );
91
- mbedtls_sha256_finish (& self -> state .sha256 , (unsigned char * )vstr .buf );
91
+ mbedtls_sha256_context ctx ;
92
+ mbedtls_sha256_clone (& ctx , (const mbedtls_sha256_context * )& self -> state .sha256 );
93
+ mbedtls_sha256_finish (& ctx , (unsigned char * )vstr .buf );
92
94
return mp_obj_new_str_from_vstr (& mp_type_bytes , & vstr );
93
95
}
94
96
MP_DEFINE_CONST_FUN_OBJ_1 (sha256_digest_obj , sha256_digest );
@@ -97,7 +99,9 @@ STATIC mp_obj_t sha1_digest(mp_obj_t self_in) {
97
99
mp_obj_hash_t * self = MP_OBJ_TO_PTR (self_in );
98
100
vstr_t vstr ;
99
101
vstr_init_len (& vstr , 20 );
100
- mbedtls_sha1_finish (& self -> state .sha1 , (unsigned char * )vstr .buf );
102
+ mbedtls_sha1_context ctx ;
103
+ mbedtls_sha1_clone (& ctx , (const mbedtls_sha1_context * )& self -> state .sha256 );
104
+ mbedtls_sha1_finish (& ctx , (unsigned char * )vstr .buf );
101
105
return mp_obj_new_str_from_vstr (& mp_type_bytes , & vstr );
102
106
}
103
107
MP_DEFINE_CONST_FUN_OBJ_1 (sha1_digest_obj , sha1_digest );
You can’t perform that action at this time.
0 commit comments