ghandi Posted June 25, 2012 Posted June 25, 2012 Hi all,While playing with the Miracl large integer package and using the example code as a base, i made 3 ECDSA functions:1. Keypair generation.2. Data signing.3. Signature verification.Using the 'cinstr' function i am able to load parameters from ascii strings to bignum variables and it works just fine, all 3 functions are operational and correct. Using the 'big_to_bytes' function i am able to get the octet string which represents the bignums in use and i can load them back to bignum variables using 'bytes_to_big' and following along in OllyDbg i can see that all of the values are correct and exactly the same as if i had loaded them from strings.However, when it reaches the stage of initializing the point x,y of order q, it fails even though the numbers are exactly the same as the working, functional version which uses only strings. Following in Olly it appears as though everything is the same, so I am stumped where it could be going wrong, does anybody have any insight they could lend to this please?HR,Ghandi
mrexodia Posted June 25, 2012 Posted June 25, 2012 I don't know much about MIRACL, only that it's big and sometimes kinda slow. I once used some other library for ECDSA functions. http://mattmccutchen.net/bigint/ it's actually small and really fast. Maybe it's helpful, I don't know.
ghandi Posted June 26, 2012 Author Posted June 26, 2012 Thank you, i haven't looked into that one in detail although i have seen it before.There are a lot of libraries to consider, some being:MiraclGNU MP (GMP)MPIRLIPBigIntIf i were looking for speed i might look at MPIR because it is a Windows port of GMP, branched off a couple of versions ago and if hype is to be believed GMP seems to be one of the faster large integer packages available. I have several (as many as i could find at the time) different libraries, either in code form, i have used different ones for different needs.But for this particular project i am wanting to use Miracl and size is not a worry nor is speed, although i don't believe either will be as bad as though, especially with link time code generation and other optimizations enabled.To this end i am still asking if anybody has any idea why using raw binary data would give a different result than converting ascii to binary and performing the exact same operations? All of the values are correct in their binary form, so i can't see why Miracl would give different results...HR,Ghandi
mrexodia Posted June 26, 2012 Posted June 26, 2012 Hmm, maybe you could try using older versions of Miracl. Another option is to use another bignum library to convert the data to strings, after which you pass them to the miracl functions in string form. It's kind of lame, but if speed and size do not matter it's worth the consideration.Greetings,Mr. eXoDia
ghandi Posted June 26, 2012 Author Posted June 26, 2012 (edited) I have the data in both string and binary form, i was just looking at storing parameters as binary rather than ascii.But just converting from byte form to ascii or back again, base 16, is done easily with no need for API or libraries, i guess i probably could have made that a little clearer by giving the base im using as well.EDIT: I printed out the values of the curve parameters, using the example ones from the Miracl source and 'A' was going from a negative number to a positive number, spoiling further calculations. After using the negify() function on the suspect number, i was able to convert the numbers to bytes and back again and the function still worked okay.BigNum: Pcotstr result: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFbig_to_bytes: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFbytes_to_big: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFFBigNum: Acotstr result: -3big_to_bytes: 03bytes_to_big: 3BigNum: Bcotstr result: 1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45big_to_bytes: 1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45bytes_to_big: 1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45BigNum: Qcotstr result: 100000000000000000001F4C8F927AED3CA752257big_to_bytes: 0100000000000000000001F4C8F927AED3CA752257bytes_to_big: 100000000000000000001F4C8F927AED3CA752257BigNum: Xcotstr result: 4A96B5688EF573284664698968C38BB913CBFC82big_to_bytes: 4A96B5688EF573284664698968C38BB913CBFC82bytes_to_big: 4A96B5688EF573284664698968C38BB913CBFC82BigNum: Ycotstr result: 23A628553168947D59DCC912042351377AC5FB32big_to_bytes: 23A628553168947D59DCC912042351377AC5FB32bytes_to_big: 23A628553168947D59DCC912042351377AC5FB32So, in a nutshell, it was me not using Miracl correctly...HR,Ghandi Edited June 26, 2012 by ghandi
mrexodia Posted June 26, 2012 Posted June 26, 2012 Ok then, nice to hear your problems are solved so far
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now