ecc_test function is not working #295
Labels
No labels
bug
duplicate
enhancement
feature
help wanted
improve API
invalid
needs documentation
not-planned
rtfm
stale
support
wishlist
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libtom/libtomcrypt#295
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi All,
I ported the libtom crypt code with tom fast math library in embedded platform. I am successfully able to port the RSA logic and all the functionalities are running without any problem. However, I am facing a problem while running the ecc_test function. It is getting stuck in "hsm_sdk_ecc_map" function for the first curve itself.
I have observed that values in x,y,and z members of M[0] are 0. Initially there were some values in these variables but it got zero during the execution of for loop in the function "hsm_sdk_ecc_mulmod".
Does anyone have faced the similar problem? It would be great if someone can throw some pointers on the above scenario.
What libtomcrypt version or git branch are you using?
I am using "libtomcrypt-1.18.0-rc3" version and latest version of tom fast math.
Did you have to change anything in any of the libs? If yes, can you please provide the diffs
Which configurations do you use?
And what's these functions
hsm_sdk_ecc_mulmodandhsm_sdk_ecc_map? Never heard of them.There are some ecc related issues (e.g. #108 #116) which we have decided not to fix in 1.18.
However, there is a branch
pr/ecc-non-asn1-partrelated to #236 which contains some ecc fixes that are not included in 1.18. What regardsltc_ecc_mulmodit has a new/better handling of so called "point at infinity". Could you please try thepr/ecc-non-asn1-partbranch?It would also help if you can post a small failing C example demonstrating your problem.
Hi Stefan
Sorry for the misunderstanding. I have renamed the function
Originally these functions were ltc_ee_mulmod and ltc_ecc_map
The current configuration I am using is
#define LTC_ECC112
#define LTC__ECC128
#define LTC_ECC160
#define LTC_ECC192
#define LTC_ECC224
#define LTC_ECC256
#define LTC_ECC384
#define LTC_ECC521
/* ECC */
#define LTC_MECC
/* use Shamir's trick for point mul (speeds up signature verification) */
#define LTC_ECC_SHAMIR
/#define LTC_MECC_ACCEL/
/* do we want fixed point ECC /
/#define LTC_MECC_FP */
/#define LTC_ECC_TIMING_RESISTANT/
The size of fp_int I have selected is 4096 bits.
On Wed, Sep 20, 2017 at 10:18 PM, Steffen Jaeckel notifications@github.com
wrote:
No, I have not changed any thing in the library. Just renamed the variables
and functions name.
On Wed, Sep 20, 2017 at 10:23 PM, Himanshu Singhal hmnsh18@gmail.com
wrote:
Exactly that's what I meant with "changes in the library".
Can you please either test with the original library or create a diff of the changes?
@karel-m
Thank you for the pointer.
I just cloned the branch "pr/ecc-non-asn1-part" and did a quick compare of the ecc files with RC3 branch. It seems to have many changes specially with respect to handling of point at infinity feature.
I will try to merge these changes and give it a try.
I have a one question, if it is a known issue, is there any specific reason why this feature was not considered for 1.18 release?
@sjaeckel
I can do the diff but I believe that will not be useful as it will contain the diff for so many files. I can try the testing with original library but it will take time because from starting only, I tried in my embedded platform. Moreover, if the issue is with respect to renaming of functions and library, RSA would also not have worked. I will give it a try to work with the original files.
Because this feature will break ABI and API and we wanted 1.18 to be a drop-in replacement for 1.17.
good idea!
@karel-m does the issue sound familiar to you?
IMO it is #108 (ECC public key validation stucks in ltc_ecc_map) which is fixem in my branch.
@hmnsh18 is there any special reason why you have chosen tomfastmath and not libtommath?
Hi Karel,
My intention/requirement is try to avoid dynamic allocation as much as
possible. That is the main reason of going to tom fast math instead of lib
tom math. Also as mentioned in the documentation of tomfastmath,
"
exibility]."
I found the above points good enough to make a decision to select
tomfastmath over libtom math. Is there any constraint which I should be
aware of using tomfast math for ECC functionality? All functionalities are
supposed to work with tomfastmath right?
"IMO it is #108 https://github.com/libtom/libtomcrypt/issues/108 (ECC
public key validation stucks in ltc_ecc_map) which is fixem in my branch."
Which branch are you talking about here?
Regards
Himanshu
On Wed, Sep 20, 2017 at 11:23 PM, karel-m notifications@github.com wrote:
Hi Stefan,
"Because this feature will break ABI and API and we wanted 1.18 to be a
drop-in replacement for 1.17."
I am sorry but I didn't understand the statement. What do you mean by ABI?
If I understand it correctly, you do agree that this ECC feature should be
incorporated but because of compatibility issues it would have with
previous versions, this idea was dropped.
I am not sure how would I be able to send the code snippet because I
haven't written anything new. I am just using the in built test function
"ecc_test" to test the sanity of ECC functionality. I feel that this
function has no platform based dependency. Having said that, if this
function is working at someone's end then I must be doing something wrong.
I wanted to know whether this function has been tested by anyone and if
yes, have they faced the similar type of issue at their end?
Regards
Himanshu
On Thu, Sep 21, 2017 at 9:41 AM, Himanshu Singhal hmnsh18@gmail.com wrote:
FWIW, as I scroll all this on my small screen I saw TFM and a key size 4096, max being 2048.
Sent fm iTouch
pr/ecc-non-asn1-partThe thing is that planned ECC enhancements have an impact on backwards compatibility, therefore they were not included in 1.18. When talking about #108 (please read the discussion there) it is fixed in
pr/ecc-non-asn1-partbut not in planned 1.18, although @sjaeckel wanted to backport the fix I was against as it is IMO a waste of time, becausepr/ecc-non-asn1-partis expected to be fine-tuned and merged shortly after 1.18 is released, please read the discussion in #236.To your other questions:
1/
ecc_testfrom 1.18 release candidate should pass with both libtomcrypt / tomfastmath (it is regularly tested so please check out your custom modifications).2/
libtomcryptlibtommathvs.tomfastmath- a trouble you might experience with tomfastmath is max. num size limit (FP_MAX_SIZEis by default 2048 - try to increase it), which you can sometimes hit without any obvious error. I mean you can getCRYPT_OKfor some operation which in fact failed and returned a bogus result. IMOlibtommathis better choice if you prefer avoiding surprises.3/ ECC & "point at infinity" - it is unlikely that you hit this issue by running
ecc_test, on the other hand this corner case might happen in real life use.a/ I guess you meant
libtommathnotlibtomcrypt.b/ the 2048 statement is only half correct. The default size of an mpi in tfm is 4096+some margin which allows to do multiplications of up to 2048 bit wide numbers, thereby limiting the size of PK operations to 2048 bits.
yes, updated
@hmnsh18 any update on this?
Please re-open if you have further questions/comments.