Karen K. Johnson, the convicted cocaine dealer sentenced to a jail term that prosecutors hoped would force her to give evidence against Mayor Marion Barry, has frustrated federal investigators by spending the last four months reading in her cell and refusing to talk.

"She's as solid as a rock," said a source who regularly sees Johnson, a former D.C. government employe who was jailed in August for up to 18 months when she refused to testify before a federal grand jury investigating drug use by city workers and others. "She's not breaking."

Federal prosecutors considered Johnson's cooperation crucial to their effort to determine whether Barry committed perjury last January when he appeared before the grand jury and denied ever having obtained cocaine from her.

A high-ranking Barry aide said this week that the investigation is going nowhere, despite an all-out effort to find other witnesses. The aide said he no longer believes the mayor is in jeopardy.

"I think this thing has petered out," the aide said.

The drug case, which caused a major political uproar last summer and raised doubts about the mayor's future, appears to be reaching a crucial juncture.

The term of the grand jury investigating the Johnson drug case will expire in March, and at that point U.S. Attorney Joseph E. diGenova must decide whether to extend the life of the panel or continue the investigation with a new grand jury.

If diGenova decides to end the investigation, Johnson would be released from her contempt sentence. At that point, she would be transferred back to a minimum-security federal corrections center in Southeast Washington to resume a four-month sentence for the cocaine convictions. She had served only two days of that sentence before she was held in contempt.

Questions were raised about Barry more than a year ago when Johnson told a government informant in a secretly taped conversation that she had sold cocaine to Barry on numerous occasions.

Barry has steadfastly denied any drug use and has said prosecutors have told him he is not a target of the grand jury investigation. Barry's attorney did acknowledge that the mayor had a "personal relationship" with Johnson.

After Johnson was jailed for refusing to testify, prosecutors stepped up the investigation and four U.S. Drug Enforcement Administration agents were assigned to the case. Prosecutors also expanded their inquiries into areas that went beyond the specifics of the Johnson case.

However, sources familiar with the overall investigation said that despite these efforts, prosecutors have not turned up credible evidence to substantiate allegations against Barry.

DiGenova has declined to comment publicly on the investigation or to say what his timetable is for resolving the matter. Sources said that if the investigation results in no charges being filed, diGenova may issue a report on the case.

Barry appears confident that he has defused the investigation as a political issue and has kept diGenova on the defensive by criticizing his office for allegedly leaking information about the investigation.

The mayor said before leaving on his current trip to Africa that he had not been damaged by the leaks and that he is in "good shape politically."

"If something comes out of those investigations, they aren't going to damage me in the sense of making it impossible for me to decide whether I'm going to run [for reelection] in '86," Barry said. "I'm not going to be run out of office by any of this."

Following a late-August front-page story in The New York Times that quoted "federal law enforcment officials" as saying the grand jury was investigating Barry for possible perjury, the mayor charged that the Reagan administration was trying to embarrass him with "a leak a week" of unsubstantiated allegations.

Herbert O. Reid, legal counsel to the mayor, and City Council Chairman David A. Clarke both asked U.S. Attorney General William French Smith to appoint a special prosecutor to investigate the leaks.

The Justice Department has acknowledged receipt of the letters but has not said what, if anything, it intends to do about the requests. Reid said this week he does not intend to pursue the matter further, in light of the dearth of reports about the investigation since he first lodged a complaint.

"The leaks have stopped," Reid said. "There is nothing to be served [in pursuing the request for an investigation] beyond that. The leaking has stopped."

Barry aides have suggested that the reason Johnson refused to testify was not to protect the mayor -- who has said his relationship with her was "never much of one" -- but because she feared reprisals from her drug suppliers whose identities prosecutors might be seeking.

A source close to Johnson said she believed she had no choice but to keep quiet and go to jail. Johnson deemed unacceptable any cooperation that would require her to rely on government protection, which often involves assuming a new identity and moving to a distant city, according to the source, who asked not to be identified.

"After you say whatever it is they want you to say, you have no control over your life," the source said, adding that Johnson would not want to give up contact with her family and friends.

Johnson initially was lodged in the infirmary of the jail, away from the rest of the inmates, because she feared for her safety, according to D.C. corrections officials.

At her own request, Johnson last month was moved to a cell in the jail's southeast wing, which primarily houses women prisoners convicted of crimes and serving their sentences, according to Marion D. Strickland, the D.C. Corrections official in charge of the jail.

Johnson now has more freedom of movement, according to Strickland. She can mingle with other prisoners and visit recreation areas, which have televisions and card tables.

Strickland said that chronic jail crowding has forced Johnson to share a one-person cell with another woman inmate.

Strickland declined to provide the names of persons who have visited Johnson, although it is know that her most frequent visitor is a brother who serves as her chief link to the outside and who has helped care for her small child.

Her plans are uncertain, but for now life in the jail is spent "pretty much to herself," according to a source, who regularly sees Johnson. She has a newspaper sent to her every day, the source said, and spends hours reading novels, including "Flowers in the Attic," "Petals on the Wind" and "Hollywood Wives."