Frage

can somebody explain this algorithm is secure or not? is there attack to break that? this algorithm uses common XOR cryptography but has some differences:

M(1) = key XOR Message(1)
M(2) = h(key) XOR Message(2)
M(3) = h(h(key)) XOR Message(3)
and so on

Notes:

  1. M(i) is ciphered text
  2. Message(i) is message that we are going to cipher it
  3. key and Message(i) have the same lengths**
  4. attacker just has the ciphered text and knows key making scheme(continues hashing) and XOR cryptography
  5. hash algorithm is SHA-512
War es hilfreich?

Lösung

Studying encryption algorithms is great fun. Just remember you are playing, not producing anything serious. As long as you are only keeping things like your personal diary (or maybe even passwords) encrypted and you keep the data secure, you will probably be fine. This kind of counts as security through obscurity. I would not recommend encrypting mass quantities of data that you REALLY need to keep private or anything that is available and of interest to the outside world, however.


In this case, if your message is shorter than the key size and hash block size and the key is single use and random, you are effectively using a one-use pad so everything in swell. Provided your random number key generation is perfect, you have an unbreakable encryption mechanism. As you add each block to the message, you are effectively calculating new keys using SHA-512, not adding any particular value. If an attacker can assume the message consists of printable text and if the length of the message is long or the key is used repeatedly, it should would not be too difficult to find the original key.

It would be more effective to calculate:

M(1)=h(N + key) XOR Message(1)
M(2)=h(M(1)) XOR Message(2)
M(3)=h(M(2)) XOR Message(3)

(where N is the number of times the key has been used which is passed in clear text.)

That way the bad guys can’t calculate your key sequence ahead of time and decrypt your message before you can. Also by using a salted hash of the key, the attacker won’t be able to predict the key sequence that will be used next time.


I read somewhere:

  • The first rule of cryptography is “Cryptography should be left to experts.”
  • The second rule is “You are not an expert.”

There is a reason people get PhDs in things like Computer Science and Mathematics. There is a lot to learn and discover. Something like this looks fine to me but no doubt it has a gaping hole that an attacker could drive a truck through.

Have fun and don't let grouchy people like me get you down. /Bob Bryan

Andere Tipps

If the attacker ever gets to know a plaintext-ciphertext pair, he can calculate the corresponding key. And from that he can calculate all later keys. i.e. it's trivially vulnerable to a known plain text attack.

Note that when I say that the attacker guesses the message, I don't mean that he's sure that his guess is correct. He might make a few trillion guesses, and if one of them is correct, your whole scheme is broken.

And of course you must not ever reuse a key.


A more secure (but twice as slow) algorithm would be:

Key(i+1) = h("A"+key)
M(i) = h("B"+key) XOR Message(i)

Or a construction similar to CTR mode:

M(i) =  h(i+key) XOR Message(i)

But I still wouldn't use either.


But there is no reason to use such a homebrew algorithm. There are plenty of existing algorithms that work well. For example if you like a stream cipher design, you could use AES in CTR mode.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top