aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash')
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHash.php87
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHashInterface.php52
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/HashUtils.php76
-rw-r--r--apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/TreeHash.php195
4 files changed, 0 insertions, 410 deletions
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHash.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHash.php
deleted file mode 100644
index c57c3e4cb07..00000000000
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHash.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-/**
- * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-namespace Aws\Common\Hash;
-
-use Aws\Common\Exception\LogicException;
-
-/**
- * Encapsulates the creation of a hash from streamed chunks of data
- */
-class ChunkHash implements ChunkHashInterface
-{
- /**
- * @var resource The hash context as created by `hash_init()`
- */
- protected $context;
-
- /**
- * @var string The resulting hash in hex form
- */
- protected $hash;
-
- /**
- * @var string The resulting hash in binary form
- */
- protected $hashRaw;
-
- /**
- * {@inheritdoc}
- */
- public function __construct($algorithm = self::DEFAULT_ALGORITHM)
- {
- HashUtils::validateAlgorithm($algorithm);
- $this->context = hash_init($algorithm);
- }
-
- /**
- * {@inheritdoc}
- */
- public function addData($data)
- {
- if (!$this->context) {
- throw new LogicException('You may not add more data to a finalized chunk hash.');
- }
-
- hash_update($this->context, $data);
-
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getHash($returnBinaryForm = false)
- {
- if (!$this->hash) {
- $this->hashRaw = hash_final($this->context, true);
- $this->hash = HashUtils::binToHex($this->hashRaw);
- $this->context = null;
- }
-
- return $returnBinaryForm ? $this->hashRaw : $this->hash;
- }
-
- /**
- * {@inheritdoc}
- */
- public function __clone()
- {
- if ($this->context) {
- $this->context = hash_copy($this->context);
- }
- }
-}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHashInterface.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHashInterface.php
deleted file mode 100644
index 5fcf9a56436..00000000000
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/ChunkHashInterface.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-/**
- * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-namespace Aws\Common\Hash;
-
-/**
- * Interface for objects that encapsulate the creation of a hash from streamed chunks of data
- */
-interface ChunkHashInterface
-{
- const DEFAULT_ALGORITHM = 'sha256';
-
- /**
- * Constructs the chunk hash and sets the algorithm to use for hashing
- *
- * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
- *
- * @return self
- */
- public function __construct($algorithm = 'sha256');
-
- /**
- * Add a chunk of data to be hashed
- *
- * @param string $data Data to be hashed
- *
- * @return self
- */
- public function addData($data);
-
- /**
- * Return the results of the hash
- *
- * @param bool $returnBinaryForm If true, returns the hash in binary form instead of hex form
- *
- * @return string
- */
- public function getHash($returnBinaryForm = false);
-}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/HashUtils.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/HashUtils.php
deleted file mode 100644
index f66af6edf53..00000000000
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/HashUtils.php
+++ /dev/null
@@ -1,76 +0,0 @@
-<?php
-/**
- * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-namespace Aws\Common\Hash;
-
-use Aws\Common\Exception\InvalidArgumentException;
-
-/**
- * Contains hashing utilities
- */
-class HashUtils
-{
- /**
- * Converts a hash in hex form to binary form
- *
- * @param string $hash Hash in hex form
- *
- * @return string Hash in binary form
- */
- public static function hexToBin($hash)
- {
- // If using PHP 5.4, there is a native function to convert from hex to binary
- static $useNative;
- if ($useNative === null) {
- $useNative = function_exists('hex2bin');
- }
-
- if (!$useNative && strlen($hash) % 2 !== 0) {
- $hash = '0' . $hash;
- }
-
- return $useNative ? hex2bin($hash) : pack("H*", $hash);
- }
-
- /**
- * Converts a hash in binary form to hex form
- *
- * @param string $hash Hash in binary form
- *
- * @return string Hash in hex form
- */
- public static function binToHex($hash)
- {
- return bin2hex($hash);
- }
-
- /**
- * Checks if the algorithm specified exists and throws an exception if it does not
- *
- * @param string $algorithm Name of the algorithm to validate
- *
- * @return bool
- * @throws InvalidArgumentException if the algorithm doesn't exist
- */
- public static function validateAlgorithm($algorithm)
- {
- if (!in_array($algorithm, hash_algos(), true)) {
- throw new InvalidArgumentException("The hashing algorithm specified ({$algorithm}) does not exist.");
- }
-
- return true;
- }
-}
diff --git a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/TreeHash.php b/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/TreeHash.php
deleted file mode 100644
index 26ce69286c0..00000000000
--- a/apps/files_external/3rdparty/aws-sdk-php/Aws/Common/Hash/TreeHash.php
+++ /dev/null
@@ -1,195 +0,0 @@
-<?php
-/**
- * Copyright 2010-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-namespace Aws\Common\Hash;
-
-use Aws\Common\Enum\Size;
-use Aws\Common\Exception\InvalidArgumentException;
-use Aws\Common\Exception\LogicException;
-use Guzzle\Http\EntityBody;
-
-/**
- * Encapsulates the creation of a tree hash from streamed chunks of data
- */
-class TreeHash implements ChunkHashInterface
-{
- /**
- * @var string The algorithm used for hashing
- */
- protected $algorithm;
-
- /**
- * @var array Set of binary checksums from which the tree hash is derived
- */
- protected $checksums = array();
-
- /**
- * @var string The resulting hash in hex form
- */
- protected $hash;
-
- /**
- * @var string The resulting hash in binary form
- */
- protected $hashRaw;
-
- /**
- * Create a tree hash from an array of existing tree hash checksums
- *
- * @param array $checksums Set of checksums
- * @param bool $inBinaryForm Whether or not the checksums are already in binary form
- * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
- *
- * @return TreeHash
- */
- public static function fromChecksums(array $checksums, $inBinaryForm = false, $algorithm = self::DEFAULT_ALGORITHM)
- {
- $treeHash = new self($algorithm);
-
- // Convert checksums to binary form if provided in hex form and add them to the tree hash
- $treeHash->checksums = $inBinaryForm ? $checksums : array_map('Aws\Common\Hash\HashUtils::hexToBin', $checksums);
-
- // Pre-calculate hash
- $treeHash->getHash();
-
- return $treeHash;
- }
-
- /**
- * Create a tree hash from a content body
- *
- * @param string|resource|EntityBody $content Content to create a tree hash for
- * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
- *
- * @return TreeHash
- */
- public static function fromContent($content, $algorithm = self::DEFAULT_ALGORITHM)
- {
- $treeHash = new self($algorithm);
-
- // Read the data in 1MB chunks and add to tree hash
- $content = EntityBody::factory($content);
- while ($data = $content->read(Size::MB)) {
- $treeHash->addData($data);
- }
-
- // Pre-calculate hash
- $treeHash->getHash();
-
- return $treeHash;
- }
-
- /**
- * Validates an entity body with a tree hash checksum
- *
- * @param string|resource|EntityBody $content Content to create a tree hash for
- * @param string $checksum The checksum to use for validation
- * @param string $algorithm A valid hash algorithm name as returned by `hash_algos()`
- *
- * @return bool
- */
- public static function validateChecksum($content, $checksum, $algorithm = self::DEFAULT_ALGORITHM)
- {
- $treeHash = self::fromContent($content, $algorithm);
-
- return ($checksum === $treeHash->getHash());
- }
-
- /**
- * {@inheritdoc}
- */
- public function __construct($algorithm = self::DEFAULT_ALGORITHM)
- {
- HashUtils::validateAlgorithm($algorithm);
- $this->algorithm = $algorithm;
- }
-
- /**
- * {@inheritdoc}
- * @throws LogicException if the root tree hash is already calculated
- * @throws InvalidArgumentException if the data is larger than 1MB
- */
- public function addData($data)
- {
- // Error if hash is already calculated
- if ($this->hash) {
- throw new LogicException('You may not add more data to a finalized tree hash.');
- }
-
- // Make sure that only 1MB chunks or smaller get passed in
- if (strlen($data) > Size::MB) {
- throw new InvalidArgumentException('The chunk of data added is too large for tree hashing.');
- }
-
- // Store the raw hash of this data segment
- $this->checksums[] = hash($this->algorithm, $data, true);
-
- return $this;
- }
-
- /**
- * Add a checksum to the tree hash directly
- *
- * @param string $checksum The checksum to add
- * @param bool $inBinaryForm Whether or not the checksum is already in binary form
- *
- * @return self
- * @throws LogicException if the root tree hash is already calculated
- */
- public function addChecksum($checksum, $inBinaryForm = false)
- {
- // Error if hash is already calculated
- if ($this->hash) {
- throw new LogicException('You may not add more checksums to a finalized tree hash.');
- }
-
- // Convert the checksum to binary form if necessary
- $this->checksums[] = $inBinaryForm ? $checksum : HashUtils::hexToBin($checksum);
-
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getHash($returnBinaryForm = false)
- {
- if (!$this->hash) {
- // Perform hashes up the tree to arrive at the root checksum of the tree hash
- $hashes = $this->checksums;
- while (count($hashes) > 1) {
- $sets = array_chunk($hashes, 2);
- $hashes = array();
- foreach ($sets as $set) {
- $hashes[] = (count($set) === 1) ? $set[0] : hash($this->algorithm, $set[0] . $set[1], true);
- }
- }
-
- $this->hashRaw = $hashes[0];
- $this->hash = HashUtils::binToHex($this->hashRaw);
- }
-
- return $returnBinaryForm ? $this->hashRaw : $this->hash;
- }
-
- /**
- * @return array Array of raw checksums composing the tree hash
- */
- public function getChecksums()
- {
- return $this->checksums;
- }
-}