1

I am developing an application that is going to use AES encryption.

Since it is going to use a different key for every message encrypted...

  • Would it be secure to use a constant IV? (i.e null bytes)
  • Would it be secure to not pad the encrypted message?
Nathan Parker
  • 125
  • 1
  • 5
  • 3
    I'm not sure what you mean by the second question: padding is either required to make the message a suitable size or it isn't. Key reuse should have nothing to do with it. – otus Jan 19 '16 at 15:22
  • 2
    Also, the answers to any questions about IV or padding will generally depend on the block cipher mode you're using (as it's the mode, rather than AES, which actually uses the IV/padding). What mode would you be using? – poncho Jan 19 '16 at 15:26
  • I use CBC. I always thought the padding was added for security reasons. Is that wrong? – Nathan Parker Jan 19 '16 at 15:45
  • 1
    @NathanParker AES works on a single block of 16 bytes. A non-streaming mode like CBC works on multiple blocks of 16 bytes. If you want to encrypt some plaintext that is not a multiple of the block size, then you need to pad it to reach a multiple of the block size. PKCS#7 padding for example adds 1 to 16 bytes of padding and each of those bytes' numeric value denotes how many bytes were added, so you can remove them after decryption by looking at the last byte. – Artjom B. Jan 19 '16 at 16:06
  • Thanks very much mate, I finally understood that. Have a nice day! – Nathan Parker Jan 19 '16 at 16:16

0 Answers0