2
$\begingroup$

I have a server S1 with an Private String (PS) as an identifier shared with a server S2.

Every 10 min S1 publish the hash value of PS+the current time which is used as public identifier (PI). Every one can see the value of PI in the internet. As S2 has the value of PS, he also use MD5 to get the hash value of PS+the current time and compare it to the value published by S1 and therefore identify that the value provide from S1.

My solution is working but I am wondering how secure it is ? The private string PS shared between S1 and S1 looks like

PS=KJGFDFGHJK65456789876RFBNJK567Y7654RFGHJhhhHGE457UHKJHCDFG7654RF
hash=md5(hours time in millisecond+PS)
PI=fe**63**7b00-1cf0-11e6-b**d**f4-08002**00**c9a66

I use a mask to get some values from the hash and use them to construct the Public Identifier. The blood values are random values, not taken in consideration to identify the server. If someone collect the keys I am publishing for few days, will it be possible form him to identify the Private String S1 is using to generate public keys, or that the key provide probably from S1 and not another server ? I hope you understand what I mean, my knowledge in cryptography are very basic and it's hard for me to use technical vocabular.

$\endgroup$
  • $\begingroup$ Wouldn't it be better to use a tried & tested system for authenticated encryption instead of inventing your own? $\endgroup$ – squeamish ossifrage May 18 '16 at 13:57
  • $\begingroup$ I am not inventing anything, the md5 hashing exist and I am asking if it's secure for such use or not. I thought cipher block is used when we want to decrypt the data but I only want to encrypt it so I thought maybe MD5 can do the job and it's much easier to implement $\endgroup$ – user3235881 May 18 '16 at 14:12
  • $\begingroup$ I changed "ecryption" to "authentication" in your question, because that is what this is really about. $\endgroup$ – otus May 18 '16 at 14:20
1
$\begingroup$

Every 10 min S1 publish the hash value of PS+the current time which is used as public identifier (PI). Every one can see the value of PI in the internet. As S2 has the value of PS, he also use MD5 to get the hash value of PS+the current time and compare it to the value published by S1 and therefore identify that the value provide from S1.

Essentially, you would be using MD5(M + K) as a MAC. That is insecure.

The construction where you append the key to the message and then hash is not a secure MAC when the hash function lacks collision resistance, like MD5 does. (Technically, you need a collision attack on the compression function.)

Even though using a collision resistant hash (like SHA-256) would likely make what you are doing secure, I would recommend using a real MAC. For example, HMAC, for which you ought to find an implementation in almost any programming environment.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.