I noticed that when using AES-256-CBC with a 128-bit IV, the ciphertext is always at least 16 bytes long (size of IV).
I also noticed that when using AES-256-GCM with a 96-bit IV, the ciphertext size can be smaller than the IV.
Normal? Why?
I noticed that when using AES-256-CBC with a 128-bit IV, the ciphertext is always at least 16 bytes long.
AES-256-CBC uses PKCS#7 padding means that one can have at most 16 extra bytes.
Usually one sees IV|ciphertext
where ciphertext is the encryption of the padding block.
I also noticed that when using AES-256-GCM with a 96-bit IV, the ciphertext can be smaller than 12 bytes long.
AES-GCM uses CTR mode that doesn't require padding so the ciphertext is always equal to plaintext size.
Usually one sees IV|ciphertext|tag
where the default tag is 16 bytes.
This is strange and really depends on the output of the software library.
Is it normal that cyphertext size can be smaller than IV when using AES-256-GCM?
If we only talking about the ciphertext, in CTR mode it is always equal to the plaintext size.
Semantically, however, the IV is part of the ciphertext since without it one cannot decrypt the ciphertexts completely - CBC lost only the first block whereas CTR lost all.