I doubt that there's any law against it, quite possibly because it's something that employers almost never do. By revealing your salary, and others', for the position, the company locks itself out of anything lower in its job offer to your friend. Most companies try to make sure that nobody knows what anyone else is making.
If your employer did this, it means either your friend is very, very good at what you both do, or there's a shortage of people like you out there on the job market. Complaining to your company about this might not make the most sense, as opposed to keeping a low profile while you start looking elsewhere.