Take the 2-minute tour ×

We are using the below cipher


But I am little confused because modes like ECB need the input to be padded according to the block size.But here we say NOPADDING.Dont they look contradictory.

Can we have arbitrary data which is not padded as input to ECB mode.

share|improve this question
Can we mark this Java as well whocares? That AES/ECB/NOPADDING looks suspiciously like a String that targets a Java cryptography provider (JCA/JCE). –  owlstead May 10 '12 at 20:01
add comment

1 Answer

up vote 2 down vote accepted

The "raw" modes of ECB encryption with no padding applied like for example AES/ECB/NOPADDING, are basically the pure application of the encryption function to N blocks of data. They are useful for developers that need to implement custom modes that are not shipped by default. Any mode of operation is somehow constructed from the raw encryption function.

Still, since a block cipher can only operate on full-length blocks, some form of padding has may have to be applied on the last block. This is left up to the developer, they will implement whatever form of padding is specified/recommended for the mode they wish to implement. There are many possibilities, and this is why we have "NOPADDING" - to leave the choice of padding up to us.

These modes, XXX/ECB/NOPADDING, should never be used directly. Neither should any ECB mode, really. Plain ECB encryption is very insecure, for example it doesn't hide statistical properties of the plaintext (you may know the examples where the "encrypted" image still looks much like the original). On top of that, as already noted, a block cipher can only operate on full-length blocks. This requires applying a custom padding scheme, which would add another layer where mistakes can be made as opposed to simply relying on some default implementation.

share|improve this answer
When u mean raw modes of ECB ,are you referring to AES/ECB/NOPADDING ? –  whokares May 10 '12 at 10:34
I tried to make things a little clearer - did this answer your question, too? –  emboss May 10 '12 at 11:31
Very occasionally NoPadding mode is used for fixed length data that happens to match the block size of the cypher being used. This can be useful to reduce the size of network packets, especially if the messages are sent very frequently. –  rossum May 10 '12 at 11:37
@rossum: For that purpose I would use a cipher mode that does not need padding, like CTR or GCM without authentication. –  Robert May 10 '12 at 11:50
emboss : Its clear now –  whokares May 10 '12 at 12:14
show 5 more comments

Your Answer


