web/lib/Zend/InfoCard/Cipher/Pki/Adapter/Abstract.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_InfoCard
       
    17  * @subpackage Zend_InfoCard_Cipher
       
    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: Abstract.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * Zend_InfoCard_Cipher_Pki_Interface
       
    25  */
       
    26 require_once 'Zend/InfoCard/Cipher/Pki/Interface.php';
       
    27 
       
    28 /**
       
    29  * An abstract class for public-key ciphers
       
    30  *
       
    31  * @category   Zend
       
    32  * @package    Zend_InfoCard
       
    33  * @subpackage Zend_InfoCard_Cipher
       
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    36  */
       
    37 abstract class Zend_InfoCard_Cipher_Pki_Adapter_Abstract implements Zend_InfoCard_Cipher_Pki_Interface
       
    38 {
       
    39     /**
       
    40      * OAEP Padding public key encryption
       
    41      */
       
    42     const OAEP_PADDING = 1;
       
    43 
       
    44     /**
       
    45      * No padding public key encryption
       
    46      */
       
    47     const NO_PADDING = 2;
       
    48 
       
    49     /**
       
    50      * The type of padding to use
       
    51      *
       
    52      * @var integer one of the padding constants in this class
       
    53      */
       
    54     protected $_padding;
       
    55 
       
    56     /**
       
    57      * Set the padding of the public key encryption
       
    58      *
       
    59      * @throws Zend_InfoCard_Cipher_Exception
       
    60      * @param integer $padding One of the constnats in this class
       
    61      * @return Zend_InfoCard_Pki_Adapter_Abstract
       
    62      */
       
    63     public function setPadding($padding)
       
    64     {
       
    65         switch($padding) {
       
    66             case self::OAEP_PADDING:
       
    67             case self::NO_PADDING:
       
    68                 $this->_padding = $padding;
       
    69                 break;
       
    70             default:
       
    71                 require_once 'Zend/InfoCard/Cipher/Exception.php';
       
    72                 throw new Zend_InfoCard_Cipher_Exception("Invalid Padding Type Provided");
       
    73                 break;
       
    74         }
       
    75 
       
    76         return $this;
       
    77     }
       
    78 
       
    79     /**
       
    80      * Retruns the public-key padding used
       
    81      *
       
    82      * @return integer One of the padding constants in this class
       
    83      */
       
    84     public function getPadding()
       
    85     {
       
    86         return $this->_padding;
       
    87     }
       
    88 }