0

I am using openssl library. In all documents and webpages it is written that the block size is 128 bites(common for all AES modes). But what I observed in openssl is, for CTR, CFB and OFB modes the block size is 1. Only for CBC mode it is 128 bits. Can anyone clarify this?

Thank you.

  • Can you explain how you observe a block size of 1? It's definitely 16. – RoraΖ Apr 12 '15 at 11:49
1

Yeah this is explainable by how these modes work.

Note: The input to the mode must be a multiple of the blocksize. (That's why this can be lower than 128-bit for a 128-bit cipher)

Now observe how CBC works:

NewBlock(LastCiphertextBlock,PlaintextBlock):=Encrypt(LastCiphertextBlock XOR PlaintextBlock)
As you can see this can only encrypt a multiple of the actual blocksize of the cipher.

Now let's see how OFB works:

NewBlock(State,Plaintext):=State=Encrypt(State);return State XOR Plaintext

So you're basically encrypting some state over and over and use this state as pad to encrypt the plaintext. Thus you're converting your blockcipher into a streamcipher. As the application can now store the state and only generate new states as every old bit has been used, one can encrypt arbitrary data sizes.

Now let's investigate CTR:

NewBlock(Counter,Plaintext):=Counter++;return Encrypt(Counter) XOR Plaintext

As you see this is the exact same logic as with OFB, you generate the pad using some state (the counter). As you can store this pad until the next pad-block is needed you can encrypt data bit-by-bit.

Finally let's dive into (n-bit-)CFB:

NewBlock(LastCipherTextBlock,Plaintext):=Plaintext XOR Encrypt(LastCipherTextBlock)

So again you're converting to a stream cipher, but this time you take the previous ciphertext block (which is known), encrypt it and XOR it against the plaintext. As you can once again store the pad and perform no blocksize operation on the plaintext, you can use arbitrary plaintext sizes.

  • The above logic is wrong since I faced same kind of issue when using OpenSSL but not with other crypto platforms. So my strong conviction is that the issue is in openssl. Look at here tools.ietf.org/html/rfc3686#section-2.3 – Babulu ellune Oct 27 '17 at 7:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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