A federal court is using an 18th century law to force Apple into building a back door for the FBI to assist in unlocking the encrypted data on an iPhone belonging to one of the San Bernardino shooters — an order Apple CEO Tim Cook says he will refuse.

“We have great respect for the professionals at the FBI, and we believe their intentions are good,” Apple CEO Tim Cook wrote in a letter posted late Tuesday on the iPhone maker’s website.

“Up to this point, we have done everything that is both within our power and within the law to help them. But now the U.S. government has asked us for something we simply do not have, and something we consider too dangerous to create. They have asked us to build a backdoor to the iPhone.”

United States Magistrate Judge Sheri Pym of the U.S. District Court for the Central District of California ordered Apple on Tuesday to develop a way to disable the iPhone security feature limiting a user to 10 password attempts before it erases the data on the device.

The order states Apple must only build the security workaround specifically for the iPhone 5C belonging to Syed Farook, who with his wife Tashfeen Malik shot and killed 14 people last December in San Bernardino Calif., and died in a shootout with police shortly after.

Director James Comey of the FBI told Congress last week investigators have been unable to access the iPhone of the Islamic State-inspired shooter in the months since the attack as a result end-to-end encryption built by default into Apple’s phones, which the company itself can’t access without the user’s password.

By compelling Apple to disable the limited password attempt feature, the FBI can attempt to brute-force hack the phone by trying random password combinations until they come across the correct one. The order further compels Apple to streamline this process by ensuring the FBI can submit passcode attempts electronically and preventing the phone’s software from delaying consecutive attempts “beyond what is incurred by Apple hardware.”

“Once created, the technique could be used over and over again, on any number of devices,” Cook explained. “In the physical world, it would be the equivalent of a master key, capable of opening hundreds of millions of locks — from restaurants and banks to stores and homes. No reasonable person would find that acceptable.”

Federal prosecutors said the company “has the exclusive technical means which would assist the government in completing its search, but has declined to provide that assistance voluntarily,” and that Apple must provide the FBI with “reasonable technical assistance.”

Judge Pym backed up the court’s order by citing the All Writs Act — a 1789 statute intended to fill in gaps in legal authority where no pre-existing statute applies.

Apple complied with similar FBI requests in the past under the All Writs Act, but fought the most-recent request in New York last year, where a federal magistrate judge in Brooklyn sided with the company in refusing the request and described the use of the All Writs Act as overly broad and inappropriate.

“The FBI is trying to hit the ultimate reset button on privacy, turning the clock back to a time even before the Fourth Amendment’s warrant protections,” president of TechFreedom Berin Szoka said Wednesday. “Using the All Writs Act this way would allow law enforcement to bypass all privacy safeguards. If forcing Apple to hack its own devices qualifies as ‘reasonable technical assistance,’ there is no practical limit to what law enforcement could force private companies to do to compromise the security of their systems under the Act.”

Tech and privacy groups on both sides of the aisle agreed allowing the order to go forward sets a dangerous legal precedent.

“This is an unprecedented, unwise, and unlawful move by the government,” American Civil Liberties Union staff attorney Alex Abdo said Wednesday. “The Constitution does not permit the government to force companies to hack into their customers’ devices. Apple is free to offer a phone that stores information securely, and it must remain so if consumers are to retain any control over their private data.”

“The government’s request also risks setting a dangerous precedent,” he continued. “If the FBI can force Apple to hack into its customers’ devices, then so too can every repressive regime in the rest of the world. Apple deserves praise for standing up for its right to offer secure devices to all of its customers.”

Apple has five business days to file a brief to the court explaining why complying with the order would be “unreasonably burdensome” — something Cook clearly indicated the company intends to do.

“The implications of the government’s demands are chilling,” Cook wrote. “If the government can use the All Writs Act to make it easier to unlock your iPhone, it would have the power to reach into anyone’s device to capture their data.”

Such access would include include messages, health records, financial data, location tracking, microphone and camera access, all without a user’s knowledge, according to Cook.

“Opposing this order is not something we take lightly,” the Apple CEO continued. “We feel we must speak up in the face of what we see as an overreach by the U.S. government.”

If the court upholds the order, it could signal a significant victory for law enforcement and in particular Comey, who has spent well over a year warning Congress of the dangers of terrorists and criminals “going dark” online via encrypted communications.

Follow Giuseppe on Twitter