Does encryption guarantee integrity?

前端 未结 3 1954
春和景丽
春和景丽 2021-01-31 09:57

To build a secure system, can we assume that encryption guarantees integrity is true before starting a secure programming?

  • Both in symmetric and public-key encrypt
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-31 10:37

    In short the answer is no. Message Integrity and Secrecy are different, and require different tools.

    Lets take a simple coin flip into consideration, and in this case we are betting on the results. The result is a simple bool and I encrypt it using a stream cipher like RC4 which yields 1 encrypted bit and I email it to you. You don't have the key, and I ask you to email me back the answer.

    A few attacks can happen in this scenario.

    1)An attacker could modify the bit in transit, if it was a 0 there is a 50% chance it will become a 1 and the contrary is true. This is because RC4 produces a prng stream that is XOR'ed with the plain text produce the cipher text, similar to a one time pad.

    2)Another possibility is that I could provide you with a different key to make sure your answer is wrong. This is easy to brute force, I just just keep trying keys until I get the proper bit flip.

    A solution is to use a block cipher is CMAC Mode. A CMAC is a message authentication code similar to an hmac but it uses a block cipher instead of a message digest function. The secret key (K) is the same key that you use to encrypt the message. This adds n+1 blocks to the cipher text. In my scenario this prevents both attacks 1 and 2. An attacker cannot flip a simple bit because the plain text is padded, even if the message only takes up 1 bit i must transmit a minimum of 1 block using a block cipher. The additional authentication block prevents me from chaining the key, and it also provides integrity from anyone attempting to modify the cipher text in transit (although this would be very difficult to do in practice, the additional layer of security is useful).

    WPA2 uses AES-CMAC for these reasons.

提交回复
热议问题