summaryrefslogtreecommitdiffstats
path: root/apps/files_encryption
diff options
context:
space:
mode:
authorFelix Moeller <mail@felixmoeller.de>2012-10-28 23:58:08 +0100
committerFelix Moeller <mail@felixmoeller.de>2012-10-28 23:58:08 +0100
commitdfc8228fb47220e9fe107368da2ebd5da79e780a (patch)
treefb9ee5821bb9d1ca1058336d796a5d00de3a9cb5 /apps/files_encryption
parente5a74903e453e0628a1544ddc37ee05454a38462 (diff)
downloadnextcloud-server-dfc8228fb47220e9fe107368da2ebd5da79e780a.tar.gz
nextcloud-server-dfc8228fb47220e9fe107368da2ebd5da79e780a.zip
NoSpaceAfterComma
Diffstat (limited to 'apps/files_encryption')
-rw-r--r--apps/files_encryption/lib/crypt.php20
-rw-r--r--apps/files_encryption/lib/cryptstream.php42
2 files changed, 31 insertions, 31 deletions
diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php
index d057c1ed194..28bf3c5c93e 100644
--- a/apps/files_encryption/lib/crypt.php
+++ b/apps/files_encryption/lib/crypt.php
@@ -40,7 +40,7 @@ class OC_Crypt {
static private $bf = null;
public static function loginListener($params) {
- self::init($params['uid'],$params['password']);
+ self::init($params['uid'], $params['password']);
}
public static function init($login,$password) {
@@ -51,7 +51,7 @@ class OC_Crypt {
OC_FileProxy::$enabled=false;
if(!$view->file_exists('/'.$login.'/encryption.key')) {// does key exist?
- OC_Crypt::createkey($login,$password);
+ OC_Crypt::createkey($login, $password);
}
$key=$view->file_get_contents('/'.$login.'/encryption.key');
OC_FileProxy::$enabled=true;
@@ -82,16 +82,16 @@ class OC_Crypt {
public static function createkey($username,$passcode) {
// generate a random key
- $key=mt_rand(10000,99999).mt_rand(10000,99999).mt_rand(10000,99999).mt_rand(10000,99999);
+ $key=mt_rand(10000, 99999).mt_rand(10000, 99999).mt_rand(10000, 99999).mt_rand(10000, 99999);
// encrypt the key with the passcode of the user
- $enckey=OC_Crypt::encrypt($key,$passcode);
+ $enckey=OC_Crypt::encrypt($key, $passcode);
// Write the file
$proxyEnabled=OC_FileProxy::$enabled;
OC_FileProxy::$enabled=false;
$view=new OC_FilesystemView('/'.$username);
- $view->file_put_contents('/encryption.key',$enckey);
+ $view->file_put_contents('/encryption.key', $enckey);
OC_FileProxy::$enabled=$proxyEnabled;
}
@@ -195,8 +195,8 @@ class OC_Crypt {
public static function blockEncrypt($data, $key='') {
$result='';
while(strlen($data)) {
- $result.=self::encrypt(substr($data,0,8192),$key);
- $data=substr($data,8192);
+ $result.=self::encrypt(substr($data, 0, 8192),$key);
+ $data=substr($data, 8192);
}
return $result;
}
@@ -207,11 +207,11 @@ class OC_Crypt {
public static function blockDecrypt($data, $key='',$maxLength=0) {
$result='';
while(strlen($data)) {
- $result.=self::decrypt(substr($data,0,8192),$key);
- $data=substr($data,8192);
+ $result.=self::decrypt(substr($data, 0, 8192),$key);
+ $data=substr($data, 8192);
}
if($maxLength>0) {
- return substr($result,0,$maxLength);
+ return substr($result, 0, $maxLength);
}else{
return rtrim($result, "\0");
}
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php
index 95b58b8cce7..0dd2d4b7b1e 100644
--- a/apps/files_encryption/lib/cryptstream.php
+++ b/apps/files_encryption/lib/cryptstream.php
@@ -40,7 +40,7 @@ class OC_CryptStream{
if(!self::$rootView) {
self::$rootView=new OC_FilesystemView('');
}
- $path=str_replace('crypt://','',$path);
+ $path=str_replace('crypt://', '', $path);
if(dirname($path)=='streams' and isset(self::$sourceStreams[basename($path)])) {
$this->source=self::$sourceStreams[basename($path)]['stream'];
$this->path=self::$sourceStreams[basename($path)]['path'];
@@ -50,13 +50,13 @@ class OC_CryptStream{
if($mode=='w' or $mode=='w+' or $mode=='wb' or $mode=='wb+') {
$this->size=0;
}else{
- $this->size=self::$rootView->filesize($path,$mode);
+ $this->size=self::$rootView->filesize($path, $mode);
}
OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file
- $this->source=self::$rootView->fopen($path,$mode);
+ $this->source=self::$rootView->fopen($path, $mode);
OC_FileProxy::$enabled=true;
if(!is_resource($this->source)) {
- OCP\Util::writeLog('files_encryption','failed to open '.$path,OCP\Util::ERROR);
+ OCP\Util::writeLog('files_encryption', 'failed to open '.$path, OCP\Util::ERROR);
}
}
if(is_resource($this->source)) {
@@ -67,7 +67,7 @@ class OC_CryptStream{
public function stream_seek($offset, $whence=SEEK_SET) {
$this->flush();
- fseek($this->source,$offset,$whence);
+ fseek($this->source, $offset, $whence);
}
public function stream_tell() {
@@ -79,11 +79,11 @@ class OC_CryptStream{
//This makes this function a lot simpler but will breake everything the moment it's fixed
$this->writeCache='';
if($count!=8192) {
- OCP\Util::writeLog('files_encryption','php bug 21641 no longer holds, decryption will not work',OCP\Util::FATAL);
+ OCP\Util::writeLog('files_encryption', 'php bug 21641 no longer holds, decryption will not work', OCP\Util::FATAL);
die();
}
$pos=ftell($this->source);
- $data=fread($this->source,8192);
+ $data=fread($this->source, 8192);
if(strlen($data)) {
$result=OC_Crypt::decrypt($data);
}else{
@@ -91,7 +91,7 @@ class OC_CryptStream{
}
$length=$this->size-$pos;
if($length<8192) {
- $result=substr($result,0,$length);
+ $result=substr($result, 0, $length);
}
return $result;
}
@@ -105,12 +105,12 @@ class OC_CryptStream{
}
if($currentPos%8192!=0) {
//make sure we always start on a block start
- fseek($this->source,-($currentPos%8192),SEEK_CUR);
+ fseek($this->source, -($currentPos%8192), SEEK_CUR);
$encryptedBlock=fread($this->source,8192);
- fseek($this->source,-($currentPos%8192),SEEK_CUR);
+ fseek($this->source, -($currentPos%8192), SEEK_CUR);
$block=OC_Crypt::decrypt($encryptedBlock);
- $data=substr($block,0,$currentPos%8192).$data;
- fseek($this->source,-($currentPos%8192),SEEK_CUR);
+ $data=substr($block, 0, $currentPos%8192).$data;
+ fseek($this->source, -($currentPos%8192), SEEK_CUR);
}
$currentPos=ftell($this->source);
while($remainingLength=strlen($data)>0) {
@@ -118,9 +118,9 @@ class OC_CryptStream{
$this->writeCache=$data;
$data='';
}else{
- $encrypted=OC_Crypt::encrypt(substr($data,0,8192));
- fwrite($this->source,$encrypted);
- $data=substr($data,8192);
+ $encrypted=OC_Crypt::encrypt(substr($data, 0, 8192));
+ fwrite($this->source, $encrypted);
+ $data=substr($data, 8192);
}
}
$this->size=max($this->size,$currentPos+$length);
@@ -130,13 +130,13 @@ class OC_CryptStream{
public function stream_set_option($option,$arg1,$arg2) {
switch($option) {
case STREAM_OPTION_BLOCKING:
- stream_set_blocking($this->source,$arg1);
+ stream_set_blocking($this->source, $arg1);
break;
case STREAM_OPTION_READ_TIMEOUT:
- stream_set_timeout($this->source,$arg1,$arg2);
+ stream_set_timeout($this->source, $arg1, $arg2);
break;
case STREAM_OPTION_WRITE_BUFFER:
- stream_set_write_buffer($this->source,$arg1,$arg2);
+ stream_set_write_buffer($this->source, $arg1, $arg2);
}
}
@@ -145,7 +145,7 @@ class OC_CryptStream{
}
public function stream_lock($mode) {
- flock($this->source,$mode);
+ flock($this->source, $mode);
}
public function stream_flush() {
@@ -159,7 +159,7 @@ class OC_CryptStream{
private function flush() {
if($this->writeCache) {
$encrypted=OC_Crypt::encrypt($this->writeCache);
- fwrite($this->source,$encrypted);
+ fwrite($this->source, $encrypted);
$this->writeCache='';
}
}
@@ -167,7 +167,7 @@ class OC_CryptStream{
public function stream_close() {
$this->flush();
if($this->meta['mode']!='r' and $this->meta['mode']!='rb') {
- OC_FileCache::put($this->path, array('encrypted'=>true,'size'=>$this->size),'');
+ OC_FileCache::put($this->path, array('encrypted'=>true, 'size'=>$this->size), '');
}
return fclose($this->source);
}