0

I was just thinking (through browsing the site)

How possible is it to encrypt data, then encrypt it a 2nd time and then after encrypting it with a 2nd layer, remove the first layer leaving the second layer untouched.

file -> encrypted layer 1 -> encrypted layer 1 and layer 2 -> encrypted layer 2 -> file.

technically possible right? especially if you keep everything in byte arrays? I am just curious on this?

4
  • 3
    That's not really how encryption works. You have to peal off each layer in reverse order. Decrypting with Layer 1 keys before decrypting Layer 2 will corrupt the data.
    – RoraΖ
    Commented Jul 16, 2015 at 13:52
  • Yea, Thought this might be the case :( would be interesting though to do it this way, super secure data!
    – TheHidden
    Commented Jul 16, 2015 at 14:27
  • Why so heavily down-voted?
    – user81147
    Commented Jul 16, 2015 at 15:16
  • 1
    I dont know why I thought it was a fair question :(
    – TheHidden
    Commented Jul 16, 2015 at 15:22

1 Answer 1

3

What you seek is called a commutative cipher. This is not the same thing as "a cipher that is commutative" (the terminology is confusing). A cipher that is commutative is easily achieved with, e.g., the large class of stream ciphers that generate a key-dependent pseudorandom stream and encrypt data by XORing that stream with the data to encrypt. Since XOR is commutative, two instances of such encryption can be applied successively then removed in any order. However, observing the encrypted versions yields too much information to eavesdropper -- this encryption is not as encrypted as you believe it to be.

Generally speaking, a commutative cipher is an encryption method that is commutative and yet is secure enough when used in Shamir's three-pass protocol. In a broad sense, such a commutative cipher cannot be "as secure" as a normal symmetric cipher (see this), but it can still be "secure enough" for the three-pass protocol. Known algorithms that appear to be commutative cipher in that sense (Pohlig-Hellman and SRA) rely on the same kind of mathematical tool as asymmetric encryption and key exchange algorithms like RSA or Diffie-Hellman; correspondingly, they don't offer any actual performance advantage over this more widely used types of algorithms.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .