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.

U.S. President Barack Obama was en route to the United Nations while Rousseff spoke. He then followed Rousseff on the podium as the first and second national leaders to address the General Assembly.

Postponing the state visit, which as to have included a dinner at the White House, was a rare and diplomatically severe snub by Brazil. No new date has been set.

The report by Brazil Globo's news program Fantastico on National Security Agency spying was based on documents that journalist Glenn Greenwald obtained from former NSA contractor Edward Snowden. Greenwald, who lives in Rio de Janeiro, was one of the journalists to first report Snowden's leaks of classified information on previously secret U.S. telephone and internet surveillance efforts.

Rousseff's state visit was conceived to highlight cooperation between the two biggest economies in the Americas and Brazil's emergence over the past decade as a regional power.

Rousseff said Brazil will adopt legislation and technology to protect it from illegal interception of communications.