The next frontier in the battle between the FBI and technology companies over encrypted communications will be more legally complicated—and messy—than trying to get into the iPhone of a dead terrorist.

Messaging tools like Facebook's WhatsApp and Internet services that automatically encrypt the content of texts, phone calls and other data while they're being sent are increasingly becoming a problem for national security and criminal investigations, according to the Federal Bureau of Investigation.

While the FBI says it’s essential to capture that data while it is in transit, privacy advocates urge restraint and technology companies say it isn’t even technically feasible to do so.

Although the FBI was able to obtain data on two high-profile cases involving data on locked iPhones, law enforcement agencies struggle with the legal challenges of compelling companies to provide access to encrypted communications especially in terms of dealing with laws written more than 20 years ago when the Internet was just emerging.

"This is the new frontier and it is a much more expansive frontier in terms of its effect on law enforcement investigations," said Edward McAndrew, a former federal prosecutor who's now a partner with the law firm Ballard Spahr.

Although the FBI and other law enforcement agencies can seek court orders compelling companies to comply with wiretap orders, they are hampered by rapid advances in technology and laws such as the 1994 Communications Assistance for Law Enforcement Act that limit their reach in investigations.

"As you see WhatsApp, Viber and others moving to what they're calling end-to-end encryption for messaging, that all but guarantees the government, at least through its criminal investigative authorities, would not be able to intercept that content," said McAndrew.

McAndrew said the best solution would be for Congress to update laws governing wiretaps and access to data.