I would like to apply CTR mode on a arbitrary length which isn't multiple of block size. Is this possible without applying padding.
In case we apply padding - how does the decryption algorithm know this padding!?
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.Sign up to join this community
In CTR mode, Enc is done as
CT = Enc(k,PT) = Enc(k,ctr) xor PT
The decryption is similar to encryption except you XOR Cipertext(CT) instead of Plaintext(PT).
PT = Dec(k,CT) = Enc(k,ctr) xor CT
So there is no need for plaintext to be multiple of block length and no need of padding because the PT or CT never become the input of the block cipher. Its the counter which is encrypted to generate a random stream and then Xored with plaintext or ciphertext. You can use the required length of generated bit-stream and discard the remaining.
More Details and picture Credit of CTR MODE