Take the 2-minute tour ×
Information Security Stack Exchange is a question and answer site for Information security professionals. It's 100% free, no registration required.

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?

share|improve this question
1  
Short answer: see this Wikipedia article: en.wikipedia.org/wiki/Block_cipher_mode_of_operation –  Luc Feb 23 at 22:28

2 Answers 2

AES is a block cipher, it works on 16-byte (128-bit) blocks. AES, in and on itself, 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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.