aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/crypt.php
diff options
context:
space:
mode:
authorBjörn Schießle <schiessle@owncloud.com>2013-05-17 14:13:05 +0200
committerBjörn Schießle <schiessle@owncloud.com>2013-05-17 14:13:05 +0200
commit93771f735b2347eb851941a414220af7b6ccd066 (patch)
tree3a1b378f0b46fecc69ff23cc8630718675d630b0 /apps/files_encryption/lib/crypt.php
parentbf04a21973b2ca88ea35cca3261a0f415cc36559 (diff)
downloadnextcloud-server-93771f735b2347eb851941a414220af7b6ccd066.tar.gz
nextcloud-server-93771f735b2347eb851941a414220af7b6ccd066.zip
gremove unused code
Diffstat (limited to 'apps/files_encryption/lib/crypt.php')
-rwxr-xr-xapps/files_encryption/lib/crypt.php68
1 files changed, 9 insertions, 59 deletions
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index 74f8a1ffa3b..708d1719d73 100755
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -472,61 +472,7 @@ class Crypt {
return $result;
}
-
- /**
- * @brief Encrypts content symmetrically and generates keyfile asymmetrically
- * @returns array containing catfile and new keyfile.
- * keys: data, key
- * @note this method is a wrapper for combining other crypt class methods
- */
- public static function keyEncryptKeyfile( $plainContent, $publicKey, $path ) {
-
- $user = \OCP\User::getUser();
- $view = new \OC_FilesystemView('/');
- $util = new Util($view, $user);
-
- // Encrypt plain data, generate keyfile & encrypted file
- $cryptedData = self::symmetricEncryptFileContentKeyfile( $plainContent );
-
- // Encrypt keyfile
-
- $sharingEnabled = \OCP\Share::isEnabled();
-
- // if file exists try to get sharing users
- if($view->file_exists($path)) {
- $uniqueUserIds = $util->getSharingUsersArray( $sharingEnabled, $path, $user );
- } else {
- $uniqueUserIds[] = $user;
- }
-
- // Fetch public keys for all users who will share the file
- $publicKeys = Keymanager::getPublicKeys( $view, $uniqueUserIds );
-
- // Encrypt plain keyfile to multiple sharefiles
- $multiEncrypted = Crypt::multiKeyEncrypt( $cryptedData['key'], $publicKeys );
-
- return array( 'data' => $cryptedData['encrypted'], 'filekey' => $multiEncrypted['data'], 'sharekeys' => $multiEncrypted['keys'] );
-
- }
-
- /**
- * @brief Takes catfile, keyfile, and private key, and
- * performs decryption
- * @returns decrypted content
- * @note this method is a wrapper for combining other crypt class methods
- */
- public static function keyDecryptKeyfile( $catfile, $keyfile, $privateKey ) {
-
- // Decrypt the keyfile with the user's private key
- $decryptedKeyfile = self::keyDecrypt( $keyfile, $privateKey );
- // Decrypt the catfile symmetrically using the decrypted keyfile
- $decryptedData = self::symmetricDecryptFileContent( $catfile, $decryptedKeyfile );
-
- return $decryptedData;
-
- }
-
/**
* @brief Symmetrically encrypt a file by combining encrypted component data blocks
*/
@@ -743,13 +689,17 @@ class Crypt {
}
- public static function legacyKeyRecryptKeyfile( $legacyEncryptedContent, $legacyPassphrase, $publicKey, $newPassphrase, $path ) {
+ public static function legacyKeyRecryptKeyfile( $legacyEncryptedContent, $legacyPassphrase, $publicKeys, $newPassphrase, $path ) {
$decrypted = self::legacyDecrypt( $legacyEncryptedContent, $legacyPassphrase );
-
- $recrypted = self::keyEncryptKeyfile( $decrypted, $publicKey, $path );
-
- return $recrypted;
+
+ // Encrypt plain data, generate keyfile & encrypted file
+ $cryptedData = self::symmetricEncryptFileContentKeyfile( $decrypted );
+
+ // Encrypt plain keyfile to multiple sharefiles
+ $multiEncrypted = Crypt::multiKeyEncrypt( $cryptedData['key'], $publicKeys );
+
+ return array( 'data' => $cryptedData['encrypted'], 'filekey' => $multiEncrypted['data'], 'sharekeys' => $multiEncrypted['keys'] );
}