note 15368 deleted from function.md5 by jimw
| From: | jimw@php.net | Date: | Sat, 03 Nov 2001 02:30:07 +0000 |
| Subject: | note 15368 deleted from function.md5 by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-20328@lists.php.net to get a copy of this message | ||
Guys, beware! R-MD5 is not a strong encryption algorithm in any way! I can't call it
"encrypton" at all.
The $tmp value you have at the end of encrypt function (before call to keyED) is completely
reversable without knowledge of secret key because it is sequence of bytes:
TMP = R1.(T1^R1).R2.(T2^R2)....
Where T* is bytes of text before encryption and R* supposed ;) to be random. Since you have R1 as
first byte you can restore first byte of text from second byte of this sequence and so on. So if any
encryption is ever happens, it happens inside of keyED function. But there is no encryption just XOR
with MD5 product of secret key.
RESULT = (K1^R1).(K2^T1^R1).(K3^R2).(K4^T2^R2)....(K32^T16^R16).(K1^R17).(K1^T17^R17).(K2^R18)......
MD5 function returns string 32 bytes long in which every character represents hex digit (0-f). That
means all R* as well as all K* are within the range
['0'-'9','a'-'f']=[0x30-0x39,0x61-0x66]. Imagine you have
first byte of encrypted string and it is equal to 0x52 (just an example). You know it is XOR of K1
and R1 but you do not know their values. But there are only twelwe (!!!) possible combinations of
K1/R1 which produces that value:
30 x 62 = 52
31 x 63 = 52
33 x 61 = 52
34 x 66 = 52
36 x 64 = 52
37 x 65 = 52
I said twelwe because reversing the operands (62 x 30) also gives 0x52. Then look at 33th byte of
result (K1^R17). Let it be 0x0f. This gives us ONLY FOUR (!!!) possible combinations of K1/R17.
36 x 39 = 0f
37 x 38 = 0f
K1 must be in both sets so it is obviously either 0x36 or 0x37. I think you've got the idea. Of
course, this search better be done by script and it will not take long time :) It just a matter of
seconds. Even for an average Pentium PC.
--
Dmitry Andrianov