Closed pur300 closed 5 years ago
Hi @pur300 and thanks for taking an interest in this project :)
I should let you know that I am not sure that the quality of this project is production-ready just yet. I should probably note that in the README. I just haven't had time or motivation to work on this library lately.
I have successfully tested the example code on an STM32F103 and some other 32-bit machines, as well as on a PC (gcc and clang, linux 64bit), so I would expect the example code to work out of the box. Since it looks like your code resembles the example code, I am not sure what the problem could be.
Trying to narrow it down, how does the code you tested on the PC differ from the vanilla example code?
Also do check out this issue https://github.com/kokke/tiny-ECDH-c/issues/10, which is valid to my best belief.
Also, can you please verify for me that the arrays ARE initialized to zero. I have seen cases where the = {0};
-construct only zero-initialized the first member of a struct, the rest contained garbage. I think it has to do with whether or not the compiler supports/works in C99-mode, which is the iso-version that introduced the = {0};
-construct AFAIK.
You could do that by marking the arrays static or make the global (to force 0-initialization) or call memset(x, 0, sizeof(x))
on each of them - just to be sure.
Please also check that ECC_PUB_KEY_SIZE have the sizes you expect (check the ecdh.h)
I checked the arrays and the values at the beginning are set to zero. But i also tried to set the buffer length for private key to 24 (for public key is 48 according to calculations) as suggested in issue #10, and now it seems to be working correctly (i tried to run it 100 times with different private keys).
Thank you for your time.
Hello,
I would like to use your library to generate a secret key which is going to be used to make an encrypted channel between PC and STM32l082 microcontroller. I wrote a test code on the microcontroller, where i simulate the generation of the keys and secret for both sides (PC and STM32l082). Public and private keys are successfully generated for both sides, but i'm having a problem when i want to generate a shared secret. For one side it is successfully generated, but for the other side, the function ecdh_shared_secret() always returns 0 (array secb is not populated with values).
Here is also my testing code snippet:
I tried to compile the code also on the PC, where i get the same results. I'm using the sect163k1 elliptic curve. Where do you think is the problem?
Thank you in advance.