James Bond, the protagonist of Ian Fleming's popular series of novels and the movies based on them, was number 007 in the British secret service. As was explained in the first book, the 00 number meant that he was licensed to kill. So far as I can remember—I read the books a long time ago—it was never explained exactly what were the limits of the license or under what legal theory it was granted.
I do not think it was ever suggested that he was only allowed to kill in self-defense since that, after all, requires no special number. He clearly did not have the hangman's job of executing people who had been convicted of a capital offense. He was not a soldier in a declared war. Off hand, those are the only contexts I can think of in which deliberately killing another human being is legal under the Anglo-American legal system. Which suggests that what Bond had was a license to break the law.
Defenders of the NSA argue that everything it does, with the exception of occasional mistakes, is legal under their interpretation of the relevant law. None of them, so far as I know, have argued that the NSA is entitled to break the law. On the other hand, I have seen no arguments claiming that the Patriot act entitled government officials to lie to Congress under oath, as the Director of National Intelligence has admitted doing. Yet the only calls I have seen for indicting him for perjury have been from people already critical of the NSA. From which I conclude that the defenders of the NSA, from Obama on down, really do believe that government security agents are entitled to break the law without the usual consequences, however unwilling they may be to say so.
As it happens, the same issue comes up in my novel Salamander, although not in our world. The speaker is Prince Kieron, brother and heir of the king and royal official in charge of dealing with magery:
The King is not above the law. Nonetheless, I will not promise never to violate bounds or law myself, nor will I promise to instruct my servants never to do so. Law-breaking is a bad thing, whether by the King's servants or anyone else, but there are worse things, some of which it is my responsibility to deal with. I will promise not to violate bounds or law save in the most extreme circumstances, and to do my best to see that my servants will not, so that incidents such as the two you have described do not occur again. If my people are charged, as Fieras was, I will do my best to see that they get an honest trial.
The claim that the end does not justify the means cannot be true in general—with enough at stake, all of us are willing to do things we would normally disapprove of. Kieron is not a villain. He is an intelligent, well intentioned, and reasonably honest man trying to deal with what he correctly sees as a terrible threat. Insofar as he is making a mistake, it is not bad moral reasoning. It is being too confident that his judgement is correct, hence that he is entitled, if necessary, to overrule by force or fraud the opinions of other intelligent and well intentioned people who disagree with him.
Similarly in our world. It is easy enough to come up with hypothetical situations in which an NSA agent is morally justified in tapping a phone without a warrant or a high up intelligence official in lying to Congress. It is much harder to come up with a plausible reason to believe that the willingness of agents or officials to break the law whenever they think doing so is in the national interest is, on net, a good thing.