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.
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
24 * Provides an abstraction for encryption ciphers used in an Information Card
28 * @package Zend_InfoCard
29 * @subpackage Zend_InfoCard_Cipher
30 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
31 * @license http://framework.zend.com/license/new-bsd New BSD License
33 class Zend_InfoCard_Cipher
36 * AES 256 Encryption with CBC
38 const ENC_AES256CBC
= 'http://www.w3.org/2001/04/xmlenc#aes256-cbc';
41 * AES 128 Encryption with CBC
43 const ENC_AES128CBC
= 'http://www.w3.org/2001/04/xmlenc#aes128-cbc';
46 * RSA Public Key Encryption with OAEP Padding
48 const ENC_RSA_OAEP_MGF1P
= 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p';
51 * RSA Public Key Encryption with no padding
53 const ENC_RSA
= 'http://www.w3.org/2001/04/xmlenc#rsa-1_5';
56 * Constructor (disabled)
59 * @codeCoverageIgnoreStart
61 protected function __construct()
64 // @codeCoverageIgnoreEnd
66 * Returns an instance of a cipher object supported based on the URI provided
68 * @throws Zend_InfoCard_Cipher_Exception
69 * @param string $uri The URI of the encryption method wantde
70 * @return mixed an Instance of Zend_InfoCard_Cipher_Symmetric_Interface or Zend_InfoCard_Cipher_Pki_Interface
73 static public function getInstanceByURI($uri)
76 case self
::ENC_AES256CBC
:
77 include_once 'Zend/InfoCard/Cipher/Symmetric/Adapter/Aes256cbc.php';
78 return new Zend_InfoCard_Cipher_Symmetric_Adapter_Aes256cbc();
80 case self
::ENC_AES128CBC
:
81 include_once 'Zend/InfoCard/Cipher/Symmetric/Adapter/Aes128cbc.php';
82 return new Zend_InfoCard_Cipher_Symmetric_Adapter_Aes128cbc();
84 case self
::ENC_RSA_OAEP_MGF1P
:
85 include_once 'Zend/InfoCard/Cipher/Pki/Adapter/Rsa.php';
86 return new Zend_InfoCard_Cipher_Pki_Adapter_Rsa(Zend_InfoCard_Cipher_Pki_Adapter_Rsa
::OAEP_PADDING
);
90 include_once 'Zend/InfoCard/Cipher/Pki/Adapter/Rsa.php';
91 return new Zend_InfoCard_Cipher_Pki_Adapter_Rsa(Zend_InfoCard_Cipher_Pki_Adapter_Rsa
::NO_PADDING
);
95 require_once 'Zend/InfoCard/Cipher/Exception.php';
96 throw new Zend_InfoCard_Cipher_Exception("Unknown Cipher URI");