Friday, January 1, 2010

Encryption with Rotor machines


As a requirement of the module ‘Computer Security’ we had to engage in a forum discussion about the level of security provide by a 5-disk rotor machine used in encrypting messages from the Arabic language. I thought of blogging some interesting details we shared during the discussion.

Cryptography is the science of conducting secure communication. Rotor machine was the first electro-mechanical encryption device intended to automated cryptography. They became the most important device of the Second World War and remained dominant till nineteen fifties.

Structure of rotor machine

Each rotor in a rotor machine maps a character at its input face to one on its output face so that it implements fixed mono-alphabetic substitution. A generic rotor machine constitutes of number of such rotors. A plaintext character, which is input to the first rotor, generates an output so that it becomes the input to the second rotor. Finally, the last rotor produces the corresponding ciphertext. This idea can be illustrated using the following diagram.


If the rotor position is fixed, the collection of rotors implements a mono-alphabetic substitution। This is produced by constitution of the substitutions delineated by each individual rotors. Through encipherment of each plaintext character causes various rotors to move, a poly-alphabetic substitution will be resulted.


With a alphabet of 28 letters, when two rotors are next to each other and geared together, you have to type 28x28=784 letters before the key repeats. We can keep on adding rotors next to each other if the key length is not sufficient. Moreover, with a 5-disk rotor machine you will be able to obtain a period of 17,210,368 letters long. since Arabic is contextual, that is the way it is written depends upon the context, certain level of security is implicit with language characteristics. It says in standard Arabic style letters have considerably different shapes depending whether it connect with proceeding and/or a succeeding letter. Hence all primary letters have conditional forms depending on their positioning. That is depending on whether such letter is at beginning, middle or end of a word. For example in some letters the middle form starts with a short horizontal line on the right to ensure that it will connect with its preceding letter and, for some letters, a loop or longer line on the left with which to finish the word with a subtle ornamental flourish. Hence may be in reality more than 28 letters come into the scene providing period longer than 17,210,368.

When a rotor machine is used, the rotor machine itself is the algorithm. I.e. the way in which it is set up is the key. So when deciphering, recipient need to type the ciphertext letters to his rotor machine. If that machine was set up exactly in the same way as the message sender’s, plaintext can be identified. But as similar with other types of cipher systems, if you don’t know the key it is really difficult to read the message even the system which was used to encipher it is known.

If the key is unknown, finding the rotor setup is really hard. Say you have 5 rotors with alphabet of 28 letters, then there will be 28x28x28x28x28 distinct ways to set the starting position. In addition, the possible number of link up pairs is extremely high and its calculation is so complex. If you are interested this way of calculation could be found at http://www.codesandciphers.co.uk/enigma/steckercount.htm . This shows the difficulty of breaking code further.

At the same time still there is the problem of distributing the key. The problem is conveying a long key securely to the parties who need it takes time and there can be mistakes in key distribution.

But if a fixed setup is using this might not make a much trouble। But if it is as military event as was the case with German army, then there is a immense problem as the changed key need to be distributed daily. But what they were doing was using a key sheet specifying the required set up for each month. Hence when using rotors, it is required to use some trick as such to avoid the problems relating to distribution of long key.

in everyday writing, accents are often omitted in Arabic; the reader recognizes the words as a result of experience as well as the context.This may expose a threat in security of contextual languages. If there is a possibility for reader to recognize words because of experience as well as the context, then simple guesswork could do a great job in decrypting. Means by identifying some amount of letters without taking a further effort hacker can understand the meaning of plaintext. But again only understanding would be possible instead of modifying. If the plain text is small in length, as the key repetition is not occurred there is a possibility that hacker can map unidentified letters based on his/her prediction also. However, this is less likely to occur in case of a long plaintext.

When comparing with other attempts of cipher designers one advantage in rotor machine is that it does not require extraordinary abilities from their users. This was not the case with other methods, as they required patience to carry out lengthy, letter-perfect evolutions and uncertainty under time pressure or battle strength in military context.