By Daniel Trotta

UNITED NATIONS, Sept 24 (Reuters) - Brazilian President Dilma Rousseff on Tuesday criticized the United States for spying, using the opening speech at the U.N. General Assembly to announce Brazil would adopt legislation and technology to protect it from illegal interception of communications.

Rousseff last week called off a high-profile state visit to the United States scheduled for October over reports that the U.S. National Security Agency had been spying on Brazil and Rousseff's email.

After opening with diplomatic pleasantries and a condemnation of the shopping mall attack in Kenya, Rousseff launched into a blistering attack on U.S. spying, calling espionage among friendly nations "totally unacceptable."

"Meddling in such a manner in the lives and affairs of other countries is a breach of international law and, as such, it is an affront to the principles that should otherwise govern relations among countries, especially among friendly nations," Rousseff told the annual gathering of world leaders at the United Nations.