summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2013-06-20 02:12:01 -0700
committerBjörn Schießle <bjoern@schiessle.org>2013-06-20 02:12:01 -0700
commitc4aa3fac7ee2c5d687423c74b0393a88fa9bbc9d (patch)
treec97d0ae2c5c16e7f78739d761652ddeb70d1f35d /apps
parent5aaf807366ab92bcd7126a5217cc586bef005818 (diff)
parentfe61230cc14b130bc553cf3270df8f3bd8b88d4d (diff)
downloadnextcloud-server-c4aa3fac7ee2c5d687423c74b0393a88fa9bbc9d.tar.gz
nextcloud-server-c4aa3fac7ee2c5d687423c74b0393a88fa9bbc9d.zip
Merge pull request #3788 from owncloud/more_error_messages
add some more error messages, in case something went wrong
Diffstat (limited to 'apps')
-rwxr-xr-xapps/files_encryption/lib/crypt.php35
-rw-r--r--apps/files_encryption/lib/util.php19
2 files changed, 28 insertions, 26 deletions
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index 945b342a316..927064012b6 100755
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -51,21 +51,26 @@ class Crypt {
*/
public static function createKeypair() {
- $res = openssl_pkey_new(array('private_key_bits' => 4096));
-
- // Get private key
- openssl_pkey_export($res, $privateKey);
+ $return = false;
- // Get public key
- $publicKey = openssl_pkey_get_details($res);
+ $res = openssl_pkey_new(array('private_key_bits' => 4096));
- $publicKey = $publicKey['key'];
+ if ($res === false) {
+ \OCP\Util::writeLog('Encryption library', 'couldn\'t generate users key-pair for ' . \OCP\User::getUser(), \OCP\Util::ERROR);
+ } elseif (openssl_pkey_export($res, $privateKey)) {
+ // Get public key
+ $publicKey = openssl_pkey_get_details($res);
+ $publicKey = $publicKey['key'];
- return (array(
- 'publicKey' => $publicKey,
- 'privateKey' => $privateKey
- ));
+ $return = array(
+ 'publicKey' => $publicKey,
+ 'privateKey' => $privateKey
+ );
+ } else {
+ \OCP\Util::writeLog('Encryption library', 'couldn\'t export users private key, please check your servers openSSL configuration.' . \OCP\User::getUser(), \OCP\Util::ERROR);
+ }
+ return $return;
}
/**
@@ -287,28 +292,22 @@ class Crypt {
public static function symmetricEncryptFileContent($plainContent, $passphrase = '') {
if (!$plainContent) {
-
+ \OCP\Util::writeLog('Encryption library', 'symmetrically encryption failed, no content given.', \OCP\Util::ERROR);
return false;
-
}
$iv = self::generateIv();
if ($encryptedContent = self::encrypt($plainContent, $iv, $passphrase)) {
-
// Combine content to encrypt with IV identifier and actual IV
$catfile = self::concatIv($encryptedContent, $iv);
-
$padded = self::addPadding($catfile);
return $padded;
} else {
-
\OCP\Util::writeLog('Encryption library', 'Encryption (symmetric) of keyfile content failed', \OCP\Util::ERROR);
-
return false;
-
}
}
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index b4b3923a799..e8e53859bd8 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -228,18 +228,21 @@ class Util {
// Generate keypair
$keypair = Crypt::createKeypair();
- \OC_FileProxy::$enabled = false;
+ if ($keypair) {
- // Save public key
- $this->view->file_put_contents($this->publicKeyPath, $keypair['publicKey']);
+ \OC_FileProxy::$enabled = false;
- // Encrypt private key with user pwd as passphrase
- $encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $passphrase);
+ // Encrypt private key with user pwd as passphrase
+ $encryptedPrivateKey = Crypt::symmetricEncryptFileContent($keypair['privateKey'], $passphrase);
- // Save private key
- $this->view->file_put_contents($this->privateKeyPath, $encryptedPrivateKey);
+ // Save key-pair
+ if ($encryptedPrivateKey) {
+ $this->view->file_put_contents($this->privateKeyPath, $encryptedPrivateKey);
+ $this->view->file_put_contents($this->publicKeyPath, $keypair['publicKey']);
+ }
- \OC_FileProxy::$enabled = true;
+ \OC_FileProxy::$enabled = true;
+ }
} else {
// check if public-key exists but private-key is missing