Howard A. Schmidt, a computer crime expert who advised two presidents and drafted cybersecurity safeguards that were approved by Congress in 2015, died on Thursday at his home in Muskego, Wis. He was 67.

The cause was brain cancer, his wife, Raemarie, said.

The legislation, which evolved from precautions Mr. Schmidt proposed several years earlier, enabled government and industry to share information about potential risks from attackers’ codes and techniques, shielded companies from liability lawsuits for trading data and provided privacy protections for consumers.

By the time the legislation was finally approved, though, critics complained that it had been diluted in response to corporate concerns and was already technologically anachronistic.

Recruited by President George W. Bush after the Sept. 11, 2001, terrorist attacks, Mr. Schmidt returned to the White House under President Barack Obama.