|
Home Page Kryha Home Page Kryha Cryptanalysis Home Page
|
IntroductionThe Kryha machine is vulnerable to a known plaintext attack. This page describes two cases:
Two other pages provide additional information:
Wheel and interior Alphabet unknownIntroductionThe principle is to assign each letter of the ciphertext to one of the 26 alphabets generated by the Kryha. To do this, we use the Sacco's method. How do we determine the shifts between columns? We will use pairs of identical plaintext/ciphertext letters. If these pairs are identical, they necessarily belong to the same alphabet. Then we sort the alphabets to reconstruct the internal alphabet (the one which is mobile). Finally, we deduce the shifts to move from one pair to the next (wheel reconstruction). Create the example materialsA cryptogram is created from plaintext.
$ cat MSGS/clair_connu.sh
#!/bin/sh
python3 kryha_tui.py -o \
-i KPFQVGMASCHYNIORDELUBZWJXT
$ cat MSGS/tobe.txt
To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And, by opposing, end them. To die, to sleep,
No more, and by a sleep to say we end
$ cat MSGS/tobe.txt | tr -dc '[A-Za-z]' | tr '[a-z]' '[A-Z]' \
| python3 groupe.py
TOBEO RNOTT OBETH ATIST HEQUE STION WHETH ERTIS NOBLE RINTH
EMIND TOSUF FERTH ESLIN GSAND ARROW SOFOU TRAGE OUSFO RTUNE
ORTOT AKEAR MSAGA INSTA SEAOF TROUB LESAN DBYOP POSIN GENDT
HEMTO DIETO SLEEP NOMOR EANDB YASLE EPTOS AYWEE ND
$ sh MSGS/clair_connu.sh < MSGS/tobe.txt |python3 groupe.py \
>| MSGS/clair_connu.cry
UAOHR NPWUI XMQIB AZPVT MXVPG YMYNG CIVOU CDYZT ISIEK SUULK
LEMGO TOYAH VUPJM WVLMV EWTMR MRCWT RMDUB HPVQW KTEWT LRHXS
NHQED DZCXC WWBZC NHCGQ OBCLQ HFEEO UMRDJ SJIJE NGFNC WHOXC
DAHSW GQBQE RKIQC PJOHS NPSEH PWSUM WFKDI RSJXL BG
![]() In the Sacco method, to assign each letter of the cryptogram to an alphabet, a table is created with as many columns as there are sectors of the wheel and 26 rows. The figure above shows only a portion of the table. Cells with the same pattern belong to the same alphabet. We observe that if two cells in different columns belong to the same alphabet, the cells below them (in the same columns) also belong to the same alphabet (but a different one). 1 - Finding the key LengthSuppose two letters belong to the same alphabet. They are X positions apart. If two other letters belong to a different alphabet but are also X positions apart, one of the most likely explanations is that they belong to the same columns as the previous pair. The distance between the first letters of each pair is then a multiple of the number of sectors. We can thus determine the number of secteurs, and then length of the key, which corresponds to the number of sectors multiplied by 26!
Find pairs of identical plain letter/ciphered letterI created a computer program that searches for plain letter/ciphered letter pairs and for each repetition displays the position of each occurrence and the distance between them. For example, the plaintext letter A is encrypted as C at positions 114 and 122. The distance between these repetitions is 8. $ python3 plain_known.py MSGS/clair_connu.cry MSGS/tobe.txt 1 ... AC [114, 122]: 8, AD [105, 133]: 28, BO [2, 129]: 127, DG [155, 191]: 36, EB [121, 157]: 36, EC [35, 107]: 72, EH [3, 146]: 143, EL [50, 189]: 139, EM [131, 179]: 48, EQ [12, 163]: 151, EW [65, 89, 180]: 24,91, EX [21, 188]: 167, HM [20, 64]: 44, IM [52, 68]: 16, IN [115, 143]: 28, LU [130, 178]: 48, NG [29, 53]: 24, NP [6, 165]: 159, OE [103, 127, 159]: 24,32, OJ [138, 166]: 28, ON [28, 100]: 72, OW [7, 78, 154]: 71,76, RC [77, 109]: 32, RP [62, 86]: 24, RS [45, 169]: 124, SR [80, 132, 160]: 52,28, SV [18, 66]: 48, SW [71, 111]: 40, SY [25, 57]: 32, TH [85, 125]: 40, TI [9, 13]: 4, TQ [102, 158]: 56, TT [19, 55]: 36, TU [0, 8]: 8, Find the key lengthSeveral pairs are 36 positions apart:
2 - Match an alphabet to the letters of the cryptogramEach letter of the cryptogram belongs to one of the 26 alphabets generated by a Kryha machine. Based on Sacco's method, if two letters belong to the same alphabet, we can deduce the other 25 pairs of letters, each belonging (taken separately) to the same alphabet. By following these steps, we can determine which of the cryptogram's letters belongs to each of the 26 alphabets. If a pair of plaintext/ciphertext letters is repeated, it means that these pairs used the same alphabet. For example: the pair AC is present at positions 114 and 122. The Sacco coordinates of these positions are as follows:
By analyzing all the repeating pairs, we obtain the following sequence of alphabets (in groups of 17 values):
00,01,13,14,11,23,24,10,00,12,06,03,15,12,13,25,22, 01,02,14,15,12,24,25,11,01,13,07,04,16,13,14,00,23, 02,03,15,16,13,25,00,12,02,14,08,05,17,14,15,01,24, 03,04,16,17,14,00,01,13,03,15,09,06,18,15,....Note: We notice that each column is offset from the others. The following program displays the alphabet number on the x-axis and the plaintext letter on the y-axis. The table contains the encrypted letters. For example, for alphabet number 2, the plaintext letter B is encrypted with the letter I.
$ python3 attack_clair.py
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
A: X Q W R P B M T V D C A
B: I M J O H
C:
D: R S O G X E
E:V C A K U N G X H Q W S B I M L
F: H Q W V D
G: Z E Q W
H: K U B I M D
I: P M Y Z U N Q
J:
K: Z
L: K U E L
M: E H W O
N:I M V J C O U G X H S P B
O:O A K U N G X E H W R S M T L J D
P: C F N E
Q: V
R: H R S P L D C F N
S: Y V C F O E W R S I T
T:U G H Q R S I M T L Y J D C Z O K
U:B T A E H P
V:
W: T J C
X:
Y: S P I
Z:
Note: In the previous step, we determined the number of sectors (we found 17). But the result wasn't certain. Indeed, other analyses gave a factor of 19. However, now the value of 17 is confirmed. In fact, in each alphabet, each letter appears only once. If the key length had been incorrect, we would have had the same letter multiple times. In fact, that's what happened to me, because initially, I mistakenly used a key length of 16 and, to my great surprise, I had several occurrences of the same letter in different alphabets. 3 - Find the inner alphabetWe rearrange the columns (the alphabets) so that between each column, the ciphered alphabet shifts by one position. Here is the list of columns that corresponds to the expected result: 14-03-18-07-12-11-00-15-04-19-08-23-12-01-16- 05-20-09-04-13-02-17-06-21-10-25 14 318 71211 015 419 82312 116 520 9 413 217 6211025 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 A: M V Q P T X W B D R C A B: M Q O I H C: D: S G X E R O E: H C S A M G Q K X W B U L I N F: H V Q W D G: Q W Z E H: I Y M K B U D I: Y M Q P Z U J: K: Z L: E K U L M: E O H W N: U O I H C S M G V P X J B O: U L E D R O N H S A M G K T X W P: E N C F J Q: V R: L D R N H C S F P S: W E R O I Y C S V F T T: T J Z U L D R O I Y H C S M G Q K U: E H A P V: W: T J C X: Y: P S Z: By completing the diagonals, we deduce the first column which corresponds to the ciphered alphabet (the internal movable alphabet): MASCHYNIORDELUBZWJXXTKPFQVG 4 - wheel reconstructionNow, it's easy to reconstruct the sectors of the wheel: The first plain letter/ciphered letter pair is T/U. This is the starting position. The U is found in column 6 (letter number 0). The second pair, O/A, has the ciphered letter in column 13, which is 7 positions later. Next, for the pair B/O, the ciphered letter is in column 19, 6 positions further. Then, for the pair E/H, the ciphered letter is in column 0, 7 positions further. Finally, for the pair O/R, the ciphered letter is in position 5, 5 positions further. For now, we have the following shifts: 7, 6, 7, 5Continuing, we obtain the shifts generated by the wheel (of 17 sectors): 7, 6, 7, 5, 6, 7, 6, 8, 6, 10, 5, 6, 5, 7, 6, 5, 9We have completely reconstructed the key. We can verify this with my simulator:
$ echo UAOHR NPWUI XMQIB AZPVT | \ python3 kryha_tui.py -o \ -s 7,6,7,5,6,7,6,8,6,10,5,6,5,7,6,5,9 \ -i MASCHYNIORDELUBZWJXTKPFQVG -d -a 6 TOBEORNOTTOBETHATIST Note: we have an initial shift of 6 positions because the first plain letter/ciphered letter pair is in column 6. The whole key is unknown
IntroductionThe method is broadly identical to the previous one, but because the outer alphabet is not direct (ABC...Z), the inner alphabet cannot be directly deduced. It is first necessary to find the difference between two inner alphabets (or two outer alphabets). Create the example materialsA cryptogram is created from plaintext.
$ cat /tmp/known_plain.sh
python3 kryha_tui.py -o \
-i KPFQVGMASCHYNIORDELUBZWJXT \
-e ZCJBWYKNAGQSPFTROXVMDULEHI
$ cat MSGS/tobe.txt | tr -dc '[A-Za-z]' | tr '[a-z]' '[A-Z]' \
| python3 groupe.py
TOBEO RNOTT OBETH ATIST HEQUE STION WHETH ERTIS NOBLE RINTH
EMIND TOSUF FERTH ESLIN GSAND ARROW SOFOU TRAGE OUSFO RTUNE
ORTOT AKEAR MSAGA INSTA SEAOF TROUB LESAN DBYOP POSIN GENDT
HEMTO DIETO SLEEP NOMOR EANDB YASLE EPTOS AYWEE ND
$ sh /tmp/known_plain.sh < MSGS/tobe.txt | \
python3 groupe.py >| MSGS/known_plain.cry
$ cat MSGS/known_plain.cry
OCDQE HZXOS KSWSY RDLJB JEXFX VPFOT EVJCH FOMNL AHRFU MHIIE
YXJTG BDVSL NNTLJ RJQJX BRAKM OIAXA SSXZZ GTNMR FKHVP DHYLP
OSXUY XEFMA QRFXE QVFKY AIEBY GKULD VTSXE TTBTO CAZQQ TQSRV
AKEQX WBIXU SYMWM ZTZNM GCFSN SVPVT RTZLM JRGEY OW
1 - The first stepsWe proceed as before: Search for pairs of identical plaintext/ciphertext letters$ python3 plain_known.py MSGS/known_plain.cry MSGS/tobe.txt 1 ... AE [114, 122]: 8, AX [105, 133]: 28, BD [2, 129]: 127, DW [155, 191]: 36, EE [21, 188]: 167, EF [35, 107]: 72, EI [121, 157]: 36, EQ [3, 146]: 143, ER [65, 89, 180]: 24,91, ET [131, 179]: 48, EW [12, 163]: 151, EY [50, 189]: 139, HJ [20, 64]: 44, IJ [52, 68]: 16, IQ [115, 143]: 28, LV [130, 178]: 48, NT [29, 53]: 24, NZ [6, 165]: 159, OO [28, 100]: 72, OT [138, 166]: 28, OU [103, 127, 159]: 24,32, OX [7, 78, 154]: 71,76, RA [77, 109]: 32, RM [45, 169]: 124, RT [62, 86]: 24, SJ [18, 66]: 48, SR [71, 111]: 40, SS [80, 132, 160]: 52,28, SV [25, 57]: 32, TB [19, 55]: 36, TG [85, 125]: 40, TO [0, 8]: 8, TS [9, 13]: 4, TX [102, 158]: 56, ... Finding the key Length (in fact, the number of sectors)The D/W, E/I and T/B pairs allow us to determine the number of sectors: 17.Match an alphabet to the letters of the cryptogramBy analyzing all the repeating pairs, we obtain the following sequence of alphabets (in groups of 17 values):00,01,13,14,11,23,24,10,00,12,06,03,15,12,13,25,22, 01,02,14,15,12,24,25,11,01,13,07,04,16,13,14,00,23, 02,03,15,16,13,25,00,12,02,14,08,05,17,14,15,01,24, 03,04,16,17,14,00,01,13,03,15,09,06,18,15,.... 2 - The alphabets, but before decimation
|