Protesters demonstrate outside FBI headquarters in support of Apple in an encryption dispute, Feb. 23, 2016, in Washington, D.C. Chip Somodevilla/Getty Images

Apple shot back at the Department of Justice on Tuesday in its battle to defend its encryption technology, arguing that the government is attempting to “rewrite history” by treating the centuries-old All Writs Act as an “all-powerful magic wand” to use as it wishes.

It argued that the FBI is asking the court to do something that even the government can’t agree on — whether encryption should be weakened for backdoor purposes. Defense Secretary Ashton Carter and former National Security Agency and CIA Director Michael Hayden were among the security and intelligence officials cited by the company as in support of strong encryption.

“America is more secure — America is more safe — with unbreakable end-to-end encryption,” Hayden said in February.

The arguments are part of a 26-page brief Apple filed in District Court in response to the FBI on Tuesday, reiterating its argument that the agency and court had no authority to compel Apple to develop software to unlock the iPhone used by one of the San Bernardino, California, killers, Syed Rizwan Farook, and that granting the order would set “unprecedented and offensive burdens” on the company.

“The government seeks an order here that is neither grounded in the common law nor authorized by statute,” wrote Apple’s lawyers. “Indeed, the government has not pointed to any writ available at common law that would require a private non-party to perform burdensome forensics work, create new software, or compel speech to assist law enforcement.”

While Apple argued that the FBI had no right to compel the iPhone maker to create backdoor software it doesn’t have under the All Writs Act, the DOJ on Thursday maintained that its request was “not unreasonable” for the iPhone maker to comply with. In its filing, it accused Apple of falsely framing the court order as one that could eventually “lead to a police state.”

As an alternative, the Justice Department noted that if it doesn’t get its way with the backdoor order, it may instead try to demand Apple hand over its source code and electronic signature. “The government did not seek to compel Apple to turn [its source code and electronic signature] over because it believed such a request would be less palatable to Apple,” DOJ lawyers wrote in the footnotes of its filing. “If Apple would prefer that course, however, that may provide an alternative that requires less labor by Apple programmers.”

Observers have called that threat, embedded in the government’s filing, as a “nuclear option” and Apple played it up as an example of overreach.

“The government also implicitly threatens that if Apple does not acquiesce, the government will seek to compel Apple to turn over its source code and private electronic signature,” Apple lawyers wrote. “The catastrophic security implications of that threat only highlight the government’s fundamental misunderstanding or reckless disregard of the technology at issue and the security risks implicated by its suggestion.”

The document is expected to be one of the last filings submitted in California by Apple in its first rounds of battle against the U.S. government over encryption. The fight first came to the public’s attention on Feb. 16, when Apple CEO Tim Cook opposed the court order granting the FBI’s request to force Apple to unlock Farook’s iPhone 5C.

Since then, tech companies such as Google, Facebook, Amazon and Microsoft have voiced support for Apple’s defense in amicus briefs filed to the court. Law enforcement groups such as the California State Sheriffs Association and California Police Chiefs Association filed similar briefs in support of the FBI order.

Apple vs FBI Encryption Debate | Graphiq

With Apple’s counter-response filed with the court, both parties are expected to meet in court in Riverside, California, on March 22. Apple and the Justice Department will make their oral arguments for and against the court order. U.S. Magistrate Judge Sheri Pym is then expected to make a decision on the first order after hearing their arguments. However it plays out, the losing party is expected to appeal the ruling in higher court.

Apple and the FBI are simultaneously fighting a similar battle in New York, where a federal court decided to not issue an iPhone unlocking order through the All Writs Act, a verdict that the Justice Department has appealed. Had the order been approved, it would have compelled Apple to create a backdoor into an iPhone associated with Jun Feng, who was convicted of drug trafficking in 2015. While the initial verdict was also submitted in support of Apple’s California appeal, Pym is not obliged to issue a similar ruling. Apple is scheduled to submit its reply no later than March 24. But if the court grants the iPhone maker’s request for a one-week extension, its response to the FBI’s appeal in the New York case may arrive in court on March 31.

Read the full filing below:

Apple Counter-Response To Justice Department