Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/engine/PhabricatorFileStorageEngine.php
Show All 10 Lines | |||||
* | * | ||||
* @task construct Constructing an Engine | * @task construct Constructing an Engine | ||||
* @task meta Engine Metadata | * @task meta Engine Metadata | ||||
* @task file Managing File Data | * @task file Managing File Data | ||||
* @task load Loading Storage Engines | * @task load Loading Storage Engines | ||||
*/ | */ | ||||
abstract class PhabricatorFileStorageEngine extends Phobject { | abstract class PhabricatorFileStorageEngine extends Phobject { | ||||
const HMAC_INTEGRITY = 'file.integrity'; | |||||
/** | /** | ||||
* Construct a new storage engine. | * Construct a new storage engine. | ||||
* | * | ||||
* @task construct | * @task construct | ||||
*/ | */ | ||||
final public function __construct() { | final public function __construct() { | ||||
// <empty> | // <empty> | ||||
} | } | ||||
▲ Show 20 Lines • Show All 335 Lines • ▼ Show 20 Lines | public function getRawFileDataIterator( | ||||
return array($data); | return array($data); | ||||
} | } | ||||
public function newIntegrityHash( | public function newIntegrityHash( | ||||
$data, | $data, | ||||
PhabricatorFileStorageFormat $format) { | PhabricatorFileStorageFormat $format) { | ||||
$data_hash = PhabricatorHash::digest($data); | $hmac_name = self::HMAC_INTEGRITY; | ||||
$data_hash = PhabricatorHash::digestWithNamedKey($data, $hmac_name); | |||||
$format_hash = $format->newFormatIntegrityHash(); | $format_hash = $format->newFormatIntegrityHash(); | ||||
$full_hash = "{$data_hash}/{$format_hash}"; | $full_hash = "{$data_hash}/{$format_hash}"; | ||||
return PhabricatorHash::digest($full_hash); | return PhabricatorHash::digestWithNamedKey($full_hash, $hmac_name); | ||||
} | } | ||||
} | } |