In case I am using CBC cipher in that case is it must that my encrypted text is in multiple of the BLOCK SIZE? Is the same true for GCM?
No, GCM does not require padding, nor does it require plaintext to be a multiple of the block size.
GCM is a mode that combines CTR, which is a stream cipher mode, with GMAC authentication, which dave has pointed out does require its inputs to be a multiple of its block size, 128-bits. However the GMAC process simply null pads the ciphertext input, then processes the length of the data as an additional input, to eliminate issues relating to that padding method.
CTR mode turns a block cipher into a stream cipher by encrypting an incrementing counter. GCM is only used with a 128-bit block cipher by design, so the stream cipher outputs are generated in 128-bit increments, and only the needed bits are used to encrypt the plaintext. If the plaintext is 136 bits, 256 bits of stream cipher output is generated, and the first 136 bits are used.
Because GCM is based on CTR, the length of the ciphertext is the same as the length of the plaintext, plus the GMAC authentication tag length, plus the length of the Nonce.
Yes, with most block modes,
- the plain data length (before encrypting) has to be a multiple of the block size. For this reason, the plain data is padded before.
- the encrypted data length too has to be a multiple of the block size, namely the same size as the padded plain data.
But there are exceptions to this rule, eg. the block mode XTS, where no extra paddign is necessary and the encrypted data has the same length as the plain data.
(Note that you shouldn't choose a block mode just because of this. Each mode has other advantages/disadvantages, XTS is by no means the best for all purposes)