The cloud hanging over all of this is the fact that the United States operated an illegal domestic mass surveillance system for many years, with the full knowledge of the senior politicans responsible for Intelligence oversight.
Why I disagree with nearly everyone regarding Apple and the FBI.
Tom Cross

How was it illegal? On what basis was it shown to be illegal? That someone overreaches their powers does not make it illegal. They are still acting with due authority and legitimization. During a war setting, cf AUMF, the Executive, under broad war making executive authority, essentially public safety, undertook warrantless surveillance. However, it was done under executive authority. This does not make it illegal.