Verifies given OAuth request.
@param string $signature signature to be verified.
@param string $baseString signature base string.
@param string $key signature key.
@return bool success.
179453
public function verify($signature, $baseString, $key)
    {
        $expectedSignature = $this->generateSignature($baseString, $key);
        if (empty($signature) || empty($expectedSignature)) {
            return false;
        }

        return (strcmp($expectedSignature, $signature) === 0);
    }
339560
public function verifyCallbackSignature($accessTokenCipher, $signature) {
		return $this->rsaWalletService->verifySignature($accessTokenCipher, $signature, $this->publicKey);
	}
1272973
private function _signHeader($endpoint, $authMethod, $params)
    {
        if (!is_array($params)) {
            $params = array();
        }
        if ($authMethod) {
            list($key, $value) = explode('=', substr($authMethod, 1), 2);
            $params[$key] = $value;
        }
        $baseString = '/' . $endpoint;
        ksort($params);
        foreach ($params as $key => $value) {
            $baseString .= '|' . $key . '=' . $value;
        }
        $signature = hash_hmac('sha256', $baseString, $this->_apisecret, false);

        return $signature;
    }
138193
public static function signRequest($clientSecret, $method, $url, $body, $timestamp)
	{
		$separator = "\n";
		// Build string that need to be signed [ METHOD, URL, BODY, UNIX_TIMESTAMP ]
		$string = implode($separator, [$method, $url, $body, $timestamp]);

		// Sign
		return hash_hmac('sha256', $string, $clientSecret);
	}
743735
public String sign(String signatureBaseString) {
    try {
      Mac mac = Mac.getInstance(MAC_NAME);
      mac.init(key);
      byte[] text = signatureBaseString.getBytes("UTF-8");
      byte[] signatureBytes = mac.doFinal(text);
      signatureBytes = Base64.encodeBase64(signatureBytes);
      String signature = new String(signatureBytes, "UTF-8");

      if (LOG.isDebugEnabled()) {
        LOG.debug("signature base: " + signatureBaseString);
        LOG.debug("signature: " + signature);
      }

      return signature;
    }
    catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException(e);
    }
    catch (InvalidKeyException e) {
      throw new IllegalStateException(e);
    }
    catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
865227
public function sign($text, SignatureCredentials $credentials)
    {
        if (!$credentials instanceof SymmetricCredentials) {
            throw new \InvalidArgumentException('HmacAlgorithms works with symmetric credentials');
        }
        return base64_encode(hash_hmac($this->getHashAlgorithm(), $text, $credentials->getSharedKey(), true));
    }
454387
public function getAuthorization($signature, $string = true)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a string
            ->test(1, 'string')
            //Argument 2 must be a boolean
            ->test(2, 'bool');
        
        //this is all possible configurations
        $params = array(
            'realm'     => $this->realm,
            'oauth_consumer_key' => $this->consumerKey,
            'oauth_token' => $this->requestToken,
            'oauth_signature_method' => self::HMAC_SHA1,
            'oauth_signature' => $signature,
            'oauth_timestamp' => $this->time,
            'oauth_nonce' => $this->nonce,
            'oauth_version'     => self::OAUTH_VERSION,
            'oauth_verifier' => $this->verifier,
            'oauth_callback' => $this->callback);
        
        //if no realm
        if (is_null($this->realm)) {
            //remove it
            unset($params['realm']);
        }
        
        //if no token
        if (is_null($this->requestToken)) {
            //remove it
            unset($params['oauth_token']);
        }
        
        //if no verifier
        if (is_null($this->verifier)) {
            //remove it
            unset($params['oauth_verifier']);
        }
        
        
        //if no callback
        if (is_null($this->callback)) {
            //remove it
            unset($params['oauth_callback']);
        }
        
        if (!$string) {
            return $params;
        }
        
        return sprintf(self::AUTH_HEADER, $this->buildQuery($params, ',', false));
    }
272547
public boolean verify(String message, String signature) {
		try {
			return verifier.verify(message.getBytes(charsetName), Base64.decodeBase64(signature));
		} catch (UnsupportedEncodingException e) {
			throw new SignatureException("unsupported encoding: charsetName=" + charsetName, e);
		} catch (Exception e) {
			return false;
		}
	}
