create keypair for ownCloud with empty passphrase, will be used for public link shares

remotes/origin/stable6
Björn Schießle 12 years ago
parent 9356f9a6bf
commit 5005195db0
  1. 5
      apps/files_encryption/lib/crypt.php
  2. 28
      apps/files_encryption/lib/session.php
  3. 2
      lib/public/share.php

@ -763,7 +763,7 @@ class Crypt {
$util = new Util( $view, $user );
// Check that the user is encryption capable
if ( $util->ready() ) {
if ( $util->ready() && $user == 'ownCloud' ) {
// Construct array of just UIDs for Keymanager{}
$userIds[] = $user;
@ -827,16 +827,13 @@ class Crypt {
foreach ( $content as $c) {
$path = substr($c['path'], 5);
if ( $filesView->is_dir($path) ) {
error_log("dive into $path");
$result &= self::updateKeyfile($path);
} else {
error_log("encKeyFileToMultipleUsers $path");
$shares = \OCP\Share::getUsersSharingFile( $path, true );
$result &= self::encKeyfileToMultipleUsers($shares, $path);
}
}
} else {
error_log("encKeyFileToMultipleUsers single file: " . $path);
$shares = \OCP\Share::getUsersSharingFile( $path, true );
$result = self::encKeyfileToMultipleUsers($shares, $path);
}

@ -27,6 +27,34 @@ namespace OCA\Encryption;
*/
class Session {
/**
* @brief if session is started, check if ownCloud key pair is set up, if not create it
*
* The ownCloud key pair is used to allow public link sharing even if encryption is enabled
*/
public function __construct() {
$view = new \OC\Files\View('/');
if (!$view->is_dir('owncloud_private_key')) {
$view->mkdir('owncloud_private_key');
}
if (!$view->file_exists("/public-keys/owncloud.public.key") || !$view->file_exists("/owncloud_private_key/owncloud.private.key") ) {
$keypair = Crypt::createKeypair();
\OC_FileProxy::$enabled = false;
// Save public key
$view->file_put_contents( '/public-keys/owncloud.public.key', $keypair['publicKey'] );
// Encrypt private key empthy passphrase
$encryptedPrivateKey = Crypt::symmetricEncryptFileContent( $keypair['privateKey'], '' );
// Save private key
error_log("encrypted private key: " . $encryptedPrivateKey );
$view->file_put_contents( '/owncloud_private_key/owncloud.private.key', $encryptedPrivateKey );
\OC_FileProxy::$enabled = true;
}
}
/**
* @brief Sets user private key to session

@ -219,7 +219,7 @@ class Share {
}
if ($result->fetchRow()) {
$shares[] = self::SHARE_TYPE_LINK;
$shares[] = "ownCloud";
}
}

Loading…
Cancel
Save