The charges were announced here on Friday by Rod J. Rosenstein, the deputy attorney general, who made clear during a news conference that the Justice Department views the hacking not as an attack on one party, but as an attack against the United States.