Well, the RSA algorithm is not highly difficult to implement yourself...

Once you have implemented such an algorithm though, when the user provides the public key, to ensure that it is suited to the embedded private key, you simply encrypt something with the public key, decrypt the ciphertext with the private key, and then return the decrypted result to the original data... if they match, then it's a valid pair.

Wikipedia has info regarding the RSA algorithm (how it works exactly), check it out !

Once you have implemented such an algorithm though, when the user provides the public key, to ensure that it is suited to the embedded private key, you simply encrypt something with the public key, decrypt the ciphertext with the private key, and then return the decrypted result to the original data... if they match, then it's a valid pair.

Wikipedia has info regarding the RSA algorithm (how it works exactly), check it out !