diff --git a/enigma.ino b/enigma.ino index c55272d..8fcca6e 100644 --- a/enigma.ino +++ b/enigma.ino @@ -34,21 +34,52 @@ Rotor rotors [] = { // id name wiring notch // == ==== ====== ===== { "ABC", "ABC", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "" }, // 0 alphabet + + // { "I", "I", "EKMFLGDQVZNTOWYHXUSPAIBRCJ", "Q" }, // 1 { "II", "II", "AJDKSIRUXBLHWTMCQGZNPYFVOE", "E" }, // 2 { "III", "III", "BDFHJLCPRTXVZNYEIWGAKMUSQO", "V" }, // 3 { "IV", "IV", "ESOVPZJAYQUIRHXLNFTGKDCMWB", "J" }, // 4 { "V", "V", "VZBRGITYUPSDNHLXAWMJQOFECK", "Z" }, // 5 + + // { "VI", "VI", "JPGVOUMFYQBENHZRDKASXLICTW", "ZM" }, // 6 { "VII", "VII", "NZJHGRCXMYSWBOUFAIVLPEKQDT", "ZM" }, // 7 { "VIII", "VIII", "FKQHTLXOCBJSPDZRAMEWNIUYGV", "ZM" }, // 8 - { "beta", "Beta", "LEYJVCNIXWPBQMDRTAKZGFUHOS", "" }, // 9 - { "gamma", "Gamma", "FSOKANUERHMBTIYCWLQPZXVGJD", "" }, // 10 - { "UKW-A", "UKW A", "EJMZALYXVBWFCRQUONTSPIKHGD", "" }, // 11 reflectors + { "beta", "Beta", "LEYJVCNIXWPBQMDRTAKZGFUHOS", "" }, // 9 M4 only + { "gamma", "Gamma", "FSOKANUERHMBTIYCWLQPZXVGJD", "" }, // 10 M4 only + + // reflectors + { "UKW-A", "UKW A", "EJMZALYXVBWFCRQUONTSPIKHGD", "" }, // 11 { "UKW-B", "UKW B", "YRUHQSLDPXNGOKMIEBFZCWVJAT", "" }, // 12 { "UKW-C", "UKW C", "FVPJIAOYEDRZXWGCTKUQSBNMHL", "" }, // 13 - { "UKW-B-thin", "UKW B thin", "ENKQAUYWJICOPBLMDXZVFTHRGS", "" }, // 14 - { "UKW-C-thin", "UKW C thin", "RDOBJNTKVEHMLFCWZAXGYIPSUQ", "" } // 15 + { "UKW-B-thin", "UKW B thin", "ENKQAUYWJICOPBLMDXZVFTHRGS", "" }, // 14 M4 only + { "UKW-C-thin", "UKW C thin", "RDOBJNTKVEHMLFCWZAXGYIPSUQ", "" } // 15 M4 only +}; + + +typedef struct { + char *name; + char *description; + Rotor rotor_types[]; + Rotor reflector_types[]; +} EnigmaType; + +EnigmaType enigma_types[] = { + { + "M3", + "Army", + { rotors[1], rotors[2], rotors[3], rotors[4], rotors[5] }, + { rotors[11], rotors[12] } + }, + + { + "M4", + "Navy", + // work out thin rotors + { rotors[1], rotors[2], rotors[3], rotors[4], rotors[5], rotors[6], rotors[7], rotors[8] }, + { rotors[11], rotors[12] } + } }; // entry wheel "EintrittswalzeEintrittswalze" @@ -166,7 +197,8 @@ char encode (char c) { } pin = stridx(AZ, rotors[reflector_type].wiring[pin]); if (debug_mode) { - Serial.print("->"); Serial.print(AZ[pin]); + Serial.print("->"); + Serial.print(AZ[pin]); Serial.print(" "); } @@ -248,8 +280,6 @@ void init_buf (char *buf) { } } -// 01234 - void add_to_buf (char *buf, char c) { for (int i=0; i demo_mode + // enigma type? menu -> enigma_type + // rotor[ +} + +void loop () { + if (config_mode) { + config(); + } else if (demo_mode) { + demo(); + } else { + enigma(); + } +} + + +/* + Eintrittwalze entry wheel (stator) + Greek wheels Beta and Gamma [for obvious reasons] used in the M4 + Grundstellung ground setting + Ringstellung ring setting + Stecker plug + Steckerbrett plugboard [sometimes referred to as "Stecker board"] + Umkehrwalze reflector + Walzen wheels + Walzenlage wheel order + */ + + /* +https://cryptocellar.org/Enigma/index.html +http://www.mlb.co.jp/linux/science/genigma/enigma-referat/node4.html#SECTION00043000000000000000 + + */