Russian star Sharapova was handed a two-year doping ban on Wednesday after testing positive for the banned medication meldonium at January's Australian Open.
The 29-year-old admitted in March that she simply hadn't realised meldonium, which was added to the World Antio-Doping Agency's banned substance list in January, was no longer permitted — she had been taking the medication for ten years.
“I only heard the headlines, I didn't quite get into all the details but to me it's about zero tolerance,” said Federer after his 6-4, 5-7, 6-4 victory over Taylor Fritz at the Stuttgart Open on Thursday.
“It doesn't matter if they did it on purpose or not — I don't really see the difference. You need to know what goes into your body, you have to be 100% sure of what's going on, if you're not, you're gong to be damned.
“Of course she's got the right to fight the case, like everybody else as well. I'm just for zero tolerance.
“I stay by my word that we should be saving blood samples for 10, 15, 20 years to come, so you have to scare away the people who think they could cheat.
“You have to scare them so they will not do it, so they could retroactively also be banned, and take away titles and so forth.”
Federer's win in Stuttgart over teenager Taylor Fritz marked his return to tennis after a month away with back pain.
The pair were called off court in the second round on Wednesday as heavy rains raked the Weissenhof Club, with the Swiss leading 4-3.
Federer, who last played in a third-round Rome loss to Dominic Thiem, and then missed the French Open, is building for another run at Wimbledon, where he is a seven-time champion.
The world number three is making his first appearance in Stuttgart since 2001, when he played the indoor Masters.
“I got the feel of playing matches again,” Federer said. “It was also good to see how the body reacted. The match was short but I felt good — no tension.
“But my energy level was up and down, it's a good thing I found it again at the end. I was wondering where it went during some of the match.
“It just felt good to be back on the match court.”
The 34-year-old reached another milestone as his defeat of the young American hopeful marked his 1,071st victory, tying him in second place with Ivan Lendl for the Open era win record.