The Cipher Bureau ( ) was the Second Department of Polish General Staff unit charged with SIGINT and both cryptography (the of ciphers and codes) and cryptanalysis (the of ciphers and codes, for the purpose of "breaking" them). The precursor of the agency that would become the Cipher Bureau was created in May 1919, during the Polish-Soviet War (1919–1921), and played a vital role in securing Poland's survival and victory in that war. In mid-1931, the Cipher Bureau was formed by the merger of pre-existing agencies.

In December 1932, the Bureau began breaking Germany's Enigma ciphers. Over the next seven years, Polish cryptologists overcame the growing structural and operating complexities of the plugboard-equipped Enigma. The Bureau also broke Soviet cryptography. Five weeks before the outbreak of World War II, on 25 July 1939, in Warsaw, the Polish Cipher Bureau revealed its Enigma-decryption techniques and equipment to representatives of French and British military intelligence, which had been unable to make any headway against Enigma. This Polish intelligence-and-technology transfer would give the Allies an unprecedented advantage (Ultra) in their ultimately victorious prosecution of World War II. Background

On 8 May 1919 Lt. Józef Serafin Stanslicki established a Polish Army "Cipher Section" (), precursor to the "Cipher Bureau" (). The Cipher Section reported to the Polish General Staff and contributed substantially to Poland's defense by Józef Piłsudski's forces during the Polish-Soviet War of 1919–1921, thereby helping preserve Poland's independence, recently regained in the wake of World War I. The Cipher Section's purview included both ciphers and codes. In Polish the term "cipher" () loosely refers to both these two principal categories of cryptography. (Compare the opposite practice in English, which loosely refers to both codes and ciphers as "codes".)

During the Polish–Soviet War (1919–1921), approximately a hundred Russian ciphers were broken by a sizable cadre of Polish cryptologists who included army Lieutenant Jan Kowalewski and three world-famous professors of mathematics – Stefan Mazurkiewicz, Wacław Sierpiński, and Stanisław Leśniewski. Russian army staffs were still following the same disastrously ill-disciplined signals-security procedures as had Tsarist army staffs during World War I, to the decisive advantage of their German enemy. As a result, during the Polish-Soviet War the Polish military were regularly kept informed by Russian signals stations about the movements of Russian armies and their intentions and operational orders.

The Soviet staffs, according to Polish Colonel Mieczysław Ścieżyński,

In the crucial month of August 1920 alone, Polish cryptologists decrypted 410 signals: from Soviet General Mikhail Tukhachevsky, commander of the northern front from Leon Trotsky, Soviet commissar of war from commanders of armies, for example: the commander of the , the commander of the 1st Cavalry Army, Semyon Budionny the commander of the , Gai from the staffs of the XII, XV and XVI Armies from the staffs of: the Mozyr Group (named after the Belarusian city) the Zolochiv Group (after the Ukrainian town) the Yakir Group [after General Iona Emmanuilovich Yakir] from the 2, 4, 7, 10, 11, 12, 16, 17, 18, 24, 27, 41, 44, 45, 53, 54, 58 and 60 Infantry Divisions from the 8 Cavalry Division etc.

The intercepts were as a rule decrypted the same day, or at latest the next day, and were immediately sent to the Polish General Staff's Section II (Intelligence) and operational section. The more important signals were read in their entirety by the Chief of the General Staff, and even by the Commander in Chief, Marshal Józef Piłsudski. Interception and reading of the signals provided Polish intelligence with entire Russian operational orders. The Poles were able to follow the whole operation of Budionny's Cavalry Army in the second half of August 1920 with incredible precision, just by monitoring his radiotelegraphic correspondence with Tukhachevsky, including the famous and historic conflict between the two Russian commanders.

The intercepts even included an order from Trotsky to the revolutionary council of war of the Western Front, confirming Tukhachevsky's operational orders, thus giving them the authority of the supreme chief of the Soviet armed forces. An entire operational order from Tukhachevsky to Budionny was intercepted on 19 August and read on 20 August, stating the tasks of all of Tukhachevsky's armies, of which only the essence had previously been known.

Ścieżyński surmises that the Soviets must likewise have intercepted Polish operational signals; but he doubts that this would have availed them much, since Polish cryptography "stood abreast of modern cryptography" and since only a small number of Polish higher headquarters were equipped with radio stations, of which there was a great shortage; and finally, Polish headquarters were more cautious than the Russians and almost every Polish division had the use of a land line.

Polish cryptologists enjoyed generous support under the command of Col. Tadeusz Schaetzel, chief of the Polish General Staff's Section II (Intelligence). They worked at Warsaw's radio station WAR, one of two Polish long-range radio transmitters at the time. The Polish cryptologists' work led, among many other things, to the discovery of a large gap on the Red Army's left flank, which enabled Poland's Marshal Józef Piłsudski to drive a war-winning wedge into that gap during the August 1920 Battle of Warsaw.

The discovery of the Cipher Bureau's archives, decades after the Polish-Soviet War, has borne out Ścieżyński's assertion

