The Obama administration told a U.S. magistrate judge on Friday it would be willing to allow Apple Inc. to retain possession of and later destroy specialized software it has been ordered to design to help the FBI hack into an encrypted iPhone used by the gunman in December's mass shootings in California.

The government made clear that it was open to less intrusive options in a new legal filing intended to blunt public criticism by Apple's chief executive, Tim Cook, who said the software would be "too dangerous to create" because it would threaten the digital privacy of millions of iPhone customers worldwide.

"Apple may maintain custody of the software, destroy it after its purpose under the order has been served, refuse to disseminate it outside of Apple and make clear to the world that it does not apply to other devices or users without lawful court orders," the Justice Department told Judge Sheri Pym. "No one outside Apple would have access to the software required by the order unless Apple itself chose to share it."

Meanwhile, the legal fight continued to reverberate on the presidential campaign trail as Republican candidate Donald Trump called on Americans to boycott Apple until it complies with the court order.

Trump made the comment during a question-and-answer session in Pawleys Island, South Carolina, where he's campaigning ahead of Saturday's first-in-the-South Republican presidential primary. Trump says Cook wants to prove "how liberal he is" and told the crowd to "boycott Apple until such time as they give up that security."

In the latest volley between the federal government and one of the world's most respected companies, the Justice Department argued that Apple has the technical ability to comply with a court order issued this week — but won't do so because of its marketing strategy.

"Apple has attempted to design and market its products to allow technology, rather than the law, to control access to data which has been found by this court to be warranted for an important investigation," the filing states.

The Justice Department's motion, which seeks to force Apple to comply with Pym's order, appears aimed at rebutting some of the key objections of Apple and its supporters. It says that the software the government seeks, contrary to Apple's assertions, is not akin to a "master key, capable of opening hundreds of millions of locks." And it also rejects the idea that the court order placed an unreasonable burden on the company, saying Apple already has the technical wherewithal to satisfy it.

"To the extent that Apple claims that the order is unreasonably burdensome because it undermines Apple's marketing strategies or because it fears criticism for providing lawful access to the government, these concerns do not establish an undue burden," the government wrote.

Apple's written objection, already signaled by Cook in a message to Apple customers, is due next Friday.

Senior Apple executives said during a phone call with reporters Friday that the company had worked for hours, even days, with federal officials and investigators to try to gain access to Farook's iPhone. The executives, who insisted on anonymity to speak freely amid ongoing legal proceedings, said they went to the FBI in early January with four suggestions, including a workaround using iCloud. Prosecutors noted the four methods and their "deficiencies" in a footnote in their Friday court filing.

The magistrate on Tuesday ordered Apple to provide the FBI with highly specialized software that could be loaded onto the work-issued iPhone 5C used by Syed Farook, who died with his wife in a gun battle with police after killing 14 people in December in San Bernardino, California. The U.S. has said the attacks were partly inspired by the Islamic State terror group.

Although the judge instructed Apple to create the software for the FBI, she said it could be loaded onto the phone at an Apple facility.

But the Justice Department made explicit Friday that Apple could retain custody of the software at all times.

The specialized software would bypass a security time delay and self-destruct feature that erases all data after 10 consecutive, unsuccessful attempts to guess the unlocking passcode. This would allow the FBI to use technology to rapidly and repeatedly test numbers in what's known as a brute force attack. In their filing Friday, prosecutors explained that investigators would be willing to work remotely to test passcodes, while Apple retained both possession of the phone and the technology itself.

That's a good "compromise position" because "they're giving all the power to Apple," said Jason Healey, a former director on cyber policy at the White House.

"They're telling Apple, 'You hold the software, we're not asking you to put a backdoor in the encryption, we just want to be able to brute force this thing,'" Healey said. "If the precedent is this, that they deliver the phone to Apple and Apple does it, I think that's a pretty good precedent that can't be done en masse on the next thousand iPhones."

The government said the county-owned phone could be valuable as evidence because Farook appeared to use the device to communicate with his wife in the months before the shootings as well as with some of his co-workers who were killed in the attacks.

Two other personal phones were found crushed beyond investigative value in the trash behind the couple's home.

The House Energy and Commerce Committee on Friday invited Cook and FBI Director James Comey to appear before it to discuss encryption technologies and issues of privacy and national security, asking both to tell Americans how they plan to move forward.

A hearing in the federal case has been set for March 22 in Riverside, California.