Returns the signature from given data

@param array $header
@param string $data

@return Signature
498287
protected function parseSignature(array $header, $data)
    {
        if ($data == '' || !isset($header['alg']) || $header['alg'] == 'none') {
            return null;
        }

        $hash = $this->deserializer->fromBase64URL($data);

        return new Signature($hash);
    }
269447
public function generate($method, $url, array $data = [], array $headers = [], $basicAuthCredentials = '')
    {
        $signatureParts = [$method, $url];
        $signatureParts[] = http_build_query($data);
        $signatureParts[] = http_build_query($headers);
        $signatureParts[] = $basicAuthCredentials;

        return implode('|', $signatureParts);
    }
1100840
private function createSignatureDataFromHeaders(ResponseInterface $response)
    {
        $signatureData = $response->getStatusCode();
        $signatureData .= $this->convertHeadersToSignatureData($response);
        $signatureData .= "\n\n";
        $signatureData .= (string)$response->getBody();

        return $signatureData;
    }
181322
protected function findHeader(array $headers): string
    {
        $signature = '';
        foreach ($headers as $header) {
            if ($this->request->hasHeader($header)) {
                $value = $this->request->getHeader($header);
                $value = array_shift($value);
                if ($value !== null) {
                    $signature = $value;
                    continue;
                }
            }
        }

        return $signature;
    }
661071
private static function _checkChunk($data, $header, $rn = "\r\n") {
    if (isset($header['Transfer-Encoding'])) {
      $lrn = strlen($rn);
      $p = strpos($data, $rn, 0);
      $len = hexdec(substr($data, 0, $p));
      $data = substr($data, $p + 2, $len);
    }
    return $data;
  }
1151181
public function createUsingTemporaryToken(array $data, array $headers = [])
    {
        $url = $this->url('payment_sources/create_using_temp_token');

        return $this->post($url, $data, $headers);
    }
412714
public function verifySignature(array $data)
    {
        $signedData = array_intersect_key($data, array_flip(self::$validResponseParams));
        ksort($signedData);

        $queryString = $this->buildQueryString($signedData);
        $signature = base64_encode(hash_hmac('sha1', $queryString, $this->clientSecret, true));

        return hash_equals($signature, $data['h']);
    }
535644
public function getSignature($users, $data)
    {
        //make user siggy
        $userArray = array(
            $data['username'],
            $this->realm,
            $users[$data['username']]);
        
        $userSignature = md5(implode(':', $userArray));
        
        //make request siggy
        $requestArray = array(
            $_SERVER['REQUEST_METHOD'],
            $data['uri']);
        
        $requestSignature = md5(implode(':', $requestArray));
        
        //make response siggy
        $responseArray = array(
            $userSignature,
            $data['nonce'],
            $data['nc'],
            $data['cnonce'],
            $data['qop'],
            $requestSignature);
        
        return md5(implode(':', $responseArray));
    }
501603
public function sign($data) {
    /* Remove signature from server. */
    unset($data['h']);

    /* Sort keys alphabetically. */
    ksort($data);

    /* Build query string to sign. */
    $n = count($data);
    $query = '';
    $i = 0;
    while(list($key, $val) = each($data)) {
      $i++;
      $query .= $key.'='.$val;
      if($i < $n) {
        $query.= '&';
      }
    }

    /* Sign. */
    $sign = hash_hmac('sha1', utf8_encode($query), base64_decode($this->clientSecret), true);
    return base64_encode($sign);
  }
225585
public function verify($data, $signature)
  {
    $hash = defined("OPENSSL_ALGO_SHA256") ? OPENSSL_ALGO_SHA256 : "sha256";
    $status = openssl_verify($data, $signature, $this->publicKey, $hash);
    if ($status === -1) {
      throw new Exception('Signature verification error: ' . openssl_error_string());
    }
    return $status === 1;
  }
49023
public static function header($data)
    {
        if (empty($data['response'])) {
            throw new NetException("Can't create Authorization headers from an empty response.");
        }
        if (!isset($data['nonce'])) {
            return "Basic " . $data['response'];
        }
        $defaults = [
            'realm' => 'app', 'method' => 'GET', 'uri' => '/',
            'username' => null, 'qop' => 'auth',
            'nonce' => null, 'opaque' => null,
            'cnonce' => md5(time()),  'nc' => static::$nc
        ];
        $data += $defaults;
        $auth = "username=\"{$data['username']}\", response=\"{$data['response']}\", ";
        $auth .= "uri=\"{$data['uri']}\", realm=\"{$data['realm']}\", ";
        $auth .= "qop=\"{$data['qop']}\", nc={$data['nc']}, cnonce=\"{$data['cnonce']}\", ";
        $auth .= "nonce=\"{$data['nonce']}\", opaque=\"{$data['opaque']}\"";
        return "Digest " . $auth;
    }
124945
public static function mimeHeaderDecode($header) {
    $callback = function ($matches) {
      $data = ($matches[2] == 'B') ? base64_decode($matches[3]) : str_replace('_', ' ', quoted_printable_decode($matches[3]));
      if (strtolower($matches[1]) != 'utf-8') {
        $data = static::convertToUtf8($data, $matches[1]);
      }
      return $data;
    };
    // First step: encoded chunks followed by other encoded chunks (need to collapse whitespace)
    $header = preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=\s+(?==\?)/', $callback, $header);
    // Second step: remaining chunks (do not collapse whitespace)
    return preg_replace_callback('/=\?([^?]+)\?(Q|B)\?([^?]+|\?(?!=))\?=/', $callback, $header);
  }
541945
public function getHeaderValue($header, $glue = '')
    {
        if ($header = $this->response->getHeader($header, true)) {
            if (is_array($header)) {
                return implode($glue, $header);
            }
        }

        return $header;
    }
517793
private function getOpenSSLSignature(JWKInterface $key, $data)
    {
        $pem = (new ECKey($key))->toPEM();
        $result = openssl_sign($data, $signature, $pem, $this->getHashAlgorithm());

        Assertion::true($result, 'Signature failed');

        $asn = ASNObject::fromBinary($signature);
        Assertion::isInstanceOf($asn, Sequence::class, 'Invalid signature');

        $res = '';
        foreach ($asn->getChildren() as $child) {
            Assertion::isInstanceOf($child, Integer::class, 'Invalid signature');
            $res .= str_pad($this->convertDecToHex($child->getContent()), $this->getSignaturePartLength(), '0', STR_PAD_LEFT);
        }

        return $this->convertHexToBin($res);
    }
1107005
public function head($url, $data = null, $header = [])
    {
        return $this->exec($url, false, 'head', $header);
    }
1264743
private function verifySignature($data, $sig)
    {
        $this->initOpenSSL();
        $ret = openssl_verify($data, $sig, $this->publicKey, 'sha256');
        if ($ret == -1) {
            throw new SignatureException(openssl_error_string());
        }
        return $ret;
    }
75788
public function getHeader($header)
    {
        return isset($this->getHeaders()[$header]) ? $this->getHeaders()[$header] : null;
    }