Chapter 3 : Analysis of a two-wheel Hagelin Cipher Machine Explanations 1. P = (K -1 -C) % 26 [P==Plain,K==Key,C==Cipher] Message Key: "G" => The active Pin : ( 6+11)%19=17 => "R" "I" => The active Pin : ( 8+10)%17=1 => "B" K19: 0 0 5 0 ... (R S A B ...) K17: 3 0 3 0 ... (B C D E ...) -1 -1 -1 -1 -C: -9-18 -3 -0 ... (J S D A ...) ================================== P: 19 7 4 25 ... (T H E Z ...) 2. K[i] = (C[i] + P[i] +1) % 26 K[0] = M+O+1 = 12 + 14 + 1 = 27 = 1 K[1] = G+U+1 = 6 + 20 + 1 = 27 = 1 K[2] = L+R+1 = 11 + 17 + 1 = 29 = 3 ... When we have obtained all keys, we can see the different possible values: 0, 1, 3, 4 which correspond to 0,x,y,x+y, then: x=1,y=3. How many lugs does wheel 17 have? Look at the 1st and 18th positions: the keys are equal to 1 and 4 respectively. Then wheel 17 has 1 lug and wheel 19 has 3 lugs. 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 i: 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 6 K: 1 1 3 0 3 1 3 3 1 3 4 0 4 3 3 3 4 1 4 0 0 3 1 3 0 4 3 K19:0 0 3 0 3 0 3 3 0 3 3 0 3 3 3 3 3 0 3]0 0 3 0 3 0 3 3... K17:1 1 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1]1 1 0 0 0 1 0 0 1 0... 3. C1 = (K1 -1) –P, C2 = (K2 -1) -P => (C1 - C2) = (K1 - K2) = DELTA => DELTA = 0 - 0 = 0, X - X = 0, X - 0 = X, 0 - X = -X = Y – Y = 0, Y – 0, 0 – Y, X + Y, X-Y, Y-X, -(X+Y ) => DELTA = { 0, X, -X, Y, -Y, X+Y, X-Y, Y-X, -(X+Y) } Where "X" and "Y" are the number of Lugs of the two wheels. Cipher1 F O X U B W A N V A T N A J V Cipher2 I O O R B Z J K Y R K N D M B Cipher1 5 14 23 20 1 22 0 13 21 0 19 13 0 9 21 Cipher2 8 14 14 17 1 25 9 10 24 17 10 13 3 12 1 Delta 23 0 9 3 0 23 17 3 23 9 9 0 23 23 20 Differents values of keys: 0, 3, 9, 23=-3, 17=-9, 20=-6 Then: X=3, Y=6 => Delta = {0,3,23,6,20,9,17} Try to decipher by searching in all possible keys : No 1 – F O X U B W A N V A T N A J V K= 0 U L C F Y D Z K E Z G K Z Q E K= 3 X O F I B G C P H C J P C T H K= 6 A R I L E J F S K F M S F W K K= 9 D U L O H M I V N I P V I Z N K=17 L C T W P U Q D V Q X D Q H V K=20 O F W Z S X T G Y T A G T K Y K=23 R I Z C V A W J B W D J W N B Plain A L L I E D Z S H I P S Z ... We can verify our hypotesis with the 2nd cipher text. 4. K[i] = (C[i] + P[i] +1) % 26 P[i] = (K[i] -1 – C[i]) % 26 and K[i] = Kx[i] + Ky[i] i 0 1 2 3 4 5 6 7 8 9 10 11 C 6 0 3 0 16 7 8 22 12 24 7 5 (GADAQ HIWMY HF...) P 19 7 4 25 12 0 17 8 13 4 18 25 (THEzM ARINE Sz ) 1 1 1 1 1 1 1 1 1 1 1 1 K 0 8 8 0 3 8 0 5 0 3 0 5 ... We can deduce that x=3 and y=5 We make the hypothesis that the lugs of wheel 19 equal 5. i 15 16 17 18 19 20 21 22 23 24 25 26 C -14-13 -3 -8 -8-25 -9-23-19 -8 -6 -5 (ONDII ZJXTI GF) -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Kx ...........] 0 5 5 0 0 5 0 5 Ky .................] 0 3 3 0 3 3 P 11 5 9 22 22 2 (LFJWWC) We make the hyptothesis the lugs of wheel 19 equal 3. i 15 16 17 18 19 20 21 22 23 24 25 26 C -14-13 -3 -8 -8-25 -9-23-19 -8 -6 -5 (ONDII ZJXTI GF) -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Kx ...........] 0 3 3 0 3 3 0 0 Ky .................] 0 5 5 0 0 5 P 19 7 14 20 19 25 (THOUTZ) The second hypothesis seems more likely. We can try to guess the last letters of wheel 21: - If [0,0] => P = 17,3 = RD (THOUT) - If [1,0] => P = 22,3 = WD - If [0,1] => P = 17,8 = RI - If [1,1] => P = 22,8 = WI (THOUT) => Youpee !! "WITHOUT" i 25 26 27 28 29 30 31 32 33 34 C -6 -5-13-13-23-18 -3-16-23 -3 (GFNNX SDQXD) -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 Kx 0 0 0 3 0 0 Ky 0 5 0 5 0 0 0 5 P 19 25 12 20 2 7 (TZMUCH) We guess a "Z" after the word "MUCH", Then Kx[31%19=12] = 3 and so on ... Now for the wheel settings: i 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 Wheel 21 0 5 5 0 0 5 0 5 0 0 0 5 . . . . . . . 1 1 Wheel 19 0 3 3 0 3 3 0 0 0 3 0 0 3 . . . . . . 5. Calculate the beginning and ending of the key: Cipher: KWZA ... K L J F Plain : THEZ ... Z Z Z Z Key : 4440 ... 11 9 5 We guess that there are only two "Z" at the message end. The lugs pair [4,5] explains all key values. Here are all the possible values of the key: Key = { 0, 4, 5, 9 } We can try to decipher the rest of the message: Cipher KWZAL XAPQJ DVNEJ OMUPZ XKVAF K=0 ...ZO CZKJQ WEMVQ LNFKA CPEZU K=4 THE.S GDONU AIQZU PRJOE GTIDY K=5 ....T HEPOV BJRAV QSKPF HUJEZ K=9 ....X LITSZ FNVEZ UWOTJ LYNID Plain THEZS HIPSZ WEREZ PROTE CTEDZ Key 44404 59599 00599 44994 04045 And so on. 6. Try the word "ZMORNINGZ" at each position : i Cipher Key 0 VZRVDATTA ZMORNINGZ 21,12, 6,13,17, 9, 7, 0, 0 1 ZRVDATTAN ZMORNINGZ 25, 4,10,21,14, 2, 7, 7,13 ... 10 SEJNNKTTO ZMORNINGZ 18,17,24, 5, 1,19, 7, 0,14 11 EJNNKTTOA ZMORNINGZ 4,22, 2, 5,24, 2, 7,21, 0 12 JNNKTTOAH ZMORNINGZ 9, 0, 2, 2, 7, 2, 2, 7, 7 Hooray !!! We have found a piece of true key. Key = { 0, 2, 7, 2+7=9 } The known Pins of each wheel: i : 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 Kx : 2 0 2 2 0 2 2 0 0 Ky : 7 0 0 0 7 0 0 7 7 If we suppose having wheel 17 (Kx) and 19 (Ky): i: 0 1 2 3 Cipher:-21-25-17-21 (V Z R V) Kx 2 2 0 0 Ky 7 7 -1 -1 Plain : 13 9 (N J) : Unlikely ! If we suppose having wheel 17 (Ky) and 19 (Kx): i: 0 1 2 3 Cipher:-21-25-17-21 (V Z R V) Kx 0 0 Ky 0 0 7 7 -1 -1 Plain : 4 0 (E A) : Possible! If Kx[2] = 2, then Plain[2] = R else Plain[2] = P We deduce that the 3rd letter is "R". If Kx[3] = 2, then Plain[3] = N else Plain[3] = L Here, we can’t deduce anything. Each letter (N or L) is possible. Here are the results of our deductions: i : 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 Kx : 0 0 2 2 0 2 2 0 2 2] Ky : 0 0 7 7 7 0 0 0 7] Then we use known methods. 7. First, calculate the beginnings of the key: Cipher: G Z C F G G S Y N G V A Plain : T H E Z A D M I R A L Z Key : 0 7 7 5 7 10 5 7 5 7 7 0 If there are overlaps, the possible keys are : {0,x,y,z<=x+y} We can deduce that Kx=5, Ky=7 overlaps[x<->y]=2. We suppose that Wheel X is Wheel 17 and Y is Wheel 19: i: 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 6 Kx: 0 0 0 5 0 5 5 0 5 0 0 0 ]0 0 0 5 0 5 5 0 5 0 Ky: 0 7 7 0 7 7 0 7 0 7 7 0 ]0 7 7 0 7 7 0 7 Ov: -2 -2 -2 S: -1-1-1-1-1-1-1-1 C: C Z C F G G S Y N G V A G F C B D V D A Q S F N Y L Z 01618 513241125 (-) P: 2519142522 819 7 Z T O Z W I T H The plain text discovered seems correct. Our hypothesis is good (Wheel 17 has 5 lugs and Wheel 19 has 7 lugs). Then we use known methods. 8. One uses known methods. 9. One uses known methods. 10. No explanation (the methods used are known). 11. We don’t use new methods. 12. One uses known methods.