353965
function signature ( $request, $base_string, $consumer_secret, $token_secret )
	{
		$key = $request->urlencode($consumer_secret).'&'.$request->urlencode($token_secret);
		if (function_exists('hash_hmac'))
		{
			$signature = base64_encode(hash_hmac("sha1", $base_string, $key, true));
		}
		else
		{
		    $blocksize	= 64;
		    $hashfunc	= 'sha1';
		    if (strlen($key) > $blocksize)
		    {
		        $key = pack('H*', $hashfunc($key));
		    }
		    $key	= str_pad($key,$blocksize,chr(0x00));
		    $ipad	= str_repeat(chr(0x36),$blocksize);
		    $opad	= str_repeat(chr(0x5c),$blocksize);
		    $hmac 	= pack(
		                'H*',$hashfunc(
		                    ($key^$opad).pack(
		                        'H*',$hashfunc(
		                            ($key^$ipad).$base_string
		                        )
		                    )
		                )
		            );
			$signature = base64_encode($hmac);
		}
		return $request->urlencode($signature);
	}
138710
public static function verifyMessageSignature($secret, $body = null, $signature = null) {

		// Compute hash of message using shared secret:
		$body = is_null($body) ? file_get_contents('php://input') : $body;
		$hash = base64_encode(hash_hmac('sha256', $body, $secret, true));

		// Compare hash to the signature:
		$signature = is_null($signature) ? $_SERVER['HTTP_X_ACUITY_SIGNATURE'] : $signature;
		if ($hash !== $signature) {
			throw new Exception('This message was forged!');
		}
	}
182205
public function check(array $auth, array $signature, $prefix)
    {
        if (! isset($auth[$prefix . 'signature'])) {
            throw new SignatureSignatureException('The signature has not been set');
        }

        if ($auth[$prefix . 'signature'] !== $signature[$prefix . 'signature']) {
            throw new SignatureSignatureException('The signature is not valid');
        }

        return true;
    }
697723
public static function opensslVerify(
        $str,
        $sinature,
        $publicKeyPath,
        $algo = OPENSSL_ALGO_SHA1,
        $format = self::FORMAT_HEX
    )
    {
        $publicKey = openssl_pkey_get_public(file_get_contents($publicKeyPath));

        $sinature = trim($sinature);

        switch ($format) {
            case self::FORMAT_HEX:
                $sinature = hex2bin($sinature);
                break;
            case self::FORMAT_BASE64:
                $sinature = EncodeHelper::base64Decode($sinature);
                break;
            default:
                $sinature = hex2bin($sinature);
        }

        $res = openssl_verify(trim($str), $sinature, $publicKey, $algo);

        openssl_free_key($publicKey);

        if ($res == 1) {
            return true;
        }

        return false;
    }
184074
public KeyVerifyParameters withSignature(byte[] signature) {
        if (signature == null) {
            this.signature = null;
        } else {
            this.signature = Base64Url.encode(signature);
        }
        return this;
    }
1022125
public function isValid(SignatureComposer $composer)
    {
        // Constant Time String Comparison @see http://php.net/hash_equals
        if (!function_exists('hash_equals')) {
            // Polyfill for PHP < 5.6
            return Security::hashEquals($composer->compose($this->parameters), $this->signature);
        } else {
            return hash_equals($composer->compose($this->parameters), $this->signature);
        }
    }
189375
public function isValid($payload, $publicKey, $signature)
    {
        return openssl_verify($payload, $signature, $publicKey, $this->hashAlgorithm) === 1;
    }
1236753
function _sign($key, $signatureAlgorithm)
    {
        switch (strtolower(get_class($key))) {
            case 'crypt_rsa':
                switch ($signatureAlgorithm) {
                    case 'md2WithRSAEncryption':
                    case 'md5WithRSAEncryption':
                    case 'sha1WithRSAEncryption':
                    case 'sha224WithRSAEncryption':
                    case 'sha256WithRSAEncryption':
                    case 'sha384WithRSAEncryption':
                    case 'sha512WithRSAEncryption':
                        $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
                        $key->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);

                        $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject));
                        return $this->currentCert;
                }
            default:
                return false;
        }
    }
447527
public function verify($openid, $jsonString, $jsonSignature)
    {
        $params = [
            'openid'         => $openid,
            'json_string'    => $jsonString,
            'json_signature' => $jsonSignature,
        ];

        return $this->parseJSON('json', [self::API_VERIFY_SIGNATURE, $params]);
    }