As the encryption debate rages on -- with Apple at the center of it all -- CEO Tim Cook says he feels like he's in a nightmare.

"The government should always be the one defending civil liberties. And there's a role reversal here," Cook told Time in a new interview published Thursday. "I mean I still feel like I'm in another world a bit, that I'm in this bad dream in some [ways]."

Cook spoke candidly about his feelings throughout the lengthy interview, which covered nearly every aspect of the debate.

He expressed frustration over the way the FBI and Justice Department have handled the case. He hammered away at the All Writs Act which is at the heart of the government's argument. And he repeatedly warned about a bad precedent that the outcome would set -- not only for technology companies, but also for individuals' rights.

"I'm seeing the government apparatus in a way I've never seen it before," he said. "Do I like finding out from the press about it? No. I don't think it's professional...do I like them talking about, or lying, about our intentions? No. I'm offended by it. Deeply offended by it."

In an emailed statement, a Department of Justice spokeswoman reiterated the government's arguments from an earlier legal filing.

"Apple's rhetoric is not only false, but also corrosive to the very institutions that are best able to safeguard our liberty and our rights," the statement reads.

Related -- Apple gets final word in encryption fight: The government just doesn't get it

Many law enforcement officials argue that encryption technology helps terrorists and criminals "go dark" -- masking their digital activities and making them difficult to find. Cook shot back.

"This is a crock. No one's going dark," he said.

Cook pointed to the growing amount of data that people leave behind when using the Web or smartphones. Information about individuals is "everywhere," he argued.

Going even further, Cook compared encryption to the essentials of life -- to the sun, air, and water.

"(W)e think the government should be pushing for more encryption," said Cook. "Security isn't just a feature, it's a base, it's a fundamental right."

By comparison, he said creating back doors is fundamentally wrong. It would be bad for national security because it would expose 99% of good people, he said.

Related -- Apple vs. the FBI ... in 2 minutes

Despite the thorny position that Cook finds himself in, he said he was optimistic the public debate and legal case will conclude with "sanity" -- and Apple's argument -- as the winners.

But ultimately, if the courts decide to rule in favor of the Justice Department or if congress and executive branch pass laws to curb encryption, he and Apple (AAPL) will abide by due process.

"(A)t the end of the day I'll follow the law," said Cook.