Rsa public private key matching

Hi All,

I have a requirement where i need to check if an rsa public key corresponds to a private key and hence return success or failure. Currently i am using the command

diff <( ssh-keygen -y -e -f "$PRIVKEY" ) <( ssh-keygen -y -e -f "$PUBLICKEY" )

and its solving my purpose. This is in a shell script. But i also want to incorporate the pass phrase in the validation process so that it becomes a dual layer matching, first the pass phrase and then the key matching. Is my approach right above? Can you please suggest any better option.

Some one please suggest.