Get IFF signature from data string

@param string|bool $data Image data string

@return false|string Signature if file is a valid IFF file, false if not
15819
protected function getIffSignature($data)
	{
		$signature = substr($data, 0, self::LONG_SIZE);

		// Check if image is IFF
		if ($signature !== self::IFF_HEADER_AMIGA && $signature !== self::IFF_HEADER_MAYA)
		{
			return false;
		}
		else
		{
			return $signature;
		}
	}
1062060
protected static function _signature($data, $secret = null) {
		unset($data['__signature']);
		$secret = ($secret) ?: static::$_secret;
		return hash_hmac('sha1', serialize($data), $secret);
	}
1086059
protected function invalidPayload($data)
    {
        return ! is_array($data) || ! isset($data['iv']) || ! isset($data['value']) || ! isset($data['mac']);
    }
190447
public static function type($data = false) {

        if ($data) {

            $dataType = gettype($data);

            if ($dataType === 'string') {

                if (Validate::isJson($data)) {
                    $dataType = 'json';
                }
            }

            return $dataType;
        }

        return false;
    }
250469
public function setFromData ($data)
	{
		// Check signature
		$model = $this;

		$chk = self::CHECK_SIGNATURE;

		if ($chk && !isset ($data['signature']))
		{
			throw new InvalidParameter ("All decoded requests must have a signature.");
		}

		if ($chk && $data['signature'] != self::calculateSignature ($data))
		{
			throw new InvalidParameter ("Leave now, and Never come Back! *gollem, gollem* (Decoded request signature mismatch).");
		}

		// The body. If data is found, body is not used.
		if (isset ($data['data']) && !empty ($data['data']))
		{
			$model->setData ($data['data']);
		}

		else if (isset ($data['body']))
		{
			$model->setBody ($data['body']);
		}

		if (isset ($data['headers']))
		{
			$model->setHeaders ($data['headers']);
		}

		if (isset ($data['cookies']))
		{
			$model->setCookies ($data['cookies']);
		}

		if (isset ($data['post']))
		{
			$model->setPost ($data['post']);
		}

		if (isset ($data['status']))
		{
			$model->setStatus ($data['status']);
		}

		return $model;
	}
1208989
private function validate($data)
    {
        // null or zero-length values cannot be assigned references
        if (is_null($data) || (is_string($data) && !strlen($data))) {
            return false;
        }

        return true;
    }
921238
public static function image_content_type($data)
    {
        $type = 'jpeg';
        if      (preg_match('/^\x89\x50\x4E\x47/', $data)) $type = 'png';
        else if (preg_match('/^\x47\x49\x46\x38/', $data)) $type = 'gif';
        else if (preg_match('/^\x00\x00\x01\x00/', $data)) $type = 'ico';
    //  else if (preg_match('/^\xFF\xD8\xFF\xE0/', $data)) $type = 'jpeg';

        return 'image/' . $type;
    }
1137460
public static function maybeUn($data)
    {
        // If it isn't a string, it isn't serialized
        if (!is_string($data)) {
            return $data;
        }

        $data = trim($data);

        // Is it the serialized NULL value?
        if ($data === 'N;') {
            return null;
        }

        $length = strlen($data);

        // Check some basic requirements of all serialized strings
        if (self::checkBasic($data, $length)) {
            return $data;
        }

        // $data is the serialized false value
        if ($data === 'b:0;') {
            return false;
        }

        // Don't attempt to unserialize data that isn't serialized
        $uns = @unserialize($data, []);

        // Data failed to unserialize?
        if ($uns === false) {
            $uns = @unserialize(self::fix($data), []);

            if ($uns === false) {
                return $data;
            }
            return $uns;
        }

        return $uns;
    }
