The CIA secretly owned a company that sold rigged encryption systems to other countries, allowing the agency to spy on more than 100 nations over several decades while generating millions in profit.

The agency’s relationship with the company, Crypto AG, was detailed by the Washington Post in an investigation published Tuesday.

Crypto was the dominant maker of encryption devices for decades, selling the equipment to Iran, India, Egypt, Italy, and dozens of other nations. None of the countries who bought the equipment knew it was owned by the CIA in a secret partnership with West German intelligence. The spy agencies rigged the devices so they could break the codes the countries used to send encrypted messages.

“It was the intelligence coup of the century,” a classified CIA report on the decadeslong operation concluded. “Foreign governments were paying good money to the U.S. and West Germany for the privilege of having their most secret communications read by at least two (and possibly as many as five or six) foreign countries.”

Through the devices, the United States was able to spy on Iran during the 1979 hostage crisis and implicated Libya in the 1986 bombing of a West Berlin disco that was popular with American troops.

The CIA and the National Security Agency controlled nearly every aspect of Crypto’s operations since 1970, including hiring decisions and directing to which countries the equipment would be sold.

Before the CIA owned the firm, it made a deal with Crypto’s founder Boris Hagelin in 1951 to restrict sales of his most sophisticated machines to countries approved by the U.S. Nations not on the list were sold older, more vulnerable systems. By 1967, the company was producing models whose inner workings were entirely designed by the NSA.

Around the same time, the French, West German, and other European intelligence services became aware of America's arrangement with Crypto. The French intelligence service made Hagelin an offer, which he reported to his CIA handlers. A couple of years later, German intelligence made a bid on the company with the blessing of the U.S. The Germans then asked the Americans to become partners in the deal.

The German intelligence agency left the partnership in the early 1990s, after years of disagreements over money and the Americans’ willingness to spy on some of its allies. The CIA then bought the Germans' stake and used it until 2018, when the agency sold off the company’s assets. It’s not known how much the CIA made off the sale, but current and former officials estimated its worth to be between $50 million and $70 million.