U.S. court: Mass surveillance program exposed by Snowden was illegal