Limited Entropy Dot Com Not so random thoughts on security featured by Eloi Sanfèlix

15Apr/0912

Crypto Series: WWII – Enigma

With this post we're leaving classical pencil and paper ciphers and getting into the mechanic ciphers used during the World War II era. We're gonna see the most famous of the cipher machins, the Enigma machine used by the Germans. Our analysis will be based on the book Applied Cryptanalysis from Mark Stamp and Richard M. Low. A very recommendable book if you are interested on cryptanalysis, really.

The Enigma Machine

The Enigma machine was developoed and patented by Arthur Scherbius in 1918, and was adopted by the nazi Germany for military and diplomacy use. Polish cryptanalysts broke the Enigma cipher in the late 1930s, and Allieds exploited this knowledge during WWII.

Máquina Enigma

Máquina Enigma

It is said that thanks to Enigma being broken without the Germans noticing it (thanks to the more or less careful use of the obtained intelligence) the WWII was shortend one year or even more. There has been a lot of writing around Enigma, and I'm not an expert in the field, so I refer you to Google if you want more historical information 🙂

Encrypting and decrypting with Enigma

To encrypt with Enigma, after initializing the machine with the key as we'll see later, one simply had to press the plaintext letter to encrypt in the keyboard, and then the corresponding ciphertext letter would be enlightened in the upper (back-lighted) keyboard.

To decrypt, one had to set the machine into the corresponding state and press the received ciphertext letter. Then, in the upper keyboard the plaintext letter would get enlightened.

Enigma's features

Enigma was an electro-mechanical machine, based on the use of rotors. In the previous figure, one can easily see the mechanical keyboard and the back-lighted keyboard, which worked as input and output of the device.

Further, there is what seems to be a switchboard (stekker in German) with cables connecting one of the ends with another, and three rotors in the upper side of the machine. The configuration of these rotors and the cables of the stekker are the initial key of the machine.

Once the machine was initialized, it was possible to press in the keyboard the plaintext or ciphertext letters and obtain the ciphertext or the plaintext respectively. The workings of the machine were essantially as follows:

After pressing a key in the keyboard, a signal was sent through the corresponding stekker pin. Thanks to the cable configuration, this signal was transmitted to a different letter. Thus, the stekker worked as a mapping in the alphabet, where each letter was substituted by another one: a simple substitution.

Rotores de la máquina Enigma

Rotores de la máquina Enigma

After it, the signal went through the three rotors, reflected in the reflector and went back through the rotors (see figure). Finally, from the rotors it went again through the stekker, which performed a new substitution, and turned on the backlight of the corresponding letter. The net effect of the rotors and the reflector was again a permutation: each letter was converted into a different one.

However, if this were it, we would have no more than a simple substitution, with the only complexity of the use of an electromechanical machine. What Enigma added was a variation of the disposition of these rotors.

Each time a key was pressed, the rightmost rotor stepped one position. The middle rotor stepped in an odometer-like fashion, each time the rightmost rotor went through all of its steps. The leftmost rotor stepped in the same way, but depending on the middle rotor.

Further, it was possible to select the point where each rotor would step. This means that it could be when the previous rotor reached the initial position, but it could be in a different position. We could set it, for instance, to step when the previous rotor had stepped 5 times. From there on, it would step every time the initial rotor was in that position.

Therefore, Enigma was a cipher where each letter was encrypted with a different simple permutation of the alphabet... but with an enormous number of possible permutations.

For a more detailed analysis of the Enigma machine, please refer to the aforementioned book, where the way the machin works is analysed, the key space size (i.e. number of possible keys) is computed and an attack is presented.

Posted by Eloi Sanfèlix

Comments (12) Trackbacks (0)
  1. Aquí van un par de applets que simulan la máquina Enigma.

    http://russells.freeshell.org/enigma/

    http://homepages.tesco.net/~andycarlson/enigma/enigma_j.html

    Cryptool también ofrece una simulación para ver el algoritmo paso a paso.

  2. Buenas, he buscado por google el método que usaron los héroes polacos para vencer a la enigma pero no he encontrado nada en concreto. Alguien tiene alguna referencia o link para dejarme?

    Gracias y ánimos con el curso!

  3. @Nork: por un lado está la historia de que matemáticos polacos tenían un método y que antes de la invasión de Polonia éstos compartieron esa información con los Ingleses, pero por otro lado el principal fail de los alemanes fueron debilidades debidas _al modo_ en el que usaban la máquina Enigma. Sus mensajes siempre tenían las mismas formas, solían empezar y terminar igual, con algunas variaciones y contenían cosas repetidas en mensajes como partes sobre climatología, etc y además el mismo mensaje se envíaba en repetidas ocasiones cifrados con diferentes claves. Las investigaciones iban enfocadas a obtener el estado inicial según esas pistas. Los aliados ya conocían por alguna fuente u otra el funcionamiento interno de las máquinas Enigma pero sin la clave era una tarea no alcanzable. Gracias a esos factores el objetivo era detectar el estado inicial de la máquina Enigma. El operador alemán de la máquina recibía mensualmente una hoja con las claves de un mes grabadas en tinta soluble en agua (para poder borrar la información rápidamente). Si los aliados recuperaban una de esas hojas tenían claves para el resto de ese mes. Para poder hacer el criptoanálisis se crearon máquinas electromecánicas y básadas en válvulas de vacio.
    http://library.thinkquest.org/28005/flashed/timemachine/courseofhistory/bombe.shtml

  4. Muchas gracias vierito5. Me imagino el mal trago que hubieron de pasar los encargados de descifrar los textos de Enigma.

    Gracias!

  5. @Nork: tienes pinta de interesarte el tema histórico del asunto. Te recomendaría leer el libri Criptonomicón. A los otros pájaros no porque imagino que ya se lo habrán leído xD

  6. El libri, el lobri, el libro, qué más da… si ya nadie lee xD

  7. Juas, pues yo no me lo he leído…

  8. Je… yo sí, tiempo ha.

    Algo así como cuatro o cinco o seis años…. cuando salió la edición en español. No sé cuanto tiempo hace la verdad, pero recuerdo que me devoré los tomos a razón de uno por semana o algo así… además empecé el libro teniendo solo el tomo 1, y lo acabé antes de que llegara el tomo 2 a mi librería (mi madre tiene una librería…), y lo mismo con este y el tercero.

    Buena recomendación sí, un libro entretenido sin duda.

  9. Tengo encima de la mesa el de “Neuromancer” pero tampoco me lo he leído aún jejeje Son libros pendientes pero es que me da una pereza empezarlos…

  10. Muchas gracias por la recomendación! Este lunes mismo me paso por alguna librería a ver si lo tienen.

    TuxeD podrías montar algún día un post con una lista de libros interesantes que has leído sobre el tema. Digo TuXeD por ser el amo y señor de el blog pero si algún otro quiere dejarlo en comentarios como 0x6f… también es válido 🙂

    S4ludos!

  11. Tiene razon Nork, seria interesante que postearas algo como lo que menciona algún día!. =)

    Bytes!

  12. Great post! Just wanted to let you know you have a new subscriber- me!


Leave a comment

No trackbacks yet.