I am trying to implement AES on an image of size 256x256 (65536 bytes) but AES works on 4x4 size of image (16 bytes).
What should I do? Can it be implemented or not? And if yes, then how?
Information Security Stack Exchange is a question and answer site for information security professionals. It only takes a minute to sign up.Sign up to join this community
AES is a block cipher, it works on 16-byte (128-bit) blocks. AES, on its own, can't work with data smaller or bigger than 16 bytes. Smaller data needs to be padded until they're 16 bytes, and larger data needs to be split into 16-byte blocks (and, of course, padded when needed*)
Luckily, there are algorithms that help you achieve just that (work on data larger than the cipher's block size), they're called block cipher modes of operation. They describe how the process of encryption and decryption using the block cipher should be.
Important: If you're writing your own implementation of AES to encrypt actual data for personal and/or professional use, then STOP NOW! Instead, use well-vetted, time-tested, and famous libraries for that. However, if you're doing that for educational purposes, go ahead, have fun.
If you want to use AES for confidentiality (i.e. to keep the image secret), use any of the modes offered by your library, except ECB which is not secure. If you also want to protect the image's integrity (i.e. to detect if it's been modified), use an authenticated encryption mode.
* There's more to padding than just the need to get to the block size, but I won't get into that. Read more about it if you're interested.
Several ways of encrypting data using AES is located here. It uses a high level library such as Bouncy Castle, or .NET to implement authenticated encryption using AES GCM