Two newly revealed legal memos from the Bush administration cite war with al Qaeda as the legal justification for the NSA's “Stellar Wind” program. The massive secret surveillance program allowed for warrantless wiretapping and the collection of email metadata, including the “to” and “from” fields, reports the Washington Post.

Stellar Wind was authorized after the Sept. 11, 2001, attacks, and Jack Goldsmith, then assistant attorney general and in charge of President George W. Bush’s Office of Legal Counsel, wrote two legal memos justifying the program.

The National Security Agency’s illicit surveillance program was first revealed by the New York Times in 2005, thanks to a tip from an anonymous source later identified as Thomas M. Tamm, and Stellar Wind authorized the collection of telephone calls, Internet content, telephone metadata and Internet metadata, reports Ars Technica. The collection of Internet metadata was revealed by NSA whistleblower Edward Snowden in 2013.

Snowden provided the Guardian and the Washington Post with a draft report from the Office of the Inspector General which described the Stellar Wind operation. 

“For the foregoing reasons, we conclude that, notwithstanding the prohibitions of FISA [Foreign Intelligence Surveillance Act] and Title 18, under the current circumstances of the ongoing armed conflict with al Qaeda and in light of the broad authority conferred in the Congressional Authorization [for the use of force against al Qaeda], the President, as Commander in Chief and Chief Executive, has legal authority to authorize the NSA to conduct the signals-intelligence activities described above; that the activities, to the extent they are searches subject to the Fourth Amendment, comport with the requirements of the Fourth Amendment; and thus that the operation of the STELLAR WIND program as described above is lawful,” reads Goldsmith’s conclusion on the May 6, 2004 memo.

Goldsmith's memo from July 16, 2004, examined the effect of the Supreme Court case of Hamdi v. Rumsfeld, which approved of the detention of enemy combatants. Goldsmith argued the Supreme Court decision was more proof that Stellar Wind was legal.

Goldsmith later deemed parts of Stellar Wind illegal, most notably the collection of email metadata. When it came time to reauthorize the email surveillance in 2004, then-Acting Attorney General James Comey, serving for Attorney General John Ashcroft while he was hospitalized, refused to approve the email surveillance. That decision led to the infamous scene of White House Counsel Alberto Gonzales visiting Ashcroft in the hospital in an attempt to overturn Comey's decision, notes the Washington Post. The reauthorization of the email metadata collection almost led to the resignation of Comey, Ashcroft and then-FBI Director Robert Mueller, notes Ars Technica.

Gonzales later succeeded Ashcroft as attorney general. Comey is now director of the FBI.

The legal memos were obtained by the American Civil Liberties Union under the Freedom of Information Act lawsuit.