RSA: Extract much of the rsa_pkey_export_to() code to a separate function