Does anyone have any examples of the MD5 algorithm for a microcontroller (preferably an 8-bit one)? Our project is going to use a Microchip PIC18 series device.
|
If you are looking for a C implementation, the Microchip TCP/IP stack has an implementation of MD5 in the Hashes.c file. |
|||
|
|
|
Here's the MD5 implementation from the EtherNut (AVR based) |
|||
|
|
|
I would stick with a known reputable implementation of MD5, and stay away from libraries you find from 3rd-party vendors. The original RFC 1321 which described MD5 has a sample C implementation. Reminder: the known weaknesses for MD5 are collision attacks, and not preimage attacks, so it is suitable for some cryptographic applications but not others. If you don't know the difference you shouldn't be using it, but don't discard it altogether. See http://www.vpnc.org/hash.html. |
|||||||||||
|
|
You can find a good description and some pseudocode for the MD5 algorithm wikipedia at http://en.wikipedia.org/wiki/MD5 You might also consider posting this question on stackoverflow since it is geared more towards programming questions. |
|||
|
|
|
from the wikipedia page on MD5:
and from the SSL researchers on the same page:
I understand that you probably don't want to hear this, but do you really need MD5? It shouldn't be used for cryptographic purposes as it is too insecure (and there are boatloads of rainbow tables available). If you are looking for something to just validate data, look into CRC (code here) which is computationally cheaper. If you are using it for cryptographic purposes though, then may I suggest moving to SHA? The only problem is that most cryptographically secure algorithms do not run particularly well on microcontrollers. I know it may seem like MD5 is "good enough", but the engineering way is to err on the side of caution. |
|||||||||
|