-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What do I do when I always return '-170' when using wc_ecc_shared_secret? #21
Comments
somebody help me? |
@zhy2020 my apologies for missing this. Have you made any progress? If not, I'll try to take a look this week. In the meantime: you'll get a much quicker response by submitting your questions over on wolfSSL. Additionally, as noted in #16, this repo has a somewhat old submodule of wolfssl. Using the most recent code may have even solved the problem you are encountering. |
@zhy2020 Error code that you posted points to incorrect arguments to the API. You may try the sample code from https://github.com/wolfSSL/wolfssl/blob/bdcf6928a2227f5b6768c845d3c58fa82714b030/IDE/IAR-MSP430/main.c#L241-L295, probably it should help your use-case. |
@zhy2020 is it possible for you to share your If you don't want to post them here, perhaps you could send them to [email protected] for me to test? |
my_private_key is imported through the.pem file The hexadecimal value of my_public_key is ephemeral_key.data is int curveId = ECC_SECP256R1; static void generate_private_key(void)
} static void generate_public_key(void)
} |
Hello @zhy2020 and thank you for the additional details. I've created a sample app and have confirmed the It appears the value being passed for I will next work on providing a working example. |
Hi @zhy2020 - I've updated my demo app that seems to be working a bit better. I found the key to success is to use the wc_ecc_check_key. The demo app is not quite as polished as I'd like, as I used the openssl commandline tool on your example private key file, provided above:
It generated this text:
That text, you'll see I assigned to unsigned char private_key[] and unsigned char public_key[] that were used as parameters to wc_ecc_import_private_key. Ideally, I would have liked to read your PEM-encoded ANSI X9.62 private key directly in the ESP32 without needing the openssl tool. I'm confident that's possible; I just need to do a bit more homework. |
Thank you very much for your help. The program has been running normally. |
Hi @zhy2020 I've continued to work on a working example, but I don't quite have it completed yet. Are you still getting the same ECC_BAD_ARG_E = -170, /* ECC input argument of wrong type */ error? I'd be interested in seeing all of your latest code if you can share it. |
Sorry I forgot to synchronize my progress, the program has not returned -170, I was mistaken private_key.pem file, I can get the correct shared_key. But when I used the generated shared_key to encrypt aec gcm, I got the wrong data `
} generate_shared_key(); // shared_key_hash : hex=> e0 44 b6 42 34 95 32 80 c5 34 a5 dc d9 7f ac de
uint8_t _to_vcsecmessage_pack; // hex=> 12 04 1a 02 08 02
` but by python3 code: ` encrypted_msg = encryptor.encrypt( // 9f 7b 96 df a7 c5 3e b0 9d 0d c8 6e c3 5b 12 01 bf 05 d4 dd 17 e4 |
Hi @zhy2020 I've not had a chance to look at this, but I'm wondering about your memory utilization? Have you checked heap & stack and available memory? For instance, an app I'm working on now... just changing from "no optimization debug" to "optimize for size" had this impact on memory:
Notice in particular the whopping 43K just by changing an optimization setting. Have you tried turning on "stack smashing" and "heap poisoning" to determine if the failure is memory-related? |
Sorry, I am an amateur developer on esp32 platform, I don't know how to test as you said, do you have time to help me solve this problem? thank you |
Hi @zhy2020 - if using the VisualGDB extension, the If using the command-line idf.py ( Stack settings under Stack smashing under Also, I've been working on a similar and possibly related issue in wolfSSL/wolfssl#6205 - I'd be interested in seeing if the above stack and heap issues are not causing a problem, then perhaps try turning off hardware acceleration to see if it makes any difference. I've had limited available time, but indeed I do plan on resolving this problem and creating a robust example. |
My program receives an ephemeral_key (publickey) in the format ProtobufCBinaryData. I want to use my private key (private_key ECC_SECP256R1) and ephemeral_key to generate a shared key, What do I do when I always return '-170' when using wc_ecc_shared_secret?
ecc_key my_private_key; // ECC_SECP256R1
byte my_public_key[65]; // wc_ecc_export_x963_ex()
ecc_key other_pub_key[65];
int to_load_key(ProtobufCBinaryData ephemeral_key)
{
int ret = 0;
}
The text was updated successfully, but these errors were encountered: