Earlier quoted context omitted.
It's absolutely not at all illegal to check and is a very standard part of background checks.
Not sure why this was downvoted, it's not illegal and companies do it via background checks. Quick searches reveal this is a popular question, spot checks of the answers agree that it's not illegal and quite common.
Most large companies won't give out your past salary information, so if they don't force you to provide proof, it's not very likely they will be able to verify it.
>via background checks
Background checks are normally done via a 3rd party background check company, and they don't have access to this kind of data.