# How can AES be considered secure when encrypting large files?

Why is AES considered to be secure when encrypting large files since the algorithm is a block cipher?

I mean, if the file is larger than the block size, the file will be broken down to fit the blocks. Then the same key is used to encrypt each block of the file. And as I know it, using the same key to encrypt multiple messages/blocks is not a good idea. Is not that how AES works?

Or do I have misunderstood something? :-)

• – user991 Sep 11 '14 at 18:17
• You describe ECB mode, which is indeed not secure. But actually used modes make it different for each block. – CodesInChaos Sep 11 '14 at 18:34
• Using a weak mode like ECB is not secure. That's a weakness in the mode and not in AES. But even with a secure mode, the larger the data, the more likely it is to have two identical blocks be encrypted. I think a good rule of thumb is that with a block size of $b$ bits, you shouldn't encrypt more than $b*2^{b/4}$ bits with the same key. In the case of AES that works out to no more than 64GB encrypted using a single key. – kasperd Sep 13 '14 at 17:27
• @kasperd: your rule of thumb is way overly conservative; CBC/CFB modes are good for $b\cdot2^{(b+1-r)/2}$ bits where residual odds of duplication of one block are $2^{-r}$. With AES and $r=40$ (residual odds of one in a million millions, entirely negligible compared to oblivion by asteroid on any given day) that's 3 petabit (nearly 400 terabyte). CTR/OFB modes are good for even more. – fgrieu May 2 '15 at 6:28
• @fgrieu I would say $r = 40$ isn't a very high security to aim for. Aim a little bit higher ant take $r = b/2$, and you will end up with the same result as I did. CTR can be used for more data before you run into a collision, but only if you track additional information to avoid counter reuse or switch the key whenever counter reuse would be possible. However if you guarantee that a collision will not happen, then information is leaked to the adversary, because the adversary can then take advantage of that knowledge. – kasperd May 2 '15 at 13:50