Enigma

From Teknologisk videncenter
Revision as of 10:06, 5 December 2010 by Heth (talk | contribs) (8 bit Enigma machine)
Jump to: navigation, search

Enigma Articles

8 bit Enigma machine

There are three C-programs and four file in this project. All singlethreaded C programs.

Number of possible keys when using three wheels

In the example below there is a caculation of possible keys that is

  • Three whells of 8 bit each diffently coded (fx. wheel[0]=67,wheel[1]=234 .. wheel[67]=165 .. )
  • An 8 bit Rotor-Reflector which is symmetricaly coded. (Fx. rr[0]=67 then rr[67]=0, rr[87]=167 then rr[167]=87 etc. )
  • When the encryption/decryption starts each wheel can be in 1 of 256 positions. Called the notch position
heth@MachoGPU:~/enigma$ <input>bc</input>
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
<input>/* Define the Factorial function */ 
define frac(x) {
  if (x>1) {
    return (x * f (x-1))
  }
  return (1)

}

/* Number of possible alterations of a 8 bit wheel */
wheel=frac(256)
print wheel</input>
85781777534284265411908227168123262515778152027948561985965565037726\
94525531475893774402913604514084503758853423365843061571968346936964\
75322289288497426025679637332563368786442675207626794560187968867971\
52114330770207752664645146470918732610083287632570281898077367178145\
41702505230186084953190681382574810702528175594594769870346657127381\
39286205234756808218860701203611083152093501947437109101726968262861\
60626366243502284094419140842461593600000000000000000000000000000000\
0000000000000000000000000000000

<input> /* Number of installed wheels in the Enigma engine*/
numberofwheels=3

/* Number of possible alterations of the 8 bit rotor-reflector.
   The rotor-reflector can't point to it-self. (fx. location 8 can't be 8)
*/
rotorreflector=frac(255)
print rotorreflector</input>
33508506849329791176526651237548149420225840635917407025767798842862\
08799035732771005626138126763314259280802118502282445926550135522251\
85672769253319307041281108333032565932204170002979216625073425339051\
37544660457112403384627010340202629925813784231472766366436471553963\
05352541105541439434840109915068285430675068591638581980604162940383\
35658673919826878210492461407660579356286524198217620742862096977680\
31494674313868079724382476891586560000000000000000000000000000000000\
00000000000000000000000000000
<input>

/* Number of possible startpositions of the three wheels.
   they are called a notch from the original mechanical solution
*/ 
notches=256*256*256
print notches</input>
16777216
<input>
/*Total number of Keys when using a 8 bit Enigma with three wheels */
wheel*numberofwheels*rotorreflector*notches</input>
14467425940815419878550914285328747194412838285887202913906796612290\
67116765686074239837002699523310587812021105128921519898929662849673\
80231859551685345801700678590340949512766773530970639425397581454798\
34629363249827620200556239557412599222204518999540726185192515996315\
06978129392323972906002241190936561257411009104030200763332968508802\
10053380885667825490547810051729838486330141341759611086561117956500\
02210195590742957751653052758866489611046357269440002628221514248948\
17132504901094529220429149272922120473850361954385338800798632554213\
60438811591136370963675381915493290515801660130577959111839885736840\
77541504957308491144024012326090397003948528853785364705857026051935\
47050340165465982389653696093503539510788359067272108792866788729818\
77493077624052679059588612553113715864219395902995530561734847463169\
09861780870355495760296743612825305064871402809304345105972352826182\
65297223680000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000000000000000

If we used a 10 bit rotor

Or try and imagine a 32 bit wheel (Then we would need a better implementation of frac)

<input>frac(1024)</input>
54185287960588572830769219446838547380015539635380134444828702706832\
10612073376603733140984136214586719079188457089807539319941657701873\
68260454133333721939108367528012764993769768292516937891165755680659\
66374794731451840488667767255612518869433525121367727452196343077013\
37132057962484331288700884361716546902375183904529447322778084029321\
58722061853806162806063925435310822186848239287130261690914211362251\
14468471388858788162925210404629531594994390035788241024393431503744\
41138908061814062108639532752353758850185984515822295996545585412427\
89130902486944298610923153307579131675745146436304024890820442907734\
56182736903050225279692655307296737099075874779312763510470246988966\
79614621330262371589732278578146318071564277676440645910850765647834\
56324457736853810336981776080498707767046394272605341416779125697733\
37456803747518667626596166561588468145026333704252266414186215704682\
56847733609443267374936766749150989537681129458316266438564790278163\
85730291542667725665642276826058264393884514911976419675509290208592\
71315636298329098944105273212518724952750131407167640551693619078182\
12367019122957673631170541265899299164820085157817519554669109028387\
29232224509906388638147771255227782631322385756948819393658889908993\
67087451686065309841102029985381628156433498184710577783953474253149\
96221034888075845137057698397639931039296650460461211666513451311495\
13657400869056334867859885025601787284982567787314407216524272262997\
31979156860362940662474010148269755953315573665880056292127468065728\
52015704019406922855578006114290557553245497940089398491468126398607\
50085263298820224719585505344773711590656682821041417265040658600683\
84494510435499881288680131655155171467338832334085176381971359131237\
25486737347835373163415173693875652128997265979649032412087273486906\
99802996369265070088758384854547542272771024255049902319275830918157\
44820519642107283720493729351617534195777542245315244228039137240771\
78916612030610402558300550338867900521160254087404546209383843676378\
86658769912790922323717371343176067483352513629123362885893627132294\
18356588401041872786935443907708527828855830842709046107501900718493\
31399155582127523923298797806496390753338457191738228405018695704636\
26600235265587502335595489311637509380219119860471335771652403999403\
29636024557725796367328665434895732574099971056713162327234576676193\
76514081039991936339082864205100985774545240681068973924931382873622\
26257920000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000000000000000\
00000000000000000000000000000000000000000000000000000000

When the wheels are known

Like during World War II the Allied get hold of the Wheels for the Enigma and only had to find the order of the Wheels and the startposiotion of each installed wheel.

So with the 8 bit Enigma engine with three wheels installed. There are 10 known wheels in the example below.

<input>/* Total number of wheels possible */
wheelstotal=10

/* With three wheels installed there would be 10*9*8 ways configure */
wheelcombinations=10*9*8

/* Each wheel can start in 256 ways */
notches=256*256*256

/* Total number of keys, when the wheels are known */
wheelstotal*wheelcombinations*notches</input>
120795955200
  1. A Crib is a known plaintext message in the crypted message. You can Brute-force the crypted message until you get a match on the Crib