]> source.dussan.org Git - nextcloud-server.git/commitdiff
make methods private which are not used from outside
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 8 Aug 2013 06:37:39 +0000 (08:37 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Thu, 8 Aug 2013 06:37:39 +0000 (08:37 +0200)
apps/files_encryption/lib/crypt.php

index 6543a0de5f3b94b8a059e0bf01f1b1a32260041d..34051db6a214212586bbeb87be549f5a785b44b8 100755 (executable)
  *\r
  */\r
 \r
+/*\r
+ * TODO: Check if methods really need to be public\r
+ */\r
+\r
 namespace OCA\Encryption;\r
 \r
 //require_once '../3rdparty/Crypt_Blowfish/Blowfish.php';\r
@@ -84,7 +88,7 @@ class Crypt {
         * blocks with encryption alone, hence padding is added to achieve the\r
         * required length.\r
         */\r
-       public static function addPadding($data) {\r
+       private static function addPadding($data) {\r
 \r
                $padded = $data . 'xx';\r
 \r
@@ -97,7 +101,7 @@ class Crypt {
         * @param string $padded padded data to remove padding from\r
         * @return string unpadded data on success, false on error\r
         */\r
-       public static function removePadding($padded) {\r
+       private static function removePadding($padded) {\r
 \r
                if (substr($padded, -2) === 'xx') {\r
 \r
@@ -205,7 +209,7 @@ class Crypt {
         * @param string $passphrase\r
         * @return string encrypted file content\r
         */\r
-       public static function encrypt($plainContent, $iv, $passphrase = '') {\r
+       private static function encrypt($plainContent, $iv, $passphrase = '') {\r
 \r
                if ($encryptedContent = openssl_encrypt($plainContent, 'AES-128-CFB', $passphrase, false, $iv)) {\r
                        return $encryptedContent;\r
@@ -226,7 +230,7 @@ class Crypt {
         * @throws \Exception\r
         * @return string decrypted file content\r
         */\r
-       public static function decrypt($encryptedContent, $iv, $passphrase) {\r
+       private static function decrypt($encryptedContent, $iv, $passphrase) {\r
 \r
                if ($plainContent = openssl_decrypt($encryptedContent, 'AES-128-CFB', $passphrase, false, $iv)) {\r
 \r
@@ -246,7 +250,7 @@ class Crypt {
         * @param string $iv IV to be concatenated\r
         * @returns string concatenated content\r
         */\r
-       public static function concatIv($content, $iv) {\r
+       private static function concatIv($content, $iv) {\r
 \r
                $combined = $content . '00iv00' . $iv;\r
 \r
@@ -259,7 +263,7 @@ class Crypt {
         * @param string $catFile concatenated data to be split\r
         * @returns array keys: encrypted, iv\r
         */\r
-       public static function splitIv($catFile) {\r
+       private static function splitIv($catFile) {\r
 \r
                // Fetch encryption metadata from end of file\r
                $meta = substr($catFile, -22);\r
@@ -376,34 +380,6 @@ class Crypt {
 \r
        }\r
 \r
-\r
-       /**\r
-        * @brief Creates symmetric keyfile content using a generated key\r
-        * @param string $plainContent content to be encrypted\r
-        * @returns array keys: key, encrypted\r
-        * @note symmetricDecryptFileContent() can be used to decrypt files created using this method\r
-        *\r
-        * This function decrypts a file\r
-        */\r
-       public static function symmetricEncryptFileContentKeyfile($plainContent) {\r
-\r
-               $key = self::generateKey();\r
-\r
-               if ($encryptedContent = self::symmetricEncryptFileContent($plainContent, $key)) {\r
-\r
-                       return array(\r
-                               'key' => $key,\r
-                               'encrypted' => $encryptedContent\r
-                       );\r
-\r
-               } else {\r
-\r
-                       return false;\r
-\r
-               }\r
-\r
-       }\r
-\r
        /**\r
         * @brief Create asymmetrically encrypted keyfile content using a generated key\r
         * @param string $plainContent content to be encrypted\r
@@ -486,43 +462,11 @@ class Crypt {
 \r
        }\r
 \r
-       /**\r
-        * @brief Asymetrically encrypt a string using a public key\r
-        * @param $plainContent\r
-        * @param $publicKey\r
-        * @return string encrypted file\r
-        */\r
-       public static function keyEncrypt($plainContent, $publicKey) {\r
-\r
-               openssl_public_encrypt($plainContent, $encryptedContent, $publicKey);\r
-\r
-               return $encryptedContent;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief Asymetrically decrypt a file using a private key\r
-        * @param $encryptedContent\r
-        * @param $privatekey\r
-        * @return string decrypted file\r
-        */\r
-       public static function keyDecrypt($encryptedContent, $privatekey) {\r
-\r
-               $result = @openssl_private_decrypt($encryptedContent, $plainContent, $privatekey);\r
-\r
-               if ($result) {\r
-                       return $plainContent;\r
-               }\r
-\r
-               return $result;\r
-\r
-       }\r
-\r
        /**\r
         * @brief Generates a pseudo random initialisation vector\r
         * @return String $iv generated IV\r
         */\r
-       public static function generateIv() {\r
+       private static function generateIv() {\r
 \r
                if ($random = openssl_random_pseudo_bytes(12, $strong)) {\r
 \r
@@ -548,7 +492,7 @@ class Crypt {
        }\r
 \r
        /**\r
-        * @brief Generate a pseudo random 1024kb ASCII key\r
+        * @brief Generate a pseudo random 1024kb ASCII key, used as file key\r
         * @returns $key Generated key\r
         */\r
        public static function generateKey() {\r
@@ -580,7 +524,7 @@ class Crypt {
         *\r
         * if the key is left out, the default handeler will be used\r
         */\r
-       public static function getBlowfish($key = '') {\r
+       private static function getBlowfish($key = '') {\r
 \r
                if ($key) {\r
 \r
@@ -594,38 +538,6 @@ class Crypt {
 \r
        }\r
 \r
-       /**\r
-        * @param $passphrase\r
-        * @return mixed\r
-        */\r
-       public static function legacyCreateKey($passphrase) {\r
-\r
-               // Generate a random integer\r
-               $key = mt_rand(10000, 99999) . mt_rand(10000, 99999) . mt_rand(10000, 99999) . mt_rand(10000, 99999);\r
-\r
-               // Encrypt the key with the passphrase\r
-               $legacyEncKey = self::legacyEncrypt($key, $passphrase);\r
-\r
-               return $legacyEncKey;\r
-\r
-       }\r
-\r
-       /**\r
-        * @brief encrypts content using legacy blowfish system\r
-        * @param string $content the cleartext message you want to encrypt\r
-        * @param string $passphrase\r
-        * @returns string encrypted content\r
-        *\r
-        * This function encrypts an content\r
-        */\r
-       public static function legacyEncrypt($content, $passphrase = '') {\r
-\r
-               $bf = self::getBlowfish($passphrase);\r
-\r
-               return $bf->encrypt($content);\r
-\r
-       }\r
-\r
        /**\r
         * @brief decrypts content using legacy blowfish system\r
         * @param string $content the cleartext message you want to decrypt\r