[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/include/Zend/Crypt/Rsa/Key/ -> Private.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to the new BSD license that is bundled
   8   * with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://framework.zend.com/license/new-bsd
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to [email protected] so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Crypt
  17   * @subpackage Rsa
  18   * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   * @version    $Id: Private.php 24593 2012-01-05 20:35:02Z matthew $
  21   */
  22  
  23  /**
  24   * @see Zend_Crypt_Rsa_Key
  25   */
  26  require_once  'Zend/Crypt/Rsa/Key.php';
  27  
  28  /**
  29   * @category   Zend
  30   * @package    Zend_Crypt
  31   * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  32   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  33   */
  34  class Zend_Crypt_Rsa_Key_Private extends Zend_Crypt_Rsa_Key
  35  {
  36  
  37      protected $_publicKey = null;
  38  
  39      public function __construct($pemString, $passPhrase = null)
  40      {
  41          $this->_pemString = $pemString;
  42          $this->_parse($passPhrase);
  43      }
  44  
  45      /**
  46       * @param string $passPhrase
  47       * @throws Zend_Crypt_Exception
  48       */
  49      protected function _parse($passPhrase)
  50      {
  51          $result = openssl_get_privatekey($this->_pemString, $passPhrase);
  52          if (!$result) {
  53              /**
  54               * @see Zend_Crypt_Exception
  55               */
  56              require_once  'Zend/Crypt/Exception.php';
  57              throw new Zend_Crypt_Exception('Unable to load private key');
  58          }
  59          $this->_opensslKeyResource = $result;
  60          $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
  61      }
  62  
  63      public function getPublicKey()
  64      {
  65          if ($this->_publicKey === null) {
  66              /**
  67               * @see Zend_Crypt_Rsa_Key_Public
  68               */
  69              require_once  'Zend/Crypt/Rsa/Key/Public.php';
  70              $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_details['key']);
  71          }
  72          return $this->_publicKey;
  73      }
  74  
  75  }


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1