Naval blockades of enemy ports during war are legal, that is what USA and Israel argue they are doing. That is not what Iran is doing, they are blocking fully neutral ships from going in other countries waterways.
But US law is not international law. Internationally you are at war, whatever you call it internally doesn't matter to me.