Check X-Hub-Signature

@throws BadSignatureException
@return bool
497304
private function _checkSignature(): bool
    {
        $secret           = $this->getSecret();
        $httpHubSignature = $this->serverBag->get('HTTP_X_HUB_SIGNATURE');

        if (null !== $secret) {
            if ($httpHubSignature) {
                /**
                 * Split signature into algorithm and hash
                 *
                 * @link http://isometriks.com/verify-github-webhooks-with-php
                 */
                list(, $hash) = explode('=', $httpHubSignature, 2);

                return $secret == $hash;
            }

            throw new BadSignatureException('HTTP header "X-Hub-Signature" is missing.');
        }

        return true;
    }
985456
public function checkSignature($signature = null, $timestamp = null, $nonce = null)
    {
        $request = Yii::$app->request;
        $signature === null && $signature = $request->get('signature', '');
        $timestamp === null && $timestamp = $request->get('timestamp', '');
        $nonce === null && $nonce = $request->get('nonce', '');
        $tmpArr = [$this->token, $timestamp, $nonce];
        sort($tmpArr, SORT_STRING);
        $tmpStr = implode($tmpArr);
        return sha1($tmpStr) == $signature;
    }
564169
public static function CheckAuthentication(){
            $oThis = self::CreateInstanceIfNotExists();
            $bReturn = ($oThis->bStarted) ? (!empty($oThis->aAuth["id"]) && !empty($oThis->aAuth["username"]) && ((intval($oThis->aAuth["timeout"]) > time()) || (intval($oThis->aAuth["timeout"]) <= 0))) : false;
            return $bReturn;
        }
399191
function DetectSymbianOS()
   {
       if (stripos($this->useragent, $this->deviceSymbian) > -1 || 
           stripos($this->useragent, $this->deviceS60) > -1 ||
           stripos($this->useragent, $this->deviceS70) > -1 || 
           stripos($this->useragent, $this->deviceS80) > -1 ||
           stripos($this->useragent, $this->deviceS90) > -1)
         return $this->true; 
      else
         return $this->false; 
   }
481640
public function hasValidSignature(
        SignedElement $signedElement,
        CertificateProvider $configuration
    ) : bool {
        $logger = $this->logger;
        $pemCandidates = $this->configuredKeys->filter(function (Key $key) use ($logger) {
            if (!$key instanceof X509) {
                $logger->debug(sprintf('Skipping unknown key type: "%s"', $key['type']));
                return false;
            }
            return true;
        });

        if (!count($pemCandidates)) {
            $this->logger->debug('No configured X509 certificate found to verify the signature with');

            return false;
        }

        return $this->validateElementWithKeys($signedElement, $pemCandidates);
    }
960363
public boolean verifySignature(byte[] publicKey, byte[] message, byte[] signature) {
    if (publicKey == null || publicKey.length != 32) {
      throw new IllegalArgumentException("Invalid public key!");
    }

    if (message == null || signature == null || signature.length != 64) {
      return false;
    }

    return provider.verifySignature(publicKey, message, signature);
  }
691628
private function checkSignature()
    {
        $signer = new Sha512();
        $keychain = new Keychain();
        
        if (!$this->jwt->verify($signer, $keychain->getPublicKey($this->app->getSecretKey()))) {
            throw new EndpointException("Access token verification failed");
        }
    }
1262449
public function verify(JWSInterface $jws, JWKSetInterface $signature_key_set, $detached_payload = null)
    {
        Assertion::inArray($jws->getSignature(0)->getProtectedHeader('alg'), $this->getSupportedSignatureAlgorithms(), sprintf('The signature algorithm "%s" is not supported or not allowed.', $jws->getSignature(0)->getProtectedHeader('alg')));

        $index = null;
        $this->verifier->verifyWithKeySet($jws, $signature_key_set, $detached_payload, $index);
        Assertion::notNull($index, 'JWS signature(s) verification failed.');
        $this->checker_manager->checkJWS($jws, $index);

        return $index;
    }
861431
public static function getSignature($headers)
    {
        foreach($headers as $name => $value)
        {
            if(preg_match('/X-OpenPayU-Signature/i', $name) || preg_match('/OpenPayu-Signature/i', $name))
                return $value;
        }

        return null;
    }
