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

    The ciphertext C of size H×W

  • Output: 

    The plaintext P of C

  • 1:

    // step1: construct logL(HW)+1 ciphertext-plaintext pairs and compute the differentials respectively

  • 2:

    C0 = rand(H,W);

  • 3:

    P0 = decrypt(C0);

  • 4:

    for i=1 to logL(HW) do

  • 5:

       // construct logL(HW) ciphertexts and obtain the corresponding plaintexts

  • 6:

       ΔSi = JolfaeiAlgorithmGeneration(i);

  • 7:

       ΔCi = diffusionAttack(ΔSi);

  • 8:

       Ci=C0+ΔCi;

  • 9:

       Pi = decrypt(Ci);

  • 10:

       // compute logL(HW) differentials of plaintexts

  • 11:

       ΔPi=PiP0;

  • 12:

    end for

  • 13:

    // step2: get the equivalent permutation matrix by the differential of plaintexts and intermediate differential results

  • 14:

    for i=1 to logL(HW) do

  • 15:

       JolfaeiAlgorithmAdd(ΔPi,ΔSi);

  • 16:

    end for

  • 17:

    permutationMatrix = JolfaeiAlgorithm();

  • 18:

    // step3: obtain an intermediate result with the permutation matrix

  • 19:

    S0 = permute(P0,permutationMatrix);

  • 20:

    // step4: obtain the equivalent key stream matrix of the diffusion process from the intermediate results and the corresponding ciphertext.

  • 21:

    T=C diffusionAttack(S0);

  • 22:

    // step5: recover the plaintext of the target ciphertext with the equivalent key stream elements

  • 23:

    SC = inverseDiffusionAttack(CT);

  • 24:

    P = inversePermute(SC,permutationMatrix);