210 likes | 334 Vues
This document presents a detailed revisitation of the Enigma machine, capturing both its mechanical design and high-level software simulation. The work encompasses finalized design selections, block diagrams for processes, and high-level code implementation in C. The document outlines the operation of rotors and reflectors, the roles of spring-loaded contacts, and the modular architecture that allows for easy component revision. Additionally, it details the memory storage for settings and swaps, thus enhancing the machine's complexity and efficacy in encoding messages.
E N D
Team M1Enigma MachineAdithya Attawar (M11)Shilpi Chakrabarti (M12)Zavo Gabriel (M13)Mike Sokolsky (M14) January 30, 2006 Original mechanical design revisited, High-level software simulation, Architecture flowcharts
Status • Finished: • Design selections • Block diagram for processes • High-level implementation in C • To Do: • Behavioral Verilog (almost done) • Schematic • Layout • Testing • Simulation
Functional Description • Enigma Operation Revisited
Enigma Operation: Rotors & Reflector • 26 spring-loaded contacts on each side • Set to an arbitrary initial position for each message • Each rotor has unique internal wiring to perform letter swaps • Rightmost rotor steps one notch with each keystroke, the others every 26, 262, etc. • Reflector does not move; hard-wired; swaps letters and ‘reflects’ signal back through rotors
Enigma Operation: Steckerboard • Manually wired and changed daily • Daily settings specified in codebooks given to operators • Matched letter pairs (A-J, J-A) • Increased number of possible machine configurations by 26*24*22*… = ~1013
Design Decisions • Revised entire system architecture • Modular design – able to add/revise components without changing basic architecture • Implement steckerboard, rotors, reflector using memories • Address: (Character + Wheel Position)%26 • Value in cell: New character for next swap • Will need to implement a 5-bit modulo-26 adder • Serial input of initial rotor settings/order
Steckerboard Memory • 26x5-bit cells • Programmable by user on startup • Stores information about swaps • newChar = stecker[currentChar] • Swaps MUST BEmatched pairs: • If stecker[A] = ‘G’ then stecker[G] = ‘A’
Rotor and Reflector Memory • Same basic idea as Steckerboard • 8 “rotors”: • 26x5-bit cells • Swaps are NOT matched pairs • 1 “reflector” • 26x5-bit cells • Swaps MUST BE matched pairs • Differences: • Not programmable: bits in memory are permanently set during manufacturing • Swap pairs unique to each wheel • Control logic specifies how many “rotors” used, in what “position,” and in what order
I-Reg Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Character Input Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Steckerboard Swap & Increment Wheels Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Calculate Rotor Swap Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Store New Character from Rotor Swap Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Calculate Reflector Swap Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Store New Character from Reflector Swap Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Calculate Reverse Rotor Swap Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
I-Reg Store New Character from Reverse Rotor Swap Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
Steckerboard Swap & Output Encrypted Character I-Reg Plug Input Wheel Select N-Reg C-Reg ROM 232 X 5bit 5-bit %26 Adder RAM 26 X5bit Wheel Pos + 13 % 26 O-Reg
Implementation in C (snippet) • while((ch_in=(char)getchar())!=10){ // take input until <ENTER> • c_reg = (unsigned short) ch_in - 97; // ASCII 'a' is value 97 so correct to a=0 • if(c_reg>25) • exit(0); • if((wheel_pos[wheel_order[0]] = (wheel_pos[wheel_order[0]]+1)%26)==0) // rotate wheels • if((wheel_pos[wheel_order[1]] = (wheel_pos[wheel_order[1]]+1)%26)==0) • if((wheel_pos[wheel_order[2]] = (wheel_pos[wheel_order[2]]+1)%26)==0) • if((wheel_pos[wheel_order[3]] = (wheel_pos[wheel_order[3]]+1)%26)==0) • if((wheel_pos[wheel_order[4]] = (wheel_pos[wheel_order[4]]+1)%26)==0) • if((wheel_pos[wheel_order[5]] = (wheel_pos[wheel_order[5]]+1)%26)==0) • if((wheel_pos[wheel_order[6]] = (wheel_pos[wheel_order[6]]+1)%26)==0) • if((wheel_pos[wheel_order[7]] = (wheel_pos[wheel_order[7]]+1)%26)==0); • //printf("%d %d ",wheel_pos[wheel_order[0]],wheel_pos[wheel_order[1]]); • if(use_stecker) // initial stecker use • c_reg = stecker[c_reg]; • for(i=0;i<num_wheels;i++) { // step through wheels • c_reg = wheel_settings[wheel_order[i]][(c_reg+wheel_pos[wheel_order[i]])%26]; • if(DEBUG) • printf("%c ",(char)(c_reg+97)); • } • if(reflect){ // if we're reflecting, which it looks like you have to do for it to work • c_reg = reflector[c_reg]; // look up new value in reflector • if(DEBUG) • printf("%c ",(char)(c_reg+97)); • for(i=num_wheels-1;i>=0;i--){ // now go through backwards, find the location in the wheel that holds • j=0; // the value of c_reg, and save the location into c_reg • while(wheel_settings[wheel_order[i]][(j+wheel_pos[wheel_order[i]])%26]!=c_reg) • j++; • c_reg = j; • if(DEBUG) • printf("%c ",(char)(c_reg+97));
Implementation in C • Fully simulates an Enigma with up to 8 rotors, a reflector, and a steckerboard • Sample output • 3 rotors: order 1-2-0, setting F-H-J • 5 stecker pairings: AP, CN, HS, KT, VX cmu-163055:~/Documents/Programs/Enigma mvs$ ./enigma helloworld (Input string from user) xoserrykrb (Encoded output) cmu-163055:~/Documents/Programs/Enigma mvs$ ./enigma xoserrykrb (Input string – the encoded text back in) helloworld (Output – encrypt and decrypt are the same)
Problems & Questions • How to make it more secure? • Variable rotor increments? • Must be some function of input character to preserve symmetrical encrypt/decrypt • Otherwise you lose your message!