00001 <?php 00026 require_once 'Zend/Crypt/Rsa/Key.php'; 00027 00034 class Zend_Crypt_Rsa_Key_Private extends Zend_Crypt_Rsa_Key 00035 { 00036 00037 protected $_publicKey = null; 00038 00039 public function __construct($pemString, $passPhrase = null) 00040 { 00041 $this->_pemString = $pemString; 00042 $this->_parse($passPhrase); 00043 } 00044 00049 protected function _parse($passPhrase) 00050 { 00051 $result = openssl_get_privatekey($this->_pemString, $passPhrase); 00052 if (!$result) { 00056 require_once 'Zend/Crypt/Exception.php'; 00057 throw new Zend_Crypt_Exception('Unable to load private key'); 00058 } 00059 $this->_opensslKeyResource = $result; 00060 $this->_details = openssl_pkey_get_details($this->_opensslKeyResource); 00061 } 00062 00063 public function getPublicKey() 00064 { 00065 if (is_null($this->_publicKey)) { 00069 require_once 'Zend/Crypt/Rsa/Key/Public.php'; 00070 $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_details['key']); 00071 } 00072 return $this->_publicKey; 00073 } 00074 00075 }