page_title: Lorenz cipher
section_title: The key stream
hierarchical_section_title: Lorenz cipher / The key stream
caption_attribution_description: English: Lightened version of Image:SZ42-6-wheels.jpg The Lorenz machine was used by the Germans to encrypt high-level teleprinter communications. It contained 12 wheels with a total of 501 pins.
context_page_description: The Lorenz SZ40, SZ42a and SZ42b were German rotor stream cipher machines used by the German Army during World War II. They were developed by C. Lorenz AG in Berlin. The model name SZ was derived from Schlüssel-Zusatz, meaning cipher attachment. The instruments implemented a Vernam stream cipher.
  British cryptanalysts, who referred to encrypted German teleprinter traffic as Fish, dubbed the machine and its traffic Tunny and deduced its logical structure three years before they saw such a machine.
  The SZ machines were in-line attachments to standard teleprinters. An experimental link using SZ40 machines was started in June 1941. The enhanced SZ42 machines were brought into substantial use from mid-1942 onwards for high-level communications between the German High Command in Wünsdorf close to Berlin, and Army Commands throughout occupied Europe. The more advanced SZ42A came into routine use in February 1943 and the SZ42B in June 1944.
  Radioteletype rather than land-line circuits was used for this traffic. These non-Morse messages were picked up by Britain's Y-stations at Knockholt and Denmark Hill and sent to Government Code and Cypher School at Bletchley Park.
context_section_description: The logical functioning of the Tunny system was worked out well before the Bletchley Park cryptanalysts saw one of the machines—which only happened in 1945, as Germany was surrendering to the Allies.
  The SZ machine served as an in-line attachment to a standard Lorenz teleprinter. It had a metal base 19 in × 15.5 in (48 cm × 39 cm) and was 17 in (43 cm) high.  The teleprinter characters consisted of five data bits (or "impulses"), encoded in the International Telegraphy Alphabet No. 2 (ITA2). The machine generated a stream of pseudorandom characters. These formed the key that was combined with the plaintext input characters to form the ciphertext output characters. The combination was by means of the XOR (or modulo 2 addition) process.
  The key stream consisted of two component parts that were XOR-ed together. These were generated by two sets of five wheels which rotated together. The Bletchley Park cryptanalyst Bill Tutte called these the χ ("chi") wheels, and the ψ ("psi") wheels. Each wheel had a series of cams (or "pins") around their circumference. These cams could be set in a raised (active) or lowered (inactive) position. In the raised position they generated a '1' which reversed the value of a bit, in the lowered position they generated a '0' which left the bit unchanged. The number of cams on each wheel equalled the number of impulses needed to cause them to complete a full rotation. These numbers are all co-prime with each other, giving the longest possible time before the pattern repeated. This is the product of the number of positions of the wheels. For the set of χ wheels it was 41 × 31 × 29 × 26 × 23 = 22,041,682 and for the ψ wheels it was 43 × 47 × 51 × 53 × 59 = 322,303,017. The number of different ways that all twelve wheels could be set was 1.603 x 10¹⁹ i.e.16 billion billion.
  The set of five χ wheels all moved on one position after each character had been enciphered. The five ψ wheels, however, advanced intermittently. Their movement was controlled by the two μ ("mu") or "motor" wheels in series. The SZ40 μ₆₁ motor wheel stepped every time but the μ₃₇ motor wheel stepped only if the first motor wheel was a '1'. The ψ wheels then stepped only if the second motor wheel was a '1'. The SZ42A and SZ42B models added additional complexity to this mechanism, known at Bletchley Park as Limitations. Two of the four different limitations involved characteristics of the plaintext and so were autoclaves.
  The key stream generated by the SZ machines thus had a χ component and a ψ component. Symbolically, the key that was combined with the plaintext for enciphering and with the ciphertext for deciphering, can be represented as follows.
  key = χ-key ⊕ ψ-key
  However to indicate that the ψ component often did not change from character to character, the term extended psi was used, symbolised as: Ψ'. So enciphering can be shown symbolically as:
  plaintext ⊕ χ-stream ⊕ ψ'-stream = ciphertext
  and deciphering as:
  ciphertext ⊕ χ-stream ⊕ ψ'-stream = plaintext.
caption: The Lorenz SZ machines had 12 wheels each with a different number of cams (or "pins").                                            OKW/Chi
  wheel name ABCDEFGHIJKL BP wheel
  name[14] ψ1 ψ2 ψ3 ψ4 ψ5 μ37 μ61 χ1 χ2 χ3 χ4 χ5 Number of
  cams (pins) 434751535937614131292623
exif: {"Image Make": "Panasonic", "Image Model": "DMC-FZ10", "Image Orientation": "Horizontal (normal)", "Image XResolution": "72", "Image YResolution": "72", "Image ResolutionUnit": "Pixels/Inch", "Image Software": "Adobe Photoshop CS2 Windows", "Image DateTime": "2006:06:10 16:43:27", "Image YCbCrPositioning": "Co-sited", "Image PrintIM": "[80, 114, 105, 110, 116, 73, 77, 0, 48, 50, 53, 48, 0, 0, 14, 0, 1, 0, 22, 0, ... ]", "Image ExifOffset": "440", "Thumbnail Compression": "JPEG (old-style)", "Thumbnail XResolution": "72", "Thumbnail YResolution": "72", "Thumbnail ResolutionUnit": "Pixels/Inch", "Thumbnail JPEGInterchangeFormat": "1138", "Thumbnail JPEGInterchangeFormatLength": "8513", "EXIF ExposureTime": "1/80", "EXIF FNumber": "14/5", "EXIF ExposureProgram": "Program Normal", "EXIF ISOSpeedRatings": "100", "EXIF ExifVersion": "0220", "EXIF DateTimeOriginal": "2004:12:30 16:58:58", "EXIF DateTimeDigitized": "2004:12:30 16:58:58", "EXIF ComponentsConfiguration": "YCbCr", "EXIF CompressedBitsPerPixel": "4", "EXIF ShutterSpeedValue": "3161/500", "EXIF ApertureValue": "3", "EXIF ExposureBiasValue": "-33/100", "EXIF MaxApertureValue": "3", "EXIF MeteringMode": "Pattern", "EXIF LightSource": "Flash", "EXIF Flash": "Flash fired, auto mode", "EXIF FocalLength": "25/2", "EXIF FlashPixVersion": "0100", "EXIF ColorSpace": "sRGB", "EXIF ExifImageWidth": "2304", "EXIF ExifImageLength": "1728", "Interoperability InteroperabilityIndex": "R98", "Interoperability InteroperabilityVersion": "[48, 49, 48, 48]", "EXIF InteroperabilityOffset": "1012", "EXIF SensingMethod": "One-chip color area", "EXIF FileSource": "Digital Camera", "EXIF SceneType": "Directly Photographed", "EXIF CVAPattern": "[0, 2, 0, 2, 1, 0, 2, 1]", "EXIF CustomRendered": "Normal", "EXIF ExposureMode": "Auto Exposure", "EXIF WhiteBalance": "Auto", "EXIF DigitalZoomRatio": "0", "EXIF FocalLengthIn35mmFilm": "75", "EXIF SceneCaptureType": "Standard", "EXIF GainControl": "None", "EXIF Contrast": "Normal", "EXIF Saturation": "Normal", "EXIF Sharpness": "Normal", "EXIF SubjectDistanceRange": "2"}