Validate RSA key against password without PHPSeclib

I try to validate if a passphrase works with a private key in PHP.

Right now the solution is simply to use phpseclib and do this:

$rsa = new phpseclibCryptRSA();
$rsa->setPassword($passphrase);
$res = $rsa->loadKey($privateKeyString);

and check if $res is false. This works fine but I want to get rid of phpseclib and use native PHP functionality. How can I achieve that? I tried openssl_pkey_get_private() which did not work.

I only expect RSA keys (like “—–BEGIN RSA PRIVATE KEY—–“)…