Iran has three Kilo class subs, bought from Russia in the 1990s. China has a dozen on order. China already has some of its Kilos, and has received 3M54 missiles as well. So Iran could have gotten the 3M54s from Russia or China. It's unlikely Iran built their new missiles themselves. Even China, with far more resources, has not gotten far in this area. Much easier to make a deal to get them from Russia or China. Or even India, which also has the 3M54, although is not likely to sell them to Iran.
It's also possible that Iran has an earlier Russian cruise missile launched from a torpedo tube (the "Granat"). This was a 1980s development, made obsolete by the recently developed 3M54 (nicknamed "Klub"). The Granat is not designed to hit ships at sea, but fixed targets on land, and with a nuclear warhead.
The problem with the 3M54 is that it would make it easer for Iran to shut down oil exports from the Persian Gulf, at least for a while. China and India have economies heavily dependent on that oil, and would suffer if the oil supplies were interrupted. But Russia, as a major oil exporter, would benefit enormously if Iran shut off Persian Gulf oil for a while, and oil prices spiked.
Iran test fired what appeared to be a Russian Klub-S (3M54) submarine launched anti-ship missile. Weighing two tons, and fired from a 533mm (21 inch) torpedo tube on a Kilo class sub, it has a 440 pound warhead. The anti-ship version speeds up to 3,000 kilometers an hour during its last minute or so of its flight, and has a range of 220 kilometers. There is also a land attack version, with a 300 kilometers range and an 880 pound warhead.