View Full Version : Help about MDA

January 14th, 2004, 09:32
I have a subject of Data Security and Encryptography in this semester and after some days I have to give a presentation on a topic entitled "MDA : Message Digest Algorithms".

I have studied the topic but still the MD5 algorithm is difficult to understand. I know how the SHA-1 algorithm works because I studied that while looking into the MAME sources.

Does anybody know of the MD5 algo.

Jet Set Willy
January 14th, 2004, 09:34

January 14th, 2004, 09:39
Thanks Waz..but I have both of those. If you follow the 2nd link, it has the complete MD5 algo.

The steps in the text file, on how does the algo work are confusing.

If you understand the algo, can you explain it a bit.

Jet Set Willy
January 14th, 2004, 09:55
I'm not working through all of that when I don't need to know it myself.

January 14th, 2004, 10:02
hmmm..may be. Well I knew your answer.

I'll wait for someone else.

Jet Set Willy
January 14th, 2004, 10:32
Well, how far can you get before you get stuck? Maybe I can help you out with bits of it.

January 14th, 2004, 10:48
hmmm...If you have the 1321.txt document.

When you reach step 4 of section 3.4 where it says

This step uses a 64-element table T[1 ... 64] constructed from the
sine function. Let T[i] denote the i-th element of the table, which
is equal to the integer part of 4294967296 times abs(sin(i)), where i
is in radians. The elements of the table are given in the appendix.

I understand the table stuff and how it builds up. The problem is when you proceed further into the step.

Jet Set Willy
January 14th, 2004, 10:58
An element i is equal to 4294967296*abs( sin(i) ).

abs is the "absolute" function. It just means that if the result of sin is negative, it will turn it positive. It's the same as the mathematical operator "modulos", i.e. |-4| = 4

So, the table would look like this:

int table[64];

[0]=4294967296*abs( sin(1) )=3614090360
[1]=4294967296*abs( sin(2) )=3905402710
[2]=4294967296*abs( sin(3) )=606105819
[3]=4294967296*abs( sin(4) )=3250441966
[63]=4294967296*abs( sin(64) )=3250441966

You can confirm that this is the correct approach by Googling for some of the values I've generated (http://www.google.co.uk/search?q=3250441966&ie=UTF-8&oe=UTF-8&hl=en&btnG=Google+Search&meta=). The results bring up MD5 documentation. :-)

Hope that helps. I can write you some C source code to generate the table if that would help.

January 14th, 2004, 11:04
hmmm I understand what you said Waz. Great!

C, well I have implemented 50% of the algorithm myself. But the problem was here when I had to implement the table.

The explanation was a help.

Ok one more thing. Waz, what would be the way if I want to either optimize the way this algo produces the Hashes or Digests of a message.

If so, can I increase the length of the message from a standard 128 bit Hash to 256 or higher.

And one more thing, my side of the code is toooo slow.

I know I'm asking you alot of things at the same time. Hope you have the time.

Jet Set Willy
January 14th, 2004, 11:08
It's okay. I'm quite enjoying this, it's new territory.

I'm not at all familiar with the algorithm, so I won't be much help on specific matters. What datatype are you using for 128 bit tables? I imagine you're using arrays of four 32 bit values to combine and act as 128 bit values?

As for speeding up your code, I don't know how to help without actually seeing it. I have seen a file called md5.c (http://theory.lcs.mit.edu/~rivest/md5.c) around on the Web however. You might be able to look at that and compare it with your own code.

Good luck.

January 14th, 2004, 12:39
Yes, the word datatype is of 32bits and byte of 8bits.

I'll complete the code in a few hours. It is taking me more time than necessary because my monitor got wrecked up.

I have to increase the complexity of the algo from 128bits to at least 16+ bits.

I'm searching for help on that. Thanks for the md5.c link. I have found the problem with my algo.

Keep it coming Waz. I'll come back to this topic.

January 15th, 2004, 07:15
OK Waz, you were a good help (morally too). I reduced the time by getting rid of the loops and now I have another task.

I have to do it in inverted tables. Now the fun comes. I hope I will get it.

Do you think it is possible to get it done in inversion.

Jet Set Willy
January 15th, 2004, 07:25
Maybe. I don't know what you mean.

January 15th, 2004, 07:38
Have you studied inverted tables.

Jet Set Willy
January 15th, 2004, 07:40
Not that I know of. I may know them under a different terminology though.

January 15th, 2004, 07:46
Have you studied any course related to Data Structures or Algorithms etc.

Jet Set Willy
January 15th, 2004, 07:48
No, I've not done any computer related course, I just know how to work things out.

January 15th, 2004, 07:55
Great...OK, than i probably have to tell you about things on a lower level.

See..Inverted tables like arrays connected to each other through some index tables that help as keys to the original tables.

The use of having these tables is that you don't have to change the original data to get a sorted form, just changing the index to key tables helps you out.

So inverted tables are those tables that have there index tables inverted. If you invert an index table the outlook of the original table appears to be inverted as well, which infact isn't.

So is it okay for you or am I going to need someone else's help on this.

Jet Set Willy
January 15th, 2004, 07:59
Are you talking about hashing?

Don't assume that you have to talk about things on a lower level just because I haven't been on a specific course. Some people are able to teach theirselves better than a course.

January 15th, 2004, 08:03
Hasing is a different technique...although it uses arrays but you can not call them the same.

Hashing is an encryption technique where as Tables are used to maintain and sort data.

A typical example would be a telephone directory, where you want to sort out two tables on teh basis of a "name" but you just want to do that to show it to the user and changing the original data.

I am about to merge the two techniques...using hashing in the algorithm and storing data in tables.

Jet Set Willy
January 15th, 2004, 08:22
Yeees, I know what hashing is, I'm just trying to work out if that's what you're talking about because your message makes no sense.

All you seem to be saying is reversing the order of an array.

January 16th, 2004, 05:28
Ok...you got it.

Jet Set Willy
January 16th, 2004, 07:32
Somebody really doesn't know his arse from his elbow...

Here's how to work this out: Study harder.

January 16th, 2004, 07:40
Thankyou for teh advice.