Mr Panetta also condemned the use of extraordinary rendition
US President Barack Obama's nominee to head the CIA, Leon Panetta, has condemned the interrogation technique "waterboarding" as "torture".
But he made it clear that agents who had carried out waterboarding in the past should not be prosecuted if they believed they were following the law.
The Bush administration approved the practice for at least three terror suspects in 2002 and 2003.
Mr Obama has banned harsh interrogation techniques, including waterboarding.
"I have expressed the opinion that I believe waterboarding is torture and that it is wrong," Mr Panetta told the Senate Intelligence Committee, which is considering his nomination.
"More importantly, the president has expressed the same," he said.
But "those individuals [who carried out waterboarding] ought not to be prosecuted or investigated if they acted pursuant to the law as presented by the attorney general," he added.
Mr Panetta also spoke about the Bush White House's "rendition" of prisoners to other countries.
He made it clear that the Obama administration would not make use of "that kind of extraordinary rendition - when we send someone for the purpose of torture or actions by another country that violate our human values".
But he drew a distinction between the "rendition" of prisoners to another government to be prosecuted by its judicial system, and the "rendition" of suspects to be interrogated by foreign governments known to practise torture.
"I think renditions where we return individuals to another country where they prosecute them under their laws, I think that is an appropriate use of rendition," he said.