View previous topic :: View next topic |
Author |
Message |
stevenm86
Joined: 11 Jun 2006 Posts: 11
|
MD5 on PIC18? |
Posted: Sun Jun 11, 2006 2:40 am |
|
|
Hello.
Has anyone got a PCH (PIC18) implementation of the MD5 algorithm? Size is not a problem, I have 32kb of flash available, and the program does not need to do much else.
Any takers? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
|
stevenm86
Joined: 11 Jun 2006 Posts: 11
|
|
Posted: Sun Jun 11, 2006 11:43 am |
|
|
I have seen that. However, no luck.
The code is missing the last 4 rounds of encryption (which I filled in). I couldn't really figure out where to put the data. Regardless, the code does not actually run. I put it on 18F and all it does is cause the PIC to continuously restart. Yes, WDT is off . |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Jun 11, 2006 7:32 pm |
|
|
You need a while(1) in there. |
|
|
stevenm86
Joined: 11 Jun 2006 Posts: 11
|
|
Posted: Sun Jun 11, 2006 7:37 pm |
|
|
What?
I think there's something wrong...
I put the code on a PIC18, put a printf in the beginning that says something like "starting md5" and then at the end I put a printf that prints out the hash, and a while(1). 'starting md5' is printed over and over with no hash ever printed. |
|
|
Guest
|
|
Posted: Sun Jun 11, 2006 9:41 pm |
|
|
From the code:
//md5 done, result is DCBA
you must use a make32(D,B,C,A) and then print it yourself
the guy who wrote that code followed very well the docs, just didn�t suceed because he was using a pic16 to do a very hard task for a half-bained microcontroller (net even a hardware multiplier!). This code really asks for a 32 bit processor with a barrel shifter. |
|
|
stevenm86
Joined: 11 Jun 2006 Posts: 11
|
|
Posted: Sun Jun 11, 2006 9:49 pm |
|
|
Yes, I have inserted a printf statement to PRINT OUT D, C, B, and A, in that order, formatted as 32bitlong integers to be printed in hexadecimal format.
The chip just keeps restarting.
Has ANYONE gotten that code to work? Especially seeing how the last 16 operations are not finished? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 11, 2006 11:02 pm |
|
|
I don't think it's a finished program. Notice he says:
Quote: | I was trying to write an MD5 routine using the MD5 specification (rfc1321) and I ran out of ROM |
I tried to compile it with PCM vs. 3.249 for a 16F877A as he shows in his
post, and the compiler says a segment is too large. i.e., Not enough ROM.
Then he has several lines that look like this:
Code: | res = b+(a+f(b,c,d)+workmssg[k]+(4294967296*abs(sin(i)))); |
This looked suspicious to me, because 4294967296 is 0x100000000,
which is larger than a 32-bit number. The largest integer that CCS
can handle is a 32-bit unsigned number. I took one look at that
and I figured that CCS compiler would truncate it to 0, and it does.
My tests show that the result of this part is always 0:
Code: | 4294967296 * abs(sin(i)) |
So I just don't think that code is real. The code library is for code
that is finished, working code. In his post, he says "any thoughts ?"
which strongly implies that it's still a work-in-progress. |
|
|
stevenm86
Joined: 11 Jun 2006 Posts: 11
|
|
Posted: Sun Jun 11, 2006 11:31 pm |
|
|
Right.
The MD5 spec calls for some trig stuff multiplied by 2^32, and the largest thing you can represent in 32 bits is 2^32-1. If we could get fractional trig going, it would be nice... definitely avoid all these headaches w/ GPS coordinate representation. I wonder if you can make a sine table and put it in there... |
|
|
|