Technically, what Iran is doing isn't piracy. We just call it that because we don't like Iran's government.
All shipping in the Persian Gulf and Gulf of Oman is in someone's territorial waters or EEZ and a country does have the right to stop, search, and inspect vessels within their EEZ to check for compliance with local laws and regulations.
Things can get dicey when the EEZ is Iran's and they're exercising said right because they're going to find a violation and use it as a pretext to seize the vessel. "Bothering by the book" if you will.
Can you cite the relevant international maritime law which allows the hot pursuit and seizure of shipping without reason or probable cause in a straight/sea lane?