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

Hash function like MD5 or MD4 in CCS code for 18F2620

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



Joined: 21 Nov 2006
Posts: 129

View user's profile Send private message

Hash function like MD5 or MD4 in CCS code for 18F2620
PostPosted: Tue Aug 25, 2009 6:03 pm     Reply with quote

Hi,

I need a function that can take two relatively short IDs (about 10 digits each), and produce some output that is unique. If I understand correctly, this is what a MD5 hash will do.

Is there a computationally less intensive way to do this?

Does anyone have the MD5, MD4, or suitable hash function they could provide the code for?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Aug 26, 2009 12:13 am     Reply with quote

A MD4/MD5 implementation can be found in RFC 1321 because it's used for the CHAP password algorithm. But's it's probably a bit extensive for a PIC18 project. Unintentionally, it has become my tool to reveal PCD arithmetic bugs. I hope, it compiles correctly with PCH, but I didn't yet try.

MD5 purpose is to make the signature unpredictable. If you don't need this strong cryptographic feature, simple CRC or XOR algorithms can do.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Aug 26, 2009 5:42 am     Reply with quote

To add an update, the RFC 1321 test code is consuming 13% ROM and 25% RAM of PIC18F2620, but it works correctly, different from PCD with PIC24.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Aug 26, 2009 1:58 pm     Reply with quote

If you want to create a not (easily) predictable code word generated from the two IDs I would simply use a CRC32 routine. This is much lighter on the PIC resources than an MD4 or MD5 algorithm (which are not recommended for security anyway).

The CRC routines are defined by a set of six parameters, see chapter 15 in http://www.cs.waikato.ac.nz/~312/crc.txt.
Changing one or two of these parameters to not common used values will make it very difficult to guess the coding algorithm used.
pattousai



Joined: 23 Aug 2006
Posts: 37

View user's profile Send private message

PostPosted: Thu Apr 15, 2010 1:03 pm     Reply with quote

FvM wrote:
To add an update, the RFC 1321 test code is consuming 13% ROM and 25% RAM of PIC18F2620, but it works correctly, different from PCD with PIC24.

If I understand correctly, you already have the implementation of the RFC 1321. By any chance you could make that public?

Thanks a lot!
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Apr 15, 2010 10:56 pm     Reply with quote

I simply compiled the code published in RF1321. It worked correctly with PIC18F2620 and PCH.

As reported, the MD5 code also has (unintentionally) become a testcase to check for PCD bugs. I wish, CCS would use it too, before releasing new versions.
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