570581
private function verifyPHPECCSignature(JWKInterface $key, $data, $R, $S)
    {
        $p = $this->getGenerator();
        $x = $this->convertBase64ToGmp($key->get('x'));
        $y = $this->convertBase64ToGmp($key->get('y'));
        $hash = $this->convertHexToGmp(hash($this->getHashAlgorithm(), $data));

        $public_key = $p->getPublicKeyFrom($x, $y);

        $signer = EccFactory::getSigner();

        return $signer->verify(
            $public_key,
            new Signature(
                $this->convertHexToGmp($R),
                $this->convertHexToGmp($S)
            ),
            $hash
        );
    }
1237931
public function verifySign($data = '', $sign = '')
    {
        if (!is_string($sign) || !is_string($sign)) {
            return false;
        }
        return (bool)openssl_verify(
                      $data,
                      base64_decode($sign),
                      self::getPublicKey(),
                      OPENSSL_ALGO_SHA256
                    );
    }
501530
public function init($data)
    {
        $this->data = $data;

        switch (true) {

            case $this->isGdResource():
                return $this->initFromGdResource($this->data);

            case $this->isImagick():
                return $this->initFromImagick($this->data);

            case $this->isInterventionImage():
                return $this->initFromInterventionImage($this->data);

            case $this->isSplFileInfo():
                return $this->initFromPath($this->data->getRealPath());

            case $this->isBinary():
                return $this->initFromBinary($this->data);

            case $this->isUrl():
                return $this->initFromUrl($this->data);

            case $this->isStream():
                return $this->initFromStream($this->data);

            case $this->isDataUrl():
                return $this->initFromBinary($this->decodeDataUrl($this->data));

            case $this->isFilePath():
                return $this->initFromPath($this->data);

            // isBase64 has to be after isFilePath to prevent false positives
            case $this->isBase64():
                return $this->initFromBinary(base64_decode($this->data));

            default:
                throw new Exception\NotReadableException("Image source not readable");
        }
    }
907667
public function json($data)
    {
        if (isset($data['url']) && ! empty($data['url'])) {
            $result = @file_get_contents($data['url']);
            $result = json_decode($result, true);
        }
        return isset($result) ? $result : null;
    }
223132
public function checkResponseIntegrity(array $data)
    {
        if (!isset($data['signature'])) {
            return false;
        }

        return $data['vads_site_id'] === (string)$this->config['site_id']
            && $data['vads_ctx_mode'] === (string)$this->config['ctx_mode']
            && $data['signature'] === $this->generateSignature($data);
    }
51010
private function getPHPECCSignature(JWKInterface $key, $data)
    {
        $p = $this->getGenerator();
        $d = $this->convertBase64ToGmp($key->get('d'));
        $hash = $this->convertHexToGmp(hash($this->getHashAlgorithm(), $data));

        $k = RandomGeneratorFactory::getRandomGenerator()->generate($p->getOrder());

        $signer = EccFactory::getSigner();

        $private_key = $p->getPrivateKeyFrom($d);
        $signature = $signer->sign($private_key, $hash, $k);

        $part_length = $this->getSignaturePartLength();

        $R = str_pad($this->convertDecToHex($signature->getR()), $part_length, '0', STR_PAD_LEFT);
        $S = str_pad($this->convertDecToHex($signature->getS()), $part_length, '0', STR_PAD_LEFT);

        return $this->convertHexToBin($R.$S);
    }
744491
protected function isValidIco($data)
	{
		// Get header
		$header = unpack('vreserved/vtype/vimages', $data);

		return $header['reserved'] === self::ICO_RESERVED && $header['type'] === self::ICO_TYPE && $header['images'] > 0 && $header['images'] <= 255;
	}
742056
public function get($data)
    {
        if (isset($data['url']) && ! empty($data['url'])) {
            $result = @file_get_contents($data['url']);
        }
        
        return isset($result) ? $result : null;
    }
966801
private function isRemoteImage(array $data)
    {
        return isset($data['image']['file']) && is_string($data['image']['file']) &&
            (!strncasecmp('http://', $data['image']['file'], 7) || !strncasecmp('https://', $data['image']['file'], 8));
    }