Sfoglia il codice sorgente

[ZF-6518]add PHPDoc to Zend_Crypt_*

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15384 44c647ce-9c0f-0410-b52a-842ac1e357ba
yoshida@zend.co.jp 16 anni fa
parent
commit
e2a63aab9c

+ 62 - 0
library/Zend/Crypt.php

@@ -1,5 +1,30 @@
 <?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
 
+/**
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
 class Zend_Crypt
 {
 
@@ -9,6 +34,9 @@ class Zend_Crypt
 
     protected static $_type = null;
 
+    /**
+     * @var array
+     */
     protected static $_supportedAlgosOpenssl = array(
         'md2',
         'md4',
@@ -22,6 +50,9 @@ class Zend_Crypt
         'sha512'
     );
 
+    /**
+     * @var array
+     */
     protected static $_supportedAlgosMhash = array(
         'adler32',
         'crc32',
@@ -41,6 +72,12 @@ class Zend_Crypt
         'tiger160'
     );
 
+    /**
+     * @param string $algorithm
+     * @param string $data
+     * @param bool $binaryOutput
+     * @return unknown
+     */
     public static function hash($algorithm, $data, $binaryOutput = false)
     {
         $algorithm = strtolower($algorithm);
@@ -52,6 +89,10 @@ class Zend_Crypt
         $result = self::$supportedMethod($algorithm, $data, $binaryOutput);
     }
 
+    /**
+     * @param string $algorithm
+     * @throws Zend_Crypt_Exception
+     */
     protected static function _detectHashSupport($algorithm)
     {
         if (function_exists('hash')) {
@@ -75,15 +116,30 @@ class Zend_Crypt
                return;
             }
         }
+        /**
+         * @see Zend_Crypt_Exception
+         */
         require_once 'Zend/Crypt/Exception.php';
         throw new Zend_Crypt_Exception('\'' . $algorithm . '\' is not supported by any available extension or native function');
     }
 
+    /**
+     * @param string $algorithm
+     * @param string $data
+     * @param bool $binaryOutput
+     * @return string
+     */
     protected static function _digestHash($algorithm, $data, $binaryOutput)
     {
         return hash($algorithm, $data, $binaryOutput);
     }
 
+    /**
+     * @param string $algorithm
+     * @param string $data
+     * @param bool $binaryOutput
+     * @return string
+     */
     protected static function _digestMhash($algorithm, $data, $binaryOutput)
     {
         $constant = constant('MHASH_' . strtoupper($algorithm));
@@ -94,6 +150,12 @@ class Zend_Crypt
         return bin2hex($binary);
     }
 
