Skip to main content
. 2022 Oct 28;24(11):1551. doi: 10.3390/e24111551
Algorithm 1 The proposed chosen-plaintext attack
  • Output: 

    The plaintext P of C

  • Input: 

    The ciphertext C of size H × D

  • 1:

    // step1: construct an all-zero matrix and obtain the equivalent key T of diffusion stage

  • 2:

    P0 = zeros(H,W);

  • 3:

    C0 = encrypt(P0);

  • 4:

    T=C0;

  • 5:

    // step2: initialize logL(HW) matrices and get the corresponding ciphertexts

  • 6:

    for i=1 to logL(HW) do

  • 7:

       Pi = JolfaeiAlgorithmGeneration(i);

  • 8:

       Ci = encrypt(Pi);

  • 9:

    end for

  • 10:

    // step3: obtain logL(HW) middle results with the diffusion matrix T and the ciphertexts which are obtained in the step2

  • 11:

    for i=1 to logL(HW) do

  • 12:

       Si= inverseDiffusionAttack(CiT);

  • 13:

    end for

  • 14:

    // step4: obtain the equivalent permutation matrix by the input plaintexts and the middle results

  • 15:

    for i=1 to logL(HW) do

  • 16:

       JolfaeiAlgorithmAdd(Pi,Si);

  • 17:

    end for

  • 18:

    permutationMatrix = JolfaeiAlgorithm();

  • 19:

    // step5: recover the the plaintext of the target ciphertext with the equivalent key stream elements which are obtained in previous steps

  • 20:

    SC = inverseDiffusionAttack(CT);

  • 21:

    P = inversePermute(SC,permutationMatrix);