# Lorenz Cipher

## Introduction §

The Lorenz SZ 40 and SZ 42 (Schlüsselzusatz, meaning "cipher attachment") were German cipher machines used during World War II for teleprinter circuits. Teleprinters used the 32-symbol Baudot code, which consists of five channels each of which is a stream of bits which can be represented as a dot or cross (or a 0 or 1). The Lorenz machine outputs groups of five pseudo-random bits to be XORed with the plaintext. The pseudo-random bits were generated by ten pinwheels, five of which stepped regularly, termed the χ ("chi") wheels, and five of which were stepped irregularly, termed the ψ ("psi") wheels. The stepping of the ψ wheels was determined by two more pinwheels, termed the "motor wheels". Apart from the stepping of the five irregular pinwheels (which either all stepped together, or all stayed together), the Lorenz machine is actually five parallel pseudorandom generators.

British cryptographers referred to encrypted German teleprinter traffic as "Fish", and called the machine and its traffic "Tunny". While the well-known Enigma machine was generally used by field units, the Lorenz machine was used for high-level communications.

The Lorenz cipher is an early example of what are today called stream ciphers, in which a continuous stream of pseudo-random information is used to obscure the plaintext, usually by XORing the psuedo-random stream with the plaintext. It was primarily to break the Lorenz cipher that the British devised what is now considered the world's first electronic computer, COLOSSUS.

## Operation §

A good description of a simplified Lorentz system is provided at www.cimt.plymouth.ac.uk.

The Lorenz cipher had twelve pinwheels, all of which could have all their pins set by the user. These wheels were separated into 2 groups of 5 wheels, along with 2 control wheels.

The wheels of the first group (the chi wheels) had sizes 41, 31, 29, 26, and 23. Those of the second group (the psi wheels) had sizes 43, 47, 51, 53, and 59.

The two additional wheels were of size 37 and 61. The chi wheels and the wheel with 61 positions advanced one position with every letter enciphered. When the current pin (before moving) on the 61-position wheel was active, the wheel with 37 positions advanced one space. The psi wheels step in an irregular pattern that depends on the 37-pin wheel.

To adequately explain how the stepping of the psi wheels was implemented, it is necessary to introduce 3 new terms, the BASIC MOTOR, the LIMITATION and the TOTAL MOTOR. The BASIC MOTOR is the current position of the 37-pin control wheel. The TOTAL MOTOR is the combination of the LIMITATION and the BASIC MOTOR, in that when the BASIC MOTOR is 0 and the LIMITATION is 1, the TOTAL MOTOR is 0 and the psi wheels do not move, otherwise the TOTAL MOTOR is 1 and the psi wheels increment 1 position.

Example:

 Basic Motor `x . . . x . . . x x x . x . x x .` Limitation `. x . x x . . x x x . . x x . . x` Total Motor `x . x . x x x . x x x x x . x x .`

There are several ways of calculating the LIMITATION. The simplest corresponds to “no limitation”, which is equivalent to a limitation stream that consists entirely of crosses, so that the BASIC MOTOR and TOTAL MOTOR are the same.

 LIMITATION 1: Chi2 lim The active character of chi 2 (the second chi wheel) at any position is given by the character of chi 2 which was active in the previous position. This is also called Chi 2 ONE BACK. LIMITATION 2: Psi1 lim The active character of the limitation is given by the XOR of the character of chi 2 which was active in the previous position and the active character of psi 1 which was active in the previous position. LIMITATION 3: P5 lim The active character of the limitation is given by the XOR of the character of chi 2 which was active in the previous position and the character of P5 (the fifth bit of the plaintext) which was active two positions previously. LIMITATION 4: Psi1 P5 lim The active character of the limitation is given by the XOR of the character of chi 2 which was active in the previous position, the active character of psi 1 which was active in the previous position, and the character of P5 (the fifth bit of the plaintext) which was active two positions previously.

The limitations which involve P5 make the key stream dependent on the plaintext.

## The Key §

The key material for the Lorenz cipher included the bit patterns for each of the 12 wheels (early in the war these were changed monthly, however later they were changed much more often), along with the starting positions for each wheel. The starting positions were often sent as a 12 character 'indicator setting' sent at the beginning of each message.

An example set of wheel patterns would look like the following:

```bk1 ...xxxx....xx....x.xx..x..xx.x.xx.x.xxxx.

bk2 xx..xxx.xx...x.x.xx...x....xxx.

bk3 ..xxx.xx..x....xxx..xx.xx..xx

bk4 ..xx..x.xx..x..xx..x..xxxx

bk5 .x...x.xx..x...xxx.xxx.

bm1 xxx.x.xx..xx..xx...xxxx.x.xx.xx...xx....xxxx.xx..xx...xx....x

bm2 x.xxx.x.x.x.x..x.x.xxx.x.x.x.x.x.x.x.

bs1 ..x.x.x.x.x..x..x.xx.xx.x.x..xx.xxx..xxx...

bs2 ..x.xx.x.x.x.x.x.xx..xx.x..x.xxxx.....xxx..x.xx

bs3 x.x.x.x.x.x.x..x..xx.x.x.xxxx....xxx...xxx.xx..x..x

bs4 x.x..xx.x.x.x.x.x.xx.x....xx..xx..xx.xxxxx.x..x....x.

bs5 .x.x.x.x.xx...x.x..xxx.xxxx.xx.x....x...x..xx.xx..xx..x.x.x
```
These are the same as the BREAM patterns that were used in WWII.

Wikipedia provides a good overview: http://en.wikipedia.org/wiki/Lorenz_cipher.

The General report on Tunny, written by Allan Turing, provides a very in depth analysis of the Lorenz cipher and the COLOSSUS machine used to break it. The Tunny Report.

An overview of the Lorenz cipher: http://www.quadibloc.com/crypto/te0301.htm

The National museum of computing ran a challenge to crack messages enciphered using the Lorenz cipher, the messages can be seen here: http://www.tnmoc.org/cipherp.htm. The winner of the challenge has an Ada implementation of the Lorenz cipher here: http://www.schlaupelz.de/SZ42/SZ42_software.html