JOHANNESBURG (AP) — The White House says today's handshake between President Barack Obama and Cuban leader Raul Castro wasn't planned in advance.

Obama shook hands with Castro and other world leaders as he made his way to the podium to speak at today's memorial service for Nelson Mandela in South Africa.

A spokesman says it was simply an exchange of greetings. It comes as the U.S. and Cuba have recently taken small steps toward political reconciliation.

Despite today's handshake, Obama still offered an implicit criticism of governments like Cuba's in his remarks moments later, when he said too many people embrace Mandela's legacy of racial reconciliation but passionately resist economic and other reforms.

He said, "There are too many people who claim solidarity" with the struggles of Mandela, but "do not tolerate dissent from their own people."

More than a half-century after the U.S. cut off diplomatic relations with Cuba, any contact between American and Cuban leaders are exceedingly rare. U.S. officials have often gone to great lengths to avoid having presidents meet Cuban leaders, even in passing.

Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.