diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2015-08-25 15:58:07 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-08-30 15:31:19 +0200 |
commit | 166e57cf611b659892748fc7799e85a82553b042 (patch) | |
tree | a9f16c0f601bac4f95e2c9a96f0725daf43a6a12 /apps/encryption | |
parent | f893de413670877aa91af2559a1eee369b4590d6 (diff) | |
download | nextcloud-server-166e57cf611b659892748fc7799e85a82553b042.tar.gz nextcloud-server-166e57cf611b659892748fc7799e85a82553b042.zip |
return false if private key is not valid
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/lib/crypto/crypt.php | 2 | ||||
-rw-r--r-- | apps/encryption/tests/lib/crypto/cryptTest.php | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/apps/encryption/lib/crypto/crypt.php b/apps/encryption/lib/crypto/crypt.php index 6c4c108f50a..5d1bb92460a 100644 --- a/apps/encryption/lib/crypto/crypt.php +++ b/apps/encryption/lib/crypto/crypt.php @@ -398,7 +398,7 @@ class Crypt { } } - return true; + return false; } /** diff --git a/apps/encryption/tests/lib/crypto/cryptTest.php b/apps/encryption/tests/lib/crypto/cryptTest.php index 3c7767a8908..c6f16e952d7 100644 --- a/apps/encryption/tests/lib/crypto/cryptTest.php +++ b/apps/encryption/tests/lib/crypto/cryptTest.php @@ -363,4 +363,19 @@ class cryptTest extends TestCase { ]; } + public function testIsValidPrivateKey() { + $res = openssl_pkey_new(); + openssl_pkey_export($res, $privateKey); + + // valid private key + $this->assertTrue( + $this->invokePrivate($this->crypt, 'isValidPrivateKey', [$privateKey]) + ); + + // invalid private key + $this->assertFalse( + $this->invokePrivate($this->crypt, 'isValidPrivateKey', ['foo']) + ); + } + } |