WASHINGTON - Federal and local authorities have found that the man charged in the shooting deaths of nine black people in a South Carolina church last month had been in contact with white supremacists online, although it does not appear that they encouraged him to carry out the massacre, according to law enforcement officials.

Investigators uncovered that information as they have pieced together where the gunman, Dylann Roof, 21, received his inspiration, and whether anyone else should face charges in connection with the murders.

“To understand what happened, you have to understand who he talked to and who may have known what,” said one law enforcement official briefed on the case. The officials spoke on the condition of anonymity because they did not want to be identified discussing a continuing investigation.

So far, the authorities have determined that people around Roof were aware that he held some racist beliefs.

If the authorities find that any of Roof’s associates knew about his plans, they would most likely try to prosecute them. In the case of the 2013 Boston Marathon bombings, at least two men who were friends of the bombers were charged with helping them dispose of evidence from the bombing and from a subsequent shooting of a police officer. Three other men associated with the bombers were charged in connection with lying to the authorities or obstructing the investigation.

The authorities investigating the shooting that took place at Emanuel African Methodist Episcopal Church have been able to piece together the communications of Roof in part because they are in possession of his electronic devices, including his cellphone and computer. The devices were taken to FBI laboratories in Quantico, Va., where they have been scrutinized by specially trained agents and analysts.

They showed that at least some of Roof’s communications with the hate groups were online.

The State newspaper in Columbia, S.C., reported Thursday that the investigation had widened to include others who may have helped Roof. It did not identify who those people were.