Midway through the trial of former CIA officer Jeffrey Sterling, one comment stands out. “A criminal case,” defense attorney Edward MacMahon told the jury at the outset, “is not a place where the CIA goes to get its reputation back.” But that’s where the CIA went with this trial in its first week — sending to the witness stand a procession of officials who attested to the agency’s virtues and fervently decried anyone who might provide a journalist with classified information.

The CIA’s reputation certainly needs a lift. It has rolled downhill at an accelerating pace in the dozen years since telling President George W. Bush what he wanted the nation to hear about Iraqi weapons of mass destruction. That huge bloody blot on the agency’s record has not healed since then, inflamed by such matters as drone strikes, rendition of prisoners to torture-happy regimes and resolute protection of its own torturers.

CIA sensibilities about absolution and prosecution are reflected in the fact that a former head of the CIA’s clandestine service, Jose Rodriguez Jr., suffered no penalty for destroying numerous videotapes of torture interrogations by the agency — which knew from the start that the torture was illegal.

But in the courtroom, day after day, with patriotic piety, CIA witnesses — most of them screened from public view to keep their identities secret — have testified to their reverence for legality.

In the process, the CIA is airing soiled threads of its dirty laundry as never before in open court. The agency seems virtually obsessed with trying to refute the negative portrayal of Operation Merlin — the CIA’s effort 15 years ago to provide a flawed nuclear weapon design to Iran — in James Risen’s 2006 book State of War.

To underscore the importance of blocking the information about Operation Merlin that eventually surfaced in the book, Rice testified that — in her role as national security adviser in 2003 — she consulted with President Bush and got his approval before meeting with representatives of the New York Times. Rice succeeded in persuading the newspaper hierarchy not to publish the story. (Revealing CIA memos about the agency’s maneuvers to pressure the Times are posted as trial exhibits.)

The star witness at the end of last week, identified as “Mr. Merlin,” was the CIA-asset Russian scientist who delivered diagram material for a nuclear weapon component to an Iranian office in Vienna in 2000. Like the CIA officers who testified, he voiced pride in Operation Merlin — at one point even seeming to assert that it had prevented Iran from developing a nuclear bomb. (That was an especially bizarre claim. Mr. Merlin himself admitted that his efforts never got any response from Tehran, and there is no evidence the operation had any nonproliferation effect.)

Contrary to the narrative in State of War — which portrays him as very skeptical of the operation and reluctant to participate — Mr. Merlin’s testimony via video aimed to present himself as resolute about executing the plan: “I knew I needed to do my job. . . . I had no doubts.”

When the prosecutor asked whether it took a lot of persuading to get him to participate in the operation, Mr. Merlin responded with sudden vehemence: “It was not a rogue operation. It was a brilliant operation.” (The chapter in Risen’s book detailing Operation Merlin is titled “A Rogue Operation.”)

The prosecutor probably liked the answer — except for the obvious fact that it was not responsive to his question. So he tried again, inquiring whether it took a lot of persuasion from the CIA case officer to go through with his assigned mission to Vienna. The query was an evident prompt for a “No” answer. But Mr. Merlin replied: “I don’t know.”

The prosecutor tried again, asking whether he had been reluctant to agree to go ahead with the task.

At first there was no answer, just conspicuous silence. Then: “I don’t know.” Then: “I didn’t have any doubts. I didn’t hesitate.”

All this is potentially important to the case, since the government is asserting that Risen’s book is inaccurate — that Operation Merlin was actually near flawless and that Sterling invented concerns and a narrative that unfairly characterized it.

Everyone agrees that Sterling went through proper channels to share his concerns and classified information with Senate Intelligence Committee staff in early March 2003. But the prosecution, armed with a 10-count felony indictment, alleges that he also went to Risen and disclosed classified information. Sterling says he’s innocent on all counts.

The government hadn’t wanted Mr. Merlin to testify, contending that he was too ill (with kidney cancer), but US District Court Judge Leonie Brinkema ruled for a video deposition. That turned out to be unfortunate for the prosecutors, since Merlin became foggy and evasive under cross-examination, with increasing frequency of replies like “I can’t recall” and “I don’t remember.” Dense fog of his own making eclipsed Mr. Merlin as a star witness for the government.

To close out the trial’s first week, before a three-day weekend, the government called more CIA witnesses to the stand. They hammered at the vital need for scrupulous rectitude from CIA officers to obey the law and regulations in handling classified materials. As you might imagine, none had anything to say about disapproval of violating laws against torture or destroying evidence of torture. Nor did any allude to realities of extremely selective prosecution for leaks, with top US government officials and the CIA press office routinely funneling classified information to favorite journalists.

But high-ranking officials and PR operatives are not the only CIA employees apt to elude intense scrutiny for possibly leaking to the press. Judging from testimony at the trial, the harshest investigative spotlight shines on those seen as malcontents. The head of the CIA press office, William Harlow, indicated that Sterling (who is African American) became a quick suspect in the Operation Merlin leak case because he’d previously filed a suit charging the agency with racial bias.

Sterling’s other transgressions against a de facto code of silence included his visit to Capitol Hill when he spilled classified beans to Senate oversight committee staffers.

In the courtroom, during the trial’s first week, I often sat near retired CIA analyst Ray McGovern, who chaired the National Intelligence Estimates in the 1980s and prepared the CIA’s daily briefs for presidents from John Kennedy to George H.W. Bush. I wondered what McGovern was making of the spectacle; I found out when he wrote that “the real subtext of the Sterling case is how the politicization of the CIA’s analytical division over the past several decades has contributed to multiple intelligence failures, especially efforts to ‘prove’ that targeted regimes in the Middle East were amassing weapons of mass destruction.”

There’s no telling whether members of the jury will grasp this “real subtext.” Judge Brinkema seems determined to exclude anything more than faint wisps of such context. Overall, an elastic sense of scope is prevailing from the bench, to the benefit of the government.

“In the Sterling case, federal prosecutors seem to want to have it both ways,” McGovern observed. “They want to broaden the case to burnish the CIA’s reputation regarding its covert-op skills but then to narrow the case if defense attorneys try to show the jury the broader context in which the ‘Merlin’ disclosures were made in 2006 — how President George W. Bush’s administration was trying to build a case for war with Iran over its nuclear program much as it did over Iraq’s non-existent WMDs in 2002-2003.”

Along the way, the CIA is eager to use the trial as much as possible for image damage control, trying to ascend high ground that has eroded in part due to high-quality journalistic accounts of the sort that Risen provided in his State of Warreporting on Operation Merlin.

And the CIA wants a very harsh prison sentence to serve as a warning to others.

The CIA is on a quest for more respect — from news media, from lawmakers, from potential recruits — from anyone willing to defer to its authority, no matter how legally hypocritical or morally absent. Demolishing the life of Jeffrey Sterling is just another means to that end.