CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

MD5 on PIC18?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stevenm86



Joined: 11 Jun 2006
Posts: 11

View user's profile Send private message

MD5 on PIC18?
PostPosted: Sun Jun 11, 2006 2:40 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Sun Jun 11, 2006 8:40 am     Reply with quote

Did you try this code

http://www.ccsinfo.com/forum/viewtopic.php?t=23727&highlight=md5
stevenm86



Joined: 11 Jun 2006
Posts: 11

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 11:43 am     Reply with quote

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 Smile.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Jun 11, 2006 7:32 pm     Reply with quote

You need a while(1) in there.
stevenm86



Joined: 11 Jun 2006
Posts: 11

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 7:37 pm     Reply with quote

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








PostPosted: Sun Jun 11, 2006 9:41 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 9:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 11:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jun 11, 2006 11:31 pm     Reply with quote

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...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group