# How does AES-CBC encryption achieve non-repeating blocks of ciphertext?

I am very interested in encryption algorithms, especially AES encryption algorithm in symmetric encryption. To this end, I have studied a lot of theoretical knowledge about AES encryption algorithm and the code samples I can obtain.

I wrote a 512-bit encryption algorithm after referring to AES-CBC-256 mode in detail.

I named this mode SZQ-CBC-512, but the output result is almost the same as that of AES-ECB-256 mode (that is, the data between different blocks is the same).

I will describe this problem in detail:

1. The avalanche effect is very perfect because it refers to "column mixing", "row shifting" and "sub bytes" of AES encryption algorithm (equivalent to another realization of an AES encryption algorithm).
2. All inputs are 512 bits, that is to say, the blocks of "plaintext, key and ciphertext" are 64 bytes.

Then in the process of implementation, If you enter a byte stream with a length of 128 bytes and all of them are "00", you will get the data spliced by two blocks.

The two blocks will be the same.

These are the Github warehouses of the AES encryption algorithm code samples I refer to.

https://github.com/SergeyBel/AES
https://github.com/jbheard/AEScrypt
https://github.com/4thrun/aes
-------------------------------------------------
https://github.com/kokke/tiny-AES-c
This is the code sample warehouse of AES encryption algorithm that I have learned and understood most.


The following is an example output of the plaintext, key and ciphertext of the SZQ encryption algorithm.

Hex print
---------------------------------------------------------------
Plaintext:
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
---------------------------------------------------------------
Key:
---------------------------------------------------------------
Iv:
---------------------------------------------------------------
Ciphertext:


It can be seen that the data of the two blocks in the ciphertext are the same.

b5d7...b44eb5d7...b44e

However, I found that under the CBC mode of AES encryption algorithm, different blocks will not have duplicate blocks in a very large range.

So I would like to know how AES encryption algorithm achieves this.
The following is the source code warehouse of SZQ encryption algorithm I developed.

https://github.com/sngrotesque/SZQ

• When properly used CBC not only would minimize the probability of duplicate ciphertext blocks to be negligible, but also given the same input plaintext to encrypt twice would produce completely different resulting ciphertexts. You may want to take a closer look at the importance of generating a (cryptographically strong-) random IV block to be used as input, each time you encrypt a plaintext with CBC.
– Amit
Feb 18 at 20:05
• Note that, in the SZQ cipher, the RowsMix operation is not at all equivalent to the AES MixRows operation; in particular, it is not even close to being MDS (in the forward direction, you have have a delta on 2 bytes in and 1 byte out); MixRows being MDS is crucial for the proofs that AES is immune to linear/differential cryptanalysis. In addition, how were the sboxes chosen (and why do you believe that they give good linear/differential properties)? Feb 19 at 3:09
• As for the generation of sbox, I first created a uint8 array of 256 bytes in length from 0 to 255, and then used a random algorithm to scramble it for 16 times. Feb 19 at 5:30
• At present, if SZQ cipher only has ECB mode, can you analyze the security of this algorithm? Feb 19 at 5:33
• As for analyzing the security of the cipher, well, the sbox does have decent sized differential and linear characteristics (about what one would expect from a random sbox). And, there may be sparse paths through the cipher (as I pointed out about the RowsMix operation). As for finding a concrete differential or linear characteristic through the bulk of the cipher, well, that'd be more work than I'm interested in. What appears to be much harder is showing that there isn't one - can you do that? If not, why do you believe it might be secure? Feb 20 at 21:01