ECC public key validation stucks in ltc_ecc_map #108
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#108
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?
ECDSA ceriticom[http://cs.ucsb.edu/~koc/ccs130h/notes/ecdsa-cert.pdf] reference
says ECDSA public key (or private key) has to be validated by checking list below
Q : public key to validate
n: order of domain parameter
O: point at infinity
so I was calculate nQ using ltc_ecc_mulmod(n, Q, result, modulus, 1)
but it hangs.
here is the code(looked up ecc_test() codes)
used curve is(from src/pk/ecc/ecc.c)
LTC_ECC224
P="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"
B="B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4"
n="FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"
Gx="B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21"
Gy="BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34"
used public key parameter is (It is correct key !! has to be validate)
Qx = EA3745501BBC6A70BBFDD8AEEDB18CF5073C6DC9AA7CBB5915170D60
Qy = 6C9CB8E68AABFEC989CAC5E2326E0448B7E69C3E56039BA21A44FDAC
I compiled libtomcrypt using libtommath library(both are static compiled).
build flags was
CFLAGS="-DLTM_DESC -I ../libtommath/" EXTRALIBS="-L. -ltommath" make
CFLAGS="-DLTM_DESC -I ../libtommath/" EXTRALIBS="-L. -ltommath" make test
Module seems to be stuck at ltc_ecc_map. but I don't know why.
Help me if you got anything clue.
and I got another question
Is there anything method that ECC point is at infinity?
my thinking was if Qz==0 then point is at infinity (look at the openssl is_point_at_infinity).
I want to know whether it corrects.
thanks.
@karel-m has an updated version of ecc in the miko-ecc-enhancements branch.
Does this issue still apply there?
yes.
I checked out miko-ecc-enhancements
and doing same test.
It has same problem, too.
I changed somes parameters in above test code.
And I find out it stucks at ltc_ecc_map()
I think module does not have checking whether the point is at infinity
when doing calculating ecc math.
Shouldn't we add this logic in module doing math?
Could you describe the math logic to me in libtomcrypt module when doing ecc?
I think I can help it.
I think this would be an answer
When doing ltc_mp.ecc_ptmul()
Add checks the point whether the point is at infinity before ltc_ecc_map()
but, ltc_is_point_at_infinity(R) returns LTC_MP_GT
because of R->z has used of 4
What was wrong ?
I think logic is quite simple and will be working.
It would be very appreciated If you give me a comment.
@karel-m can you please have a look and integrate that case in your ecc branch and fix it?
Could you please test the latest branch
miko-ecc-enhancements- the fix is: b744d26 (although we should perhaps review handling of points at infinity also at other places).Any improvements to
_ecc_issue108test (based on your example) are welcome:https://github.com/libtom/libtomcrypt/blob/miko-ecc-enhancements/testprof/ecc_test.c#L109
@karel-m should I open a PR with the backported fix and testcase?
No, handling "point at infinity" is not a simple patch.
It is fixed in
miko-ecc-enhancements(just checkout and grep for "infinity" to see all places that need fixing).Unfortunately rebasing
miko-ecc-enhancementson currentdevelopfails very badly and I am currently short of time to investigate more.Damn, but that patch at least fixes this issue ;-)
That's also out of discussion for now, I'd prefer to have the remaining issues solved that we accepted to go into 1.18Ah damn, this one is in 1.18... either we push it to next or we have to backport the "point at infinity" checks...
@karel-m how should we proceed with this issue?
This should be fixed in develop. I'll close this issue in 2 weeks unless there is a feedback that it is still a problem.