Abstract.php 2.4 KB

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