Apple, which is fighting an order to help hack the phone of a shooter in the deadly terror attack in San Bernardino, Calif, is reportedly working on an unhackable iPhone.

Citing people close to the company and security experts, the New York Times reports that Apple engineers are developing new security measures that would make it impossible for the government to break into a locked iPhone using methods like those at the center of the current court battle.

A senior executive, speaking on condition of anonymity, told the New York Times that Apple had started work on the security upgrade before the San Bernardino attack.

Related: Apple CEO defends position in encryption dispute with feds

Apple is resisting a judge’s order directing the tech giant to override security features on the iPhone used by one of the San Bernardino gunmen who killed 14 people in the December terror attack. The order requires Apple to supply highly specialized software the FBI can load onto the county-owned work iPhone to bypass a self-destruct feature, which erases the phone's data after too many unsuccessful attempts to unlock it.

Federal authorities have insisted they’re only asking for narrow assistance in bypassing some security features on the iPhone, which they believe contains information related to the mass murders. Apple argues that doing so would make other iPhones more susceptible to hacking by authorities or criminals in the future.

Related: How much do Americans really value their online privacy?

The New York Times reports that if Apple succeeds in upgrading its security, which experts say is likely, the company will create a long-running technical headache for law enforcement, even if the Obama administration wins the fight over the San Bernardino shooter’s iPhone. The report suggests that if the FBI wanted to access other iPhones in the future, Apple would need to create more so-called “backdoors” into its iOS software, fuelling more legal battles.

In an interview with ABC News on Wednesday Apple CEO Tim Cook defended the iPhone maker’s position in its encryption dispute with the feds. In his first interview since the controversy erupted last week, Cook said that if his company complied with the FBI’s demand to unlock Syed Rizwan Farook’s encrypted phone it would be “bad for America.”

"Some things are hard and some things are right, and some things are both. This is one of those things," Cook said. The interview came as both sides in the dispute are courting public support, through interviews and published statements, while also mustering legal arguments in the case.

Related: Why Apple's security battle with the FBI is a PR masterstroke

Suni Munshani, CEO of data security specialist Protegrity, told FoxNews.com that he expects Apple to tighten its iPhone security. “Given how seriously Apple has taken the privacy concerns of its customers in recent years, I have no doubt they will be able to make it more difficult for anyone – governments and criminals alike – to gain access to data stored on Apple devices,” he explained, via email.

Rob Enderle, principal analyst at tech research firm Enderle Group, cited speculation that Apple could improve the iPhone’s biometric security and also make the “self-destruct” feature part of the device’s hardware, as opposed to software. “That way it reduces the chances of a false negative and it will be virtually impossible for even Apple to break into the phone,” he told FoxNews.com, via email. “I also expect they will explore letting companies host their own Apple communications servers like Blackberry does with BES and BBM so rather than coming to them with requests law enforcement will go to the companies or organizations who own the phones.”

Munshani adds that Apple may eventually have to disable, or give device owners the option of disabling, the capability that the tech giant currently has to update system software without needing the device owner to enter a password. “That way Apple customers can decide for themselves the tradeoff between convenience and privacy,” he noted.

Related: Microsoft founder Gates backs FBI in encryption fight with Apple

Attorney General Loretta Lynch on Wednesday defended the FBI’s push to access the locked and encrypted iPhone, saying judges at all levels have held such companies “must assist if it is reasonably within their power to do so.” Lynch also suggested Congress does not need to get involved as Apple wants. 

Last week Republican presidential hopeful Donald Trump jumped into the iPhone security row, calling for a boycott of Apple products until the tech giant complies with the judge’s order.

Apple has not yet responded to a request for comment on this story from FoxNews.com.

The Associated Press contributed to this report.

Follow James Rogers on Twitter @jamesjrogers