encryption – Block cipher exercise CTR, CBC and ECB


I’m trying to figure out this exercise about CTR, CBC and ECB

given Encryption Matrix

(29->0, 11->1, 26->2, 1->3, 21->4, 4->5, 15->6, 31->7, 27->8, 28->9, 2->10, 14->11, 8->12, 20->13, 9->14, 5->15, 0->16, 22->17, 7->18, 10->19, 3->20, 6->21, 25->22, 17->23, 24->24, 23->25, 19->26, 18->27, 16->28, 12->29, 13->30, 30->31)

0 encyrpts to 29, i.e. E(K, 0) = 29, 3 maps to 20. To decrypt read backwards, so 29 goes to 0 and 30 to 31. in notation: D(K, 30) = 31.

Hints:

· Plaintexts are 6 letter german words.

· Blocklenght = 5.

· You must convert decimal to 5 bit binary to XOR in CBC and CTR Mode example: 11_10 XOR 17_10 = 01011_2 XOR 10001_2 = 11010_2 = 26_10.

Code table:Code table

ECB-Ciphertext: (25, 29, 14, 14, 10, 21)
P_i=D(K,C_i)

CBC-Ciphertext (IV=0):(29, 16, 18, 7, 10, 23)

C_0 := IV

C_i=E(K,P_i XOR C_i-1)

P_i=C_i-1 XOR D(K,C_i)

CTR-Ciphertext (IV=0):(25, 14, 10, 23, 16, 29)

P_i=C_i XOR E(K,IV+i mod 2^blocksize)

I only get false results these are no german words

ECB Wallte

CBC abldut

CTR efqwfz