The 4th Amendment to the US Constitution, part of the Bill of Rights (the first ten amendments, as a package, minus two), ratified in 1791.
Perhaps the, or a, pivotal section relies upon the word "unreasonable":
The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated...Is it unreasonable to have the government have access to data that the giant info-companies already have access to and have in fact generated and searched through themselves? It certainly seems unparalleled, and I don't for the life of me see how it is actually legal, but given that other organizations have been doing this for years for their own good I have a bit of a hard time seeing how it is unreasonable to have some other people do the exactly the same thing as others while looking for terrorists instead of for their own capital gains.
People, especially at Wired Magazine, used to love to name-drop Bentham's panopticon back in the 1990s, but that idea hasn't been used much if at all in the recent dust up. Perhaps it seemed cool until it happened.
Edit: Last week's New Yorker lead article does mention Bentham, but since I was off at ICA in London I only saw it today. The article also astutely points out how we knew the NSA was doing this for years, and knew this years ago.