[ZF-10089] Zend_Log
[zend/radio.git] / library / Zend / InfoCard / Cipher.php
blobef4960a94a0f73ee7d1b710d852db4736c9a6447
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
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.
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$
23 /**
24 * Provides an abstraction for encryption ciphers used in an Information Card
25 * implementation
27 * @category Zend
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
35 /**
36 * AES 256 Encryption with CBC
38 const ENC_AES256CBC = 'http://www.w3.org/2001/04/xmlenc#aes256-cbc';
40 /**
41 * AES 128 Encryption with CBC
43 const ENC_AES128CBC = 'http://www.w3.org/2001/04/xmlenc#aes128-cbc';
45 /**
46 * RSA Public Key Encryption with OAEP Padding
48 const ENC_RSA_OAEP_MGF1P = 'http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p';
50 /**
51 * RSA Public Key Encryption with no padding
53 const ENC_RSA = 'http://www.w3.org/2001/04/xmlenc#rsa-1_5';
55 /**
56 * Constructor (disabled)
58 * @return void
59 * @codeCoverageIgnoreStart
61 protected function __construct()
64 // @codeCoverageIgnoreEnd
65 /**
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
71 * depending on URI
73 static public function getInstanceByURI($uri)
75 switch($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);
87 break;
89 case self::ENC_RSA:
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);
92 break;
94 default:
95 require_once 'Zend/InfoCard/Cipher/Exception.php';
96 throw new Zend_InfoCard_Cipher_Exception("Unknown Cipher URI");