web/lib/Zend/Crypt/Rsa/Key.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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 license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Crypt
       
    17  * @subpackage Rsa
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Key.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @category   Zend
       
    25  * @package    Zend_Crypt
       
    26  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    27  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    28  */
       
    29 class Zend_Crypt_Rsa_Key implements Countable
       
    30 {
       
    31     /**
       
    32      * @var string
       
    33      */
       
    34     protected $_pemString = null;
       
    35 
       
    36     /**
       
    37      * Bits, key string and type of key
       
    38      *
       
    39      * @var array
       
    40      */
       
    41     protected $_details = array();
       
    42 
       
    43     /**
       
    44      * Key Resource
       
    45      *
       
    46      * @var resource
       
    47      */
       
    48     protected $_opensslKeyResource = null;
       
    49 
       
    50     /**
       
    51      * Retrieves key resource
       
    52      *
       
    53      * @return resource
       
    54      */
       
    55     public function getOpensslKeyResource()
       
    56     {
       
    57         return $this->_opensslKeyResource;
       
    58     }
       
    59 
       
    60     /**
       
    61      * @return string
       
    62      * @throws Zend_Crypt_Exception
       
    63      */
       
    64     public function toString()
       
    65     {
       
    66         if (!empty($this->_pemString)) {
       
    67             return $this->_pemString;
       
    68         } elseif (!empty($this->_certificateString)) {
       
    69             return $this->_certificateString;
       
    70         }
       
    71         /**
       
    72          * @see Zend_Crypt_Exception
       
    73          */
       
    74         require_once 'Zend/Crypt/Exception.php';
       
    75         throw new Zend_Crypt_Exception('No public key string representation is available');
       
    76     }
       
    77 
       
    78     /**
       
    79      * @return string
       
    80      */
       
    81     public function __toString()
       
    82     {
       
    83         return $this->toString();
       
    84     }
       
    85 
       
    86     public function count()
       
    87     {
       
    88         return $this->_details['bits'];
       
    89     }
       
    90 
       
    91     public function getType()
       
    92     {
       
    93         return $this->_details['type'];
       
    94     }
       
    95 }