1105355
public function toProtobuf() : SignatureDeviceInfo
    {
        $deviceInfo = new SignatureDeviceInfo();
        if ($this->deviceId !== null) {
            $deviceInfo->setDeviceId($this->deviceId);
        }

        $deviceInfo->setDeviceBrand($this->deviceBrand);
        $deviceInfo->setDeviceModel($this->deviceModel);
        $deviceInfo->setDeviceModelBoot($this->deviceModelBoot);
        $deviceInfo->setFirmwareType($this->firmwareType);
        $deviceInfo->setFirmwareBrand($this->firmwareBrand);
        $deviceInfo->setHardwareModel($this->hardwareModel);
        $deviceInfo->setHardwareManufacturer($this->hardwareManufacturer);

        return $deviceInfo;
    }
1354497
def verify_tokens(self):
    
    xidentity = key_utils.get_compressed_public_key_from_pem(self.pem)
    url = self.uri + "/tokens"
    xsignature = key_utils.sign(self.uri + "/tokens", self.pem)
    headers = {"content-type": "application/json", 'accept': 'application/json', 'X-Identity': xidentity, 'X-Signature': xsignature, 'X-accept-version': '2.0.0'}
    response = requests.get(self.uri + "/tokens", headers=headers, verify=self.verify)
    if response.ok:
      allTokens = response.json()['data']
      selfKeys = self.tokens.keys() 
      matchedTokens = [token for token in allTokens for key in selfKeys if token.get(key) == self.tokens.get(key)]
      if not matchedTokens:
        return False
      return True
72928
private function checkSignature($signature, $status, $code)
    {
        if (!$signature) {
            throw new EndpointException("Invalid signature");
        }
      
        $data = $this->app->getAppId() . $this->requestId . $this->connectId . $code . $status;
        $result = openssl_verify($data, $signature, $this->app->getSecretKey(), OPENSSL_ALGO_SHA512);
        
        if ($result < 1) {
            $errstr = openssl_error_string();

            throw new EndpointException("Invalid signature or an openssl error (" . ($errstr ? $errstr : "-") . ")");
        }
    }
84709
public function isValid()
    {
        $localSign = generate_sign($this->getNotify()->except('sign')->all(), $this->merchant->key, 'md5');

        return $localSign === $this->getNotify()->get('sign');
    }
537252
public function hasBeenSignaled()
    {
        $this->requireProcessIsTerminated(__FUNCTION__);

        if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
            throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
        }

        return $this->processInformation['signaled'];
    }
1162606
public static function verify()
    {
        // PHP interpreter version
        self::checkSystemVersion();

        // BCMath
        self::isFunctionExists('bcmul', self::getErrorMessage('bcmath'));
        self::isFunctionExists('bcdiv', self::getErrorMessage('bcmath'));

        // Filter
        self::isFunctionExists('filter_var', self::getErrorMessage('filter'));

        // Hash
        self::isFunctionExists('hash', self::getErrorMessage('hash'));

        // XMLReader
        self::isClassExists('XMLReader', self::getErrorMessage('xmlreader'));

        // XMLWriter
        if (\Genesis\Config::getInterface('builder') == 'xml') {
            self::isClassExists('XMLWriter', self::getErrorMessage('xmlwriter'));
        }

        // cURL
        if (\Genesis\Config::getInterface('network') == 'curl') {
            self::isFunctionExists('curl_init', self::getErrorMessage('curl'));
        }
    }
348598
protected function checkToken()
    {
        $query = $this->query;
        $signature = $this->sign(
            $this->token,
            isset($query['timestamp']) ? $query['timestamp'] : '',
            isset($query['nonce']) ? $query['nonce'] : ''
        );
        return isset($query['signature']) && $signature === $query['signature'];
    }
104147
private function checkSignature() 
    {
        if ($this->signature !== false && $this->timestamp !== false && $this->nonce !== false) {
            $tmp_signature = SHA1::getSignature($this->token, $this->timestamp, $this->nonce);
            if ($tmp_signature === false) {
                error_log('Validate signature error.', 0);
            } else if ($tmp_signature === $this->signature) {
                return true;
            }
        }
        return false;
    }