-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
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;
wc_ecc_init(&other_pub_key);
ret = wc_ecc_import_x963((byte *)ephemeral_key.data, (word32)ephemeral_key.len, &other_pub_key);
//int curve_idx = wc_ecc_get_curve_idx(ECC_SECP256R1);
//other_pub_key= wc_ecc_new_point(); // ecc_point *other_pub_key;
//ret = wc_ecc_import_point_der(ephemeral_key.data, ephemeral_key.len, curve_idx, other_pub_key);
ret = wc_ecc_shared_secret(&my_private_key, &other_pub_key, shared_key, shared_key_len);
if (ret != 0)
{
ESP_LOGI(TAG, "========= wc_ecc_shared_secret error %d", ret);
wc_ecc_free(&other_pub_key);
return -4; // Error computing shared key
}
return 0;
}
Metadata
Metadata
Assignees
Labels
No labels