2015-01-14 19:39:23 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-04-07 15:02:49 +00:00
|
|
|
* @author Björn Schießle <schiessle@owncloud.com>
|
2015-06-25 09:43:55 +00:00
|
|
|
* @author Lukas Reschke <lukas@owncloud.com>
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-01-14 19:39:23 +00:00
|
|
|
*
|
2015-04-07 15:02:49 +00:00
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*
|
2015-04-07 15:02:49 +00:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2015-01-14 19:39:23 +00:00
|
|
|
*
|
2015-04-07 15:02:49 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2015-01-14 19:39:23 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-04-07 15:02:49 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-01-14 19:39:23 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCP\Encryption;
|
|
|
|
|
2015-04-16 15:00:08 +00:00
|
|
|
/**
|
|
|
|
* Interface IEncryptionModule
|
|
|
|
*
|
|
|
|
* @package OCP\Encryption
|
|
|
|
* @since 8.1.0
|
|
|
|
*/
|
2015-01-14 19:39:23 +00:00
|
|
|
interface IEncryptionModule {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string defining the technical unique id
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function getId();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* In comparison to getKey() this function returns a human readable (maybe translated) name
|
|
|
|
*
|
|
|
|
* @return string
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function getDisplayName();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* start receiving chunks from a file. This is the place where you can
|
|
|
|
* perform some initial step before starting encrypting/decrypting the
|
|
|
|
* chunks
|
|
|
|
*
|
|
|
|
* @param string $path to the file
|
|
|
|
* @param string $user who read/write the file (null for public access)
|
2015-04-24 11:02:06 +00:00
|
|
|
* @param string $mode php stream open mode
|
2015-01-14 19:39:23 +00:00
|
|
|
* @param array $header contains the header data read from the file
|
|
|
|
* @param array $accessList who has access to the file contains the key 'users' and 'public'
|
|
|
|
*
|
|
|
|
* $return array $header contain data as key-value pairs which should be
|
|
|
|
* written to the header, in case of a write operation
|
|
|
|
* or if no additional data is needed return a empty array
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
2015-04-24 11:02:06 +00:00
|
|
|
public function begin($path, $user, $mode, array $header, array $accessList);
|
2015-01-14 19:39:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* last chunk received. This is the place where you can perform some final
|
|
|
|
* operation and return some remaining data if something is left in your
|
|
|
|
* buffer.
|
|
|
|
*
|
|
|
|
* @param string $path to the file
|
|
|
|
* @return string remained data which should be written to the file in case
|
|
|
|
* of a write operation
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function end($path);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* encrypt data
|
|
|
|
*
|
|
|
|
* @param string $data you want to encrypt
|
|
|
|
* @return mixed encrypted data
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function encrypt($data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* decrypt data
|
|
|
|
*
|
|
|
|
* @param string $data you want to decrypt
|
|
|
|
* @return mixed decrypted data
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function decrypt($data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* update encrypted file, e.g. give additional users access to the file
|
|
|
|
*
|
|
|
|
* @param string $path path to the file which should be updated
|
2015-03-27 10:46:32 +00:00
|
|
|
* @param string $uid of the user who performs the operation
|
2015-01-14 19:39:23 +00:00
|
|
|
* @param array $accessList who has access to the file contains the key 'users' and 'public'
|
|
|
|
* @return boolean
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
2015-04-09 12:06:55 +00:00
|
|
|
public function update($path, $uid, array $accessList);
|
2015-01-14 19:39:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* should the file be encrypted or not
|
|
|
|
*
|
|
|
|
* @param string $path
|
|
|
|
* @return boolean
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function shouldEncrypt($path);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get size of the unencrypted payload per block.
|
|
|
|
* ownCloud read/write files with a block size of 8192 byte
|
|
|
|
*
|
|
|
|
* @return integer
|
2015-04-16 15:00:08 +00:00
|
|
|
* @since 8.1.0
|
2015-01-14 19:39:23 +00:00
|
|
|
*/
|
|
|
|
public function getUnencryptedBlockSize();
|
2015-05-12 16:49:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* check if the encryption module is able to read the file,
|
|
|
|
* e.g. if all encryption keys exists
|
|
|
|
*
|
|
|
|
* @param string $path
|
|
|
|
* @param string $uid user for whom we want to check if he can read the file
|
|
|
|
* @return boolean
|
|
|
|
* @since 8.1.0
|
|
|
|
*/
|
|
|
|
public function isReadable($path, $uid);
|
|
|
|
|
2015-01-14 19:39:23 +00:00
|
|
|
}
|