To my understanding, symmetric encryption is where encrypting and decrypting data can occur with the same key.

It's possible for symmetric encryption that the encrypting and decrypting algorithms are the same, but this is not always the case. If I'm not mistaken, with AES this could be the case for some block modes, not for others, but I'm not 100% certain about this. (?)

A dummy example which has this property is ROT13 encryption (which therefore also happens to be ROT13 decryption).

An encryption scheme can work as follows:

  1. Based on some password or key, define a deterministic stream of pseudorandom noise or garbage ("entropy stream").
  2. Output data = input data XOR'ed with the entropy stream from step 1.

In this case, encrypting and decrypting are the same.

Assuming that the entropy generator in step 1 is safe (i.e. can be considered a cryptographically secure source of randomness), is the above encryption scheme sound and safe? Or are their still downsides to it compared to other symmetric encryptions, that may not have the poperty of encrypting and decrypting being the exact same algorithm?

  • 1
    $\begingroup$ You're basically describing CTR and OFB mode... $\endgroup$
    – SEJPM
    Jan 19, 2016 at 13:05
  • $\begingroup$ Your question could be seen as asking what are the downsides of stream ciphers compared to block ciphers, correct? This security.se question tackles that, though I don't especially like the accepted answer. $\endgroup$
    – otus
    Jan 19, 2016 at 15:45
  • $\begingroup$ @SEJPM I guess so, yes. However with OFB mode, doesn't the entropy stream depend on encryption output from the preceding block? $\endgroup$
    – RocketNuts
    Jan 21, 2016 at 11:22
  • $\begingroup$ @RocketNuts, OFB mode is repeated encryption of a state (the IV). The current encryption is the XOR'ed with the plain text stream to form the cipher text stream. Also see Wikipedia $\endgroup$
    – SEJPM
    Jan 21, 2016 at 13:17
  • $\begingroup$ more accurately, you are describing a stream cipher, of which CTR and OFB are modes which turn block ciphers into stream ciphers. You were thinking of CFB mode which does depend on the ending ciphertext of the preceding block, wheres OFB depends on the output of the preceding block cipher operation only $\endgroup$ Jan 28, 2019 at 10:17

1 Answer 1


The short answer to your question is yes, but the devil is in the details of "(i.e. can be considered a cryptographically secure source of randomness)". For one thing, the "entropy stream" or any portion of it must never be reused within the same (periodicity) or any & all other input data streams. For another, it is in principle impossible to prove randomness. OTOH, "cryptographic security" is more tractable.

Interestingly (at least to me) there is another binary primitive that has the same reflexive property as XOR: complementation, or double subtraction. Consider this C fragment: Output_byte = (512 - Input_byte - Key_byte) & 0xff;

There are other (faster) ways of doing it using logical inverse & the properties of two's complement representation, but it's still nowhere near as fast as XOR. It does, however, have the same self-inverse property that XOR does.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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