Cipher Bureau In mid-1931, at the Polish General Staff, a Cipher Bureau was formed by merging the Radio-Intelligence Office () and the Polish-Cryptography Office ()., note 6 The Bureau was charged with both cryptography – the generation, and supervision of the use, of ciphers and codes – and cryptology – the study of ciphers and codes, particularly for the purpose of breaking them.

Between 1932 and 1936, the Cipher Bureau took on additional responsibilities, including radio communications between military intelligence posts in Poland and abroad, as well as radio counterintelligence – mobile direction-finding and intercept stations for the locating and traffic analysis of spy and fifth column transmitters operating in Poland.

Stalking Enigma

In late 1927 or early 1928, there arrived at the Warsaw Customs Office from Germany a package that, according to the accompanying declaration, was supposed to contain radio equipment. The German firm's representative strenuously demanded that the package be returned to Germany even before going through customs, as it had been shipped with other equipment by mistake. His insistent demands alerted the customs officials, who notified the Polish General Staff's Cipher Bureau, which took a keen interest in new developments in radio technology. Since it happened to be a Saturday afternoon, the Bureau's experts had ample time to look into the matter. They carefully opened the box and found that it did not, in fact, contain radio equipment but a cipher machine. They examined the machine minutely, then put it back into the box.

The Bureau's leading Enigma cryptanalyst Marian Rejewski commented that the cipher machine may be surmised to have been a commercial-model Enigma since at that time the military model had not yet been devised. "Hence this trivial episode was of no practical importance, though it does fix the date at which the Cipher Bureau's interest in the Enigma machine began"manifested, initially, in the entirely legal acquisition of a single commercial-model Enigma.

On 15 July 1928, the first German machine-enciphered messages were broadcast by German military radio stations. Polish monitoring stations began intercepting them, and cryptologists in the Polish Cipher Bureau's German section were instructed to try to read them. The effort was fruitless, however, and was eventually abandoned. There remained very slight evidence of the effort, in the form of a few densely written-over sheets of paper and the commercial-model Enigma machine. On 15 January 1929 Major Gwido Langer, after a tour of duty as chief of staff of the 1st Legion Infantry Division, became chief of the Radio-Intelligence Office, and subsequently of the Cipher Bureau. The Bureau's deputy chief, and the chief of its German section (BS-4), was Captain Maksymilian Ciężki.

In 1929, while the Cipher Bureau's predecessor agency was still headed by Major Franciszek Pokorny (a relative of the outstanding World War I Austro-Hungarian Army cryptologist, Captain Herman Pokorny), Ciężki, Franciszek Pokorny, and a civilian Bureau associate, Antoni Palluth, taught a secret cryptology course at Poznań University for selected mathematics students. Over ten years later, during World War II while in France, one of the students, Marian Rejewski, would discover that the entire course had been taught from French General Marcel Givièrge's book, (Course of Cryptography), published in 1925.

In September 1932, Maksymilian Ciężki hired three young graduates of the Poznań course to be Bureau staff members: Marian Rejewski, Jerzy Różycki and Henryk Zygalski.

Successes and setbacks In 1926, the German Navy adopted, as its top cryptographic device, a modified civilian Enigma machine; in 1928 the German Army followed suit. The complexity of the system was much increased in 1930 by the introduction of a plugboard (), albeit with only six connecting leads in use. In December 1932, Marian Rejewski made what historian David Kahn describes as one of the greatest advances in cryptologic history, by applying pure mathematicsthe theory of permutations and groupsto breaking the German armed forces' Enigma machine ciphers. Rejewski had worked out the precise interconnections of the Enigma rotors and reflector, after the Bureau had received, from French Military Intelligence Captain Gustave Bertrand, two German documents and two pages of Enigma daily keys (for September and October of that year). These had been obtained by a French military intelligence agent, a German codenamed Rex, from an agent who worked at Germany's Cipher Office in Berlin, Hans-Thilo Schmidt, whom the French codenamed .

After Rejewski had worked out the military Enigma's logical structure, the Polish Cipher Bureau commissioned the AVA Radio Company, co-owned by Antoni Palluth, to build replicas ("doubles") of the Enigma to Rejewski's specifications. His method of decrypting Enigma messages exploited two weaknesses of the German operating procedures. It used what Rejewski called "characteristics" that were independent of the plugboard connections. This involved compiling a card catalog of certain features of the set of indicator settings.There were 26 × 26 × 26 = 17,576 possible rotor positions for each of the six rotor orders, giving a total of 105,456 possible indicators.

The Germans increased the difficulty of decrypting Enigma messages by decreasing the interval between changes in the order of the rotors from quarterly, initially, to monthly in February 1936, then daily in October of that year, when they also increased the number of plugboard leads from six to a number that varied between five and eight. This made the Biuro's grill method much less easy, citing as it relied on 'unsteckered' letter pairs. The German navy was more security-conscious than the army and air force, and in May 1937 it introduced a new, much more secure, indicator procedure that remained unbroken for several years.