Re: Mbedtls_pk_verify error


David Brown
 

There are still buffer/variable overflow problems, so I would make sure those are fixed before trying to figure out why else it might not be working. For example:

char buffer[2];
...
snprintk(buffer, SHA256_SIZE, "%02x", rsp_hash[i]);

in this case, the buffer is 2 characters, yet you are passing a much larger value as the buffer's size. In this case the "%02x" will add two hex characters, and a terminating null, which will overflow the 2 character buffer, overwriting something else that is on the stack.

There are other things like using memcmp to compare a single character, instead of memcmp(&msg[i], "U", sizeof(msg[i])), just use (msg[i] == 'U').

Beyond that, you'll probably have to start stepping through the code with a debugger to find out what is happening. But, I would work on the overflows and such first, since those can cause very confusing behavior.

David

From: Zephyr Devel <devel@...> on behalf of christian tavares <christiantavarest@...>
Date: Monday, June 11, 2018 at 11:04 AM
To: Zephyr Devel <devel@...>
Subject: Re: [Zephyr-devel] Mbedtls_pk_verify error

Thanks for you answer me. I followed your tips and corrected that problems and I resolved to simplify the code removing the server side and letting just application working. But the problem doesn't resolve yet If you could see again o code modified I'll be grateful to help me. Thanks again.
https://github.com/chtavares592/verify_signature/blob/master/verify_signature/src/main.c

Join {devel@lists.zephyrproject.org to automatically receive all group messages.