Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-05-11 11:31:46 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2020-05-11 13:46:59 +0300
commit35ff4aa1c6693a7aafab4860e8d0c4b0fc077b74 (patch)
treefc885ac3c7872e49d15f4d330e96500d4e804c0c /tests/lib/Security
parent90e6b3105948c697fbd1956b79c8bd3775ef0c9f (diff)
Use random_bytes
Since we don't care if it is human readbale. The code is backwards compatible with the old format. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/Security')
-rw-r--r--tests/lib/Security/CryptoTest.php15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/lib/Security/CryptoTest.php b/tests/lib/Security/CryptoTest.php
index a6f4902594a..dbdf6f6a195 100644
--- a/tests/lib/Security/CryptoTest.php
+++ b/tests/lib/Security/CryptoTest.php
@@ -24,7 +24,7 @@ class CryptoTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->crypto = new Crypto(\OC::$server->getConfig(), \OC::$server->getSecureRandom());
+ $this->crypto = new Crypto(\OC::$server->getConfig());
}
/**
@@ -35,7 +35,7 @@ class CryptoTest extends \Test\TestCase {
$this->assertEquals($stringToEncrypt, $this->crypto->decrypt($ciphertext));
}
-
+
public function testWrongPassword() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('HMAC does not match.');
@@ -51,7 +51,7 @@ class CryptoTest extends \Test\TestCase {
$this->assertEquals($stringToEncrypt, $this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd'));
}
-
+
public function testWrongIV() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('HMAC does not match.');
@@ -60,7 +60,7 @@ class CryptoTest extends \Test\TestCase {
$this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd');
}
-
+
public function testWrongParameters() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Authenticated ciphertext could not be decoded.');
@@ -68,4 +68,11 @@ class CryptoTest extends \Test\TestCase {
$encryptedString = '1|2';
$this->crypto->decrypt($encryptedString, 'ThisIsAVeryS3cur3P4ssw0rd');
}
+
+ public function testLegacy() {
+ $cipherText = 'e16599188e3d212f5c7f17fdc2abca46|M1WfLAxbcAmITeD6|509457885d6ca5e6c3bfd3741852687a7f2bffce197f8d5ae97b65818b15a1b7f616b68326ff312371540f4ca8ac55f8e2de4aa13aab3474bd3431e51214e3ee';
+ $password = 'mypass';
+
+ $this->assertSame('legacy test', $this->crypto->decrypt($cipherText, $password));
+ }
}