Enigma Analysis

The cryptoanalysis methods implemented here include:

Author

Requirement

See …

Rejewski

encoded Spruchschluessel

Decrypted Secrets

Turing

unencoded crib

Decrypted Secrets

Gillogly

language statistics

CrypTool

None of these methods always succeed. As a rule of thumb, the Turing and Gillogly attacks require at least 30 characters to get sufficient analysis results.

class analyzeEnigma.TagesschluesselRange(enigma: Optional[MzEnigma.enigma.Enigma] = None, umkehrwalzenList: Optional[List[MzEnigma.component.Umkehrwalze]] = None, walzenList: Optional[List[MzEnigma.component.Walze]] = None, tagesWalzenStellungenList: Optional[List[str]] = None, zusatzwalzenList: Optional[List[MzEnigma.component.Zusatzwalze]] = None, spruchScoring: Optional[MzEnigma.enigma.SpruchScoring] = None, blank: str = '', notify: Optional[Callable[[str], None]] = None)[source]

Represents a range of Tagesschluessel and analysis methods working on them

Parameters
  • enigma – model of the Enigma (required)

  • umkehrwalzenList – ‘Umkehrwalze’ (if undefined, randomly selected)

  • walzenList – List of type ‘Walze’ (if undefined, randomly selecte(if undefined, randomly selected)

  • tagesWalzenStellungenList – List of Tageswalzenstellungen (if undefined, all)

  • spruchScoring – ‘SpruchScoring’ (required by Gillolgy attack)

  • zusatzwalzenList – ‘Zusatzwalze’ (if undefined, randomly selected)

  • blank – replacement character for a blank

  • notify – notification function (e.g. print)

classmethod checkRejewskiCatalog(catalog: List[Tuple[MzEnigma.enigma.Tagesschluessel, List[List[str]]]], expectedSpruchschluesselLength: Optional[int] = None) None[source]

check a catalog of encoded spruchschluessels

Parameters

expectedSpruchschluesselLength – number of characters in unencoded spruchschluessel (optional)

createRejewskiCatalog(pickleFile: Optional[str] = None) List[Tuple[MzEnigma.enigma.Tagesschluessel, List[List[str]]]][source]

Build up a catalog of encoded spruchschluessels. Works only without a steckerbrett.

Parameters

pickleFile – pickle file to be created (optional)

Returns

List[Tuple[Tagesschluessel, List[List[Doublet]]]

exchangePhase2(phase1Tagesschluessel: MzEnigma.enigma.Tagesschluessel, encodedSpruch: str = '', cycles: int = 5) MzEnigma.enigma.Tagesschluessel[source]

Hill climbing based on exchange of x-connected ports of a steckerbrett

Parameters
  • phase1Tagesschluessel – tagesschluessel with correct settings for Umkehrwalze, Walzen, Zusatzwalze, and Tageswalzenstellungen(required)

  • encodedSpruch – encrypted message to be attacked (required)

  • cycles – number of exchange cycles

Returns

Tagesschlüssel

gilloglyAttackPhase1(encodedSpruch: str) MzEnigma.enigma.Tagesschluessel[source]

Brute force attack to derive settings for Umkehrwalze, Walzen, Zusatzwalze, and Tageswalzenstellungen. Uses the index of coincidence for scoring. The rate of correct Tagesschluessels increases with increasing length of the encodedSpruch.

Parameters

encodedSpruch – message to be attacked (required)

Returns

Tagesschlüssel

gilloglyAttackPhase2(phase1Tagesschluessel: MzEnigma.enigma.Tagesschluessel, encodedSpruch: str = '', noImprovement: int = 10, cycles: int = 1000, useSimulatedAnnealing: bool = False) MzEnigma.enigma.Tagesschluessel[source]

Shotgun hill climbing or simulated annealing attack to derive settings for Steckerbrett

Parameters
  • phase1Tagesschluessel – tagesschluessel with correct settings for Umkehrwalze, Walzen, Zusatzwalze, and Tageswalzenstellungen(required)

  • encodedSpruch – encrypted message to be attacked (required)

  • noImprovement – stop condition after noImprovement number of attempts in a cycle

  • cycles – number of cycles with a random steckerbrett configuration

  • useSimulatedAnnealing – use simulated annealing instead of conventional hill climbing

Returns

Tagesschlüssel

classmethod loadRejewskiCatalog(pickleFile: str) List[Tuple[MzEnigma.enigma.Tagesschluessel, List[List[str]]]][source]

Build up a catalog of encoded spruchschluessels

Returns

List[Tuple[Tagesschluessel, List[List[Doublet]]]

mzAttackPhase2(phase1Tagesschluessel: MzEnigma.enigma.Tagesschluessel, encodedSpruch: str = '') MzEnigma.enigma.Tagesschluessel[source]

Systematic hill climbing attack to derive settings for Steckerbrett Uses the ‘ngramScore’ for scoring.

Parameters
  • phase1Tagesschluessel – tagesschluessel with correct settings for Umkehrwalze, Walzen, Zusatzwalze, and Tageswalzenstellungen(required)

  • encodedSpruch – encrypted message to be attacked (required)

Returns

Tagesschlüssel

classmethod rejewskiAttack(catalog: List[Tuple[MzEnigma.enigma.Tagesschluessel, List[List[str]]]], encodedSpruchSchluessel: str) List[Tuple[MzEnigma.enigma.Tagesschluessel, str]][source]

Find candidate values for the unencoded SpruchSchluessel from a catalog

Parameters
  • catalog – catalog of encoded spruchschluessels (required)

  • encodedSpruchSchluessel – encoded spruchschluessels to be found (required)

Returns

List[Tuple[Tagesschluessel, unencodedSpruchSchluessel]]

shotgunPhase2(phase1Tagesschluessel: MzEnigma.enigma.Tagesschluessel, encodedSpruch: str = '', noImprovement: int = 10) MzEnigma.enigma.Tagesschluessel[source]

Shotgun hill climbing or simulated annealing attack to derive settings for Steckerbrett Uses the ‘newNgramScore’ for scoring.

Parameters
  • phase1Tagesschluessel – tagesschluessel with correct settings for Umkehrwalze, Walzen, Zusatzwalze, and Tageswalzenstellungen(required)

  • encodedSpruch – encrypted message to be attacked (required)

  • noImprovement – stop condition after noImprovement number of attempts in a cycle

Returns

Tagesschlüssel

turingAttack(encodedSpruch: str = '', crib: str = '', startingPosition: int = 0) List[Tuple[MzEnigma.enigma.Tagesschluessel, List[Tuple[str, str]]]][source]

Turing attack to derive candidate settings for Umkehrwalze, Walzen, Zusatzwalze, Tageswalzenstellungen and several settings of the Steckerbrett An engine with Steckerbrett is required. The rate of correct Tagesschluessels increases with increasing length of the crib.

Parameters
  • encodedSpruch – encoded message to be attacked (required)

  • crib – unencoded crib to be found in the message (required)

  • startingPosition – starting position of the crib in the message

Returns

List[Tuple[Tagesschluessel, List[Tuple[Walzenstellungen, Steckerbrett.wiring]]]]