Rename symmetric encrypt/decrypt class
I'm going to make this one more generic than one library, and have it support ciphers based on what libraries are available, so this more generic name is appropriate.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
require_once dirname(__FILE__).'/../lib/openpgp.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_rsa.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_aes_tripledes.php';
|
||||
require_once dirname(__FILE__).'/../lib/openpgp_crypt_symmetric.php';
|
||||
|
||||
class MessageVerification extends PHPUnit_Framework_TestCase {
|
||||
public function oneMessageRSA($pkey, $path) {
|
||||
@@ -67,7 +67,7 @@ class KeyVerification extends PHPUnit_Framework_TestCase {
|
||||
class Decryption extends PHPUnit_Framework_TestCase {
|
||||
public function oneSymmetric($pass, $cnt, $path) {
|
||||
$m = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/' . $path));
|
||||
$m2 = OpenPGP_Crypt_AES_TripleDES::decryptSymmetric($pass, $m);
|
||||
$m2 = OpenPGP_Crypt_Symmetric::decryptSymmetric($pass, $m);
|
||||
while($m2[0] instanceof OpenPGP_CompressedDataPacket) $m2 = $m2[0]->data;
|
||||
foreach($m2 as $p) {
|
||||
if($p instanceof OpenPGP_LiteralDataPacket) {
|
||||
@@ -107,7 +107,7 @@ class Decryption extends PHPUnit_Framework_TestCase {
|
||||
|
||||
public function testDecryptSecretKey() {
|
||||
$key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/encryptedSecretKey.gpg'));
|
||||
$skey = OpenPGP_Crypt_AES_TripleDES::decryptSecretKey("hello", $key[0]);
|
||||
$skey = OpenPGP_Crypt_Symmetric::decryptSecretKey("hello", $key[0]);
|
||||
$this->assertSame(!!$skey, true);
|
||||
}
|
||||
}
|
||||
@@ -115,15 +115,15 @@ class Decryption extends PHPUnit_Framework_TestCase {
|
||||
class Encryption extends PHPUnit_Framework_TestCase {
|
||||
public function testEncryptSymmetric() {
|
||||
$data = new OpenPGP_LiteralDataPacket('This is text.', array('format' => 'u', 'filename' => 'stuff.txt'));
|
||||
$encrypted = OpenPGP_Crypt_AES_TripleDES::encrypt('secret', new OpenPGP_Message(array($data)));
|
||||
$decrypted = OpenPGP_Crypt_AES_TripleDES::decryptSymmetric('secret', $encrypted);
|
||||
$encrypted = OpenPGP_Crypt_Symmetric::encrypt('secret', new OpenPGP_Message(array($data)));
|
||||
$decrypted = OpenPGP_Crypt_Symmetric::decryptSymmetric('secret', $encrypted);
|
||||
$this->assertEquals($decrypted[0]->data, 'This is text.');
|
||||
}
|
||||
|
||||
public function testEncryptAsymmetric() {
|
||||
$key = OpenPGP_Message::parse(file_get_contents(dirname(__FILE__) . '/data/helloKey.gpg'));
|
||||
$data = new OpenPGP_LiteralDataPacket('This is text.', array('format' => 'u', 'filename' => 'stuff.txt'));
|
||||
$encrypted = OpenPGP_Crypt_AES_TripleDES::encrypt($key, new OpenPGP_Message(array($data)));
|
||||
$encrypted = OpenPGP_Crypt_Symmetric::encrypt($key, new OpenPGP_Message(array($data)));
|
||||
$decryptor = new OpenPGP_Crypt_RSA($key);
|
||||
$decrypted = $decryptor->decrypt($encrypted);
|
||||
$this->assertEquals($decrypted[0]->data, 'This is text.');
|
||||
|
Reference in New Issue
Block a user