+    /**
+     * @param string $algorithm
+     * @param string $data
+     * @param bool $binaryOutput
+     * @return string
+     */
     protected static function _digestOpenssl($algorithm, $data, $binaryOutput)
     {
         if ($algorithm == 'ripemd160') {

+ 66 - 1
library/Zend/Crypt/Rsa.php

@@ -1,9 +1,41 @@
 <?php
-
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @subpackage Rsa
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
+
+/**
+ * @see Zend_Crypt_Rsa_Key_Private
+ */
 require_once 'Zend/Crypt/Rsa/Key/Private.php';
 
+/**
+ * @see Zend_Crypt_Rsa_Key_Public
+ */
 require_once 'Zend/Crypt/Rsa/Key/Public.php';
 
+/**
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
 class Zend_Crypt_Rsa
 {
 
@@ -14,6 +46,9 @@ class Zend_Crypt_Rsa
 
     protected $_publicKey = null;
 
+    /**
+     * @var string
+     */
     protected $_pemString = null;
 
     protected $_pemPath = null;
@@ -69,6 +104,12 @@ class Zend_Crypt_Rsa
         return $this->_publicKey;
     }
 
+    /**
+     * @param string $data
+     * @param Zend_Crypt_Rsa_Key_Private $privateKey
+     * @param string $format
+     * @return string
+     */
     public function sign($data, Zend_Crypt_Rsa_Key_Private $privateKey = null, $format = null)
     {
         $signature = '';
@@ -88,6 +129,12 @@ class Zend_Crypt_Rsa
         return $signature;
     }
 
+    /**
+     * @param string $data
+     * @param string $signature
+     * @param string $format
+     * @return string
+     */
     public function verifySignature($data, $signature, $format = null)
     {
         if ($format == self::BASE64) {
@@ -99,6 +146,12 @@ class Zend_Crypt_Rsa
         return $result;
     }
 
+    /**
+     * @param string $data
+     * @param Zend_Crypt_Rsa_Key $key
+     * @param string $format
+     * @return string
+     */
     public function encrypt($data, Zend_Crypt_Rsa_Key $key, $format = null)
     {
         $encrypted = '';
@@ -113,6 +166,12 @@ class Zend_Crypt_Rsa
         return $encrypted;
     }
 
+    /**
+     * @param string $data
+     * @param Zend_Crypt_Rsa_Key $key
+     * @param string $format
+     * @return string
+     */
     public function decrypt($data, Zend_Crypt_Rsa_Key $key, $format = null)
     {
         $decrypted = '';
@@ -153,6 +212,9 @@ class Zend_Crypt_Rsa
         return $return;
     }
 
+    /**
+     * @param string $value
+     */
     public function setPemString($value)
     {
         $this->_pemString = $value;
@@ -193,6 +255,9 @@ class Zend_Crypt_Rsa
         }
     }
 
+    /**
+     * @return string
+     */
     public function getPemString()
     {
         return $this->_pemString;

+ 59 - 6
library/Zend/Crypt/Rsa/Key.php

@@ -1,41 +1,94 @@
 <?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @subpackage Rsa
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
 
+/**
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
 class Zend_Crypt_Rsa_Key implements Countable
 {
-    
+    /**
+     * @var string
+     */
     protected $_pemString = null;
 
+    /**
+     * Bits, key string and type of key
+     *
+     * @var array
+     */
     protected $_details = array();
 
+    /**
+     * Key Resource
+     *
+     * @var resource
+     */
     protected $_opensslKeyResource = null;
 
-    public function getOpensslKeyResource() 
+    /**
+     * Retrieves key resource
+     *
+     * @return resource
+     */
+    public function getOpensslKeyResource()
     {
         return $this->_opensslKeyResource;
     }
 
-    public function toString() 
+    /**
+     * @return string
+     * @throws Zend_Crypt_Exception
+     */
+    public function toString()
     {
         if (!empty($this->_pemString)) {
             return $this->_pemString;
         } elseif (!empty($this->_certificateString)) {
             return $this->_certificateString;
         }
+        /**
+         * @see Zend_Crypt_Exception
+         */
         require_once 'Zend/Crypt/Exception.php';
         throw new Zend_Crypt_Exception('No public key string representation is available');
     }
 
-    public function __toString() 
+    /**
+     * @return string
+     */
+    public function __toString()
     {
         return $this->toString();
     }
 
-    public function count() 
+    public function count()
     {
         return $this->_details['bits'];
     }
 
-    public function getType() 
+    public function getType()
     {
         return $this->_details['type'];
     }

+ 40 - 0
library/Zend/Crypt/Rsa/Key/Private.php

@@ -1,7 +1,36 @@
 <?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @subpackage Rsa
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
 
+/**
+ * @see Zend_Crypt_Rsa_Key
+ */
 require_once 'Zend/Crypt/Rsa/Key.php';
 
+/**
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
 class Zend_Crypt_Rsa_Key_Private extends Zend_Crypt_Rsa_Key
 {
 
@@ -13,10 +42,17 @@ class Zend_Crypt_Rsa_Key_Private extends Zend_Crypt_Rsa_Key
         $this->_parse($passPhrase);
     }
 
+    /**
+     * @param string $passPhrase
+     * @throws Zend_Crypt_Exception
+     */
     protected function _parse($passPhrase)
     {
         $result = openssl_get_privatekey($this->_pemString, $passPhrase);
         if (!$result) {
+            /**
+             * @see Zend_Crypt_Exception
+             */
             require_once 'Zend/Crypt/Exception.php';
             throw new Zend_Crypt_Exception('Unable to load private key');
         }
@@ -27,6 +63,10 @@ class Zend_Crypt_Rsa_Key_Private extends Zend_Crypt_Rsa_Key
     public function getPublicKey()
     {
         if (is_null($this->_publicKey)) {
+            /**
+             * @see Zend_Crypt_Rsa_Key_Public
+             */
+            require_once 'Zend/Crypt/Rsa/Key/Public.php';
             $this->_publicKey = new Zend_Crypt_Rsa_Key_Public($this->_details['key']);
         }
         return $this->_publicKey;

+ 39 - 3
library/Zend/Crypt/Rsa/Key/Public.php

@@ -1,18 +1,51 @@
 <?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @subpackage Rsa
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ * @version    $Id$
+ */
 
+/**
+ * @see Zend_Crypt_Rsa_Key
+ */
 require_once 'Zend/Crypt/Rsa/Key.php';
 
+/**
+ * @category   Zend
+ * @package    Zend_Crypt
+ * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license    http://framework.zend.com/license/new-bsd     New BSD License
+ */
 class Zend_Crypt_Rsa_Key_Public extends Zend_Crypt_Rsa_Key
 {
 
     protected $_certificateString = null;
 
-    public function __construct($string) 
+    public function __construct($string)
     {
         $this->_parse($string);
     }
 
-    protected function _parse($string) 
+    /**
+     * @param string $string
+     * @throws Zend_Crypt_Exception
+     */
+    protected function _parse($string)
     {
         if (preg_match("/^-----BEGIN CERTIFICATE-----/", $string)) {
             $this->_certificateString = $string;
@@ -21,6 +54,9 @@ class Zend_Crypt_Rsa_Key_Public extends Zend_Crypt_Rsa_Key
         }
         $result = openssl_get_publickey($string);
         if (!$result) {
+            /**
+             * @see Zend_Crypt_Exception
+             */
             require_once 'Zend/Crypt/Exception.php';
             throw new Zend_Crypt_Exception('Unable to load public key');
         }
@@ -30,7 +66,7 @@ class Zend_Crypt_Rsa_Key_Public extends Zend_Crypt_Rsa_Key
         $this->_details = openssl_pkey_get_details($this->_opensslKeyResource);
     }
 
-    public function getCertificate() 
+    public function getCertificate()
     {
         return $this->_certificateString;
     }