# Lorenz Cipher

This continues my discussion of the Lorenz Machine. The Lorenz machine consisted of a set of wheels. There were two wheels for each bit, as there were 5 bits to encode, this made 10 key wheels.

Each wheel had pins which could be raised or lowered, representing 'mark' or 'space', '1' or '0'. The settings of these pins comprised the overall secret key of the day.

There were two wheels for the first bit, the first took 41 characters to revolve, and the second took 43. This meant that it would take 1763 characters before they returned to the same position.

The second bit had wheel sizes 31 and 47, the third had 29 and 51, the fourth had 26 and 53, the last had 23 and 59.

Each bit of the plaintext was XORed with each of the bits on the wheels. The result is the ciphertext. Each character in the plaintext had each of its bits XORed with a bit produced by XORing the two wheels together. As the wheels turned, this meant that a each bit was either left alone, or inverted, in a pseudo random way.

Each bit within the plaintext would take a different number of characters before the pattern repeated - typically about 1500 characters, but as each bit would repeat at differing times there would be an extremely large amount of text before the overall key would repeat.

However - the overall string of key bits was not truly random, it was only seemingly random.

To further complicate things, the 'key wheels' were stepped irregularly under the control of two 'control' wheels.

In essence, suppose the first key wheel, a, had K(a)=1, and wheel b had K(b)=0, then the effective key for that bit is '1' (as the key bits are different). This would be XORed with the corresponding plaintext bit.

Of course, the people at Bletchley knew nothing of this at first, they had only what looked like a long random string of teletype. They did not even know the detail of how it was produced. They had to actually decrypt a message in order to work out how the messages were made... and once this was done, only then could they work out how to solve the messages! A true case of 'Chicken and Egg'.

The big break came on the 30th August 1941 when one German operator made a mistake.....