Skip to content
Snippets Groups Projects
Commit 1688d692 authored by dmitriy.gerasimov's avatar dmitriy.gerasimov
Browse files

Merge branch 'feature-2963' into 'master'

fixed dap_chain_str_to_hash_fast()

See merge request !15
parents 1dfccbe8 0f616348
No related branches found
No related tags found
1 merge request!15fixed dap_chain_str_to_hash_fast()
......@@ -493,7 +493,7 @@ dap_enc_key_serealize_t* dap_enc_key_serealize(dap_enc_key_t * key)
dap_enc_key_t* dap_enc_key_deserealize(const void *buf, size_t buf_size)
{
if(buf_size != sizeof (dap_enc_key_serealize_t)) {
log_it(L_ERROR, "Key can't be deserealize. buf_size != sizeof (dap_enc_key_serealize_t)");
log_it(L_ERROR, "Key can't be deserealize. buf_size(%d) != sizeof (dap_enc_key_serealize_t)(%d)",buf_size,sizeof (dap_enc_key_serealize_t));
return NULL;
}
const dap_enc_key_serealize_t *in_key = (const dap_enc_key_serealize_t *)buf;
......
......@@ -42,12 +42,14 @@ int dap_chain_str_to_hash_fast( const char * a_hash_str, dap_chain_hash_fast_t *
const size_t c_hash_str_size = sizeof(*a_hash) * 2 + 1 /*trailing zero*/+ 2 /* heading 0x */;
size_t l_hash_str_len = strlen( a_hash_str);
if ( l_hash_str_len + 1 == c_hash_str_size ){
for (size_t l_offset = 2; l_offset < l_hash_str_len; l_offset+=2 ){
if ( ( sscanf(a_hash_str+l_offset,"%02hhx",a_hash->raw+l_offset/2-1) != 1) ||
( sscanf(a_hash_str+l_offset,"%02hhX",a_hash->raw+l_offset/2-1) != 1)
)
log_it(L_ERROR,"dap_chain_str_to_hash_fast parse error: offset=%u, hash_str_len=%u, str=\"%2s\"",l_offset, l_hash_str_len, a_hash_str+l_offset);
return -10* ((int) l_offset); // Wrong char
for(size_t l_offset = 2; l_offset < l_hash_str_len; l_offset += 2) {
if(sscanf(a_hash_str + l_offset, "%02hhx", a_hash->raw + l_offset / 2 - 1) != 1) {
if(sscanf(a_hash_str + l_offset, "%02hhX", a_hash->raw + l_offset / 2 - 1) != 1) {
log_it(L_ERROR, "dap_chain_str_to_hash_fast parse error: offset=%u, hash_str_len=%u, str=\"%2s\"",
l_offset, l_hash_str_len, a_hash_str + l_offset);
return -10 * ((int) l_offset); // Wrong char
}
}
}
return 0;
}else // Wromg string len
......
......@@ -40,6 +40,8 @@ static bliss_signature_t s_sign_bliss_null = {0};
// calc signature size
size_t dap_sign_create_output_unserialized_calc_size(dap_enc_key_t * a_key, size_t a_output_wish_size )
{
if(!a_key)
return 0;
size_t l_sign_size = 0;
switch (a_key->type){
case DAP_ENC_KEY_TYPE_SIG_BLISS: l_sign_size = sizeof(s_sign_bliss_null); break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment