]> source.dussan.org Git - nextcloud-server.git/commitdiff
added test for decryptPrivateKey()
authorBjörn Schießle <schiessle@owncloud.com>
Mon, 3 Jun 2013 15:34:43 +0000 (17:34 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Thu, 13 Jun 2013 11:26:48 +0000 (13:26 +0200)
apps/files_encryption/tests/crypt.php

index e153a49a2c7cd903d6ba4f027931fd19c7e0fa80..ccf3c52fa97dcb9fa1c8123d60c0866d49e3e2a5 100755 (executable)
@@ -226,6 +226,24 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase {
 
        }
 
+       function testDecryptPrivateKey() {
+
+               $keypair = Encryption\Crypt::createKeypair();
+
+               // test successful decrypt
+               $crypted = Encryption\Crypt::symmetricEncryptFileContent($keypair['privateKey'], 'hat');
+
+               $decrypted = Encryption\Crypt::decryptPrivateKey($crypted, 'hat');
+
+               $this->assertEquals($keypair['privateKey'], $decrypted);
+
+               //test private key decrypt with wrong password
+               $wrongPasswd = Encryption\Crypt::decryptPrivateKey($crypted, 'hat2');
+
+               $this->assertEquals(false, $wrongPasswd);
+
+       }
+
        function testSymmetricEncryptFileContent() {
 
                # TODO: search in keyfile for actual content as IV will ensure this test always passes