當前位置: 首頁>>代碼示例>>PHP>>正文


PHP openssl_get_publickey函數代碼示例

本文整理匯總了PHP中openssl_get_publickey函數的典型用法代碼示例。如果您正苦於以下問題:PHP openssl_get_publickey函數的具體用法?PHP openssl_get_publickey怎麽用?PHP openssl_get_publickey使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了openssl_get_publickey函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPublicKey

 /**
  * Extracts the public key from certificate and prepares it for use by other functions.
  * OOP alias for openssl_pkey_get_public / openssl_get_publickey.
  *
  * @return resource 'OpenSSL key'
  */
 public function getPublicKey()
 {
     if ($this->publicKey === null) {
         $this->publicKey = openssl_get_publickey($this->certificate);
     }
     return $this->publicKey;
 }
開發者ID:evandotpro,項目名稱:sslurp,代碼行數:13,代碼來源:X509Certificate.php

示例2: rsaVerify

 /**
  * RSA驗簽
  * @param $data 待簽名數據
  * @param $public_key 支付寶的公鑰文件路徑
  * @param $sign 要校對的的簽名結果
  * @return 驗證結果
  */
 public function rsaVerify($data, $public_key, $sign)
 {
     $res = openssl_get_publickey($public_key);
     $result = (bool) openssl_verify($data, base64_decode($sign), $res);
     openssl_free_key($res);
     return $result;
 }
開發者ID:devsnippet,項目名稱:alipay-1,代碼行數:14,代碼來源:RsaFunctions.php

示例3: validate_pub_key

function validate_pub_key($pub_key)
{
    $key = @openssl_get_publickey($pub_key);

    if($key === false)
        throw new invalid_public_key_exception();
}
開發者ID:robehickman,項目名稱:decentralised_microblogging_system,代碼行數:7,代碼來源:crypto.php

示例4: validate

 /**
  * Validates a message from SNS to ensure that it was delivered by AWS
  *
  * @param Message $message The message to validate
  *
  * @throws CannotGetPublicKeyFromCertificateException If the certificate cannot be retrieved
  * @throws CertificateFromUnrecognizedSourceException If the certificate's source cannot be verified
  * @throws InvalidMessageSignatureException           If the message's signature is invalid
  */
 public function validate($message)
 {
     // Get the cert's URL and ensure it is from AWS
     $certUrl = $message->get('SigningCertURL');
     $host = parse_url($certUrl, PHP_URL_HOST);
     if ('.amazonaws.com' != substr($host, -14)) {
         throw new CertificateFromUnrecognizedSourceException($host . ' did not match .amazonaws.com');
     }
     // Get the cert itself and extract the public key
     $response = wp_remote_get($certUrl);
     if (is_wp_error($response)) {
         throw new CannotGetPublicKeyFromCertificateException('Could not retrieve certificate from ' . $certUrl);
     }
     $certificate = wp_remote_retrieve_body($response);
     $publicKey = openssl_get_publickey($certificate);
     if (!$publicKey) {
         throw new CannotGetPublicKeyFromCertificateException('Could not extract public key from ' . $certUrl);
     }
     // Verify the signature of the message
     $stringToSign = $message->getStringToSign();
     $incomingSignature = base64_decode($message->get('Signature'));
     if (!openssl_verify($stringToSign, $incomingSignature, $publicKey, OPENSSL_ALGO_SHA1)) {
         throw new InvalidMessageSignatureException('The message did not match the signature ' . "\n" . $stringToSign);
     }
 }
開發者ID:easinewe,項目名稱:Avec2016,代碼行數:34,代碼來源:MessageValidator.php

示例5: ApiRsaVerify

/**
 * RSA驗簽
 * @param $data 待簽名數據
 * @param $ali_public_key_path 支付寶的公鑰文件路徑
 * @param $sign 要校對的的簽名結果
 * return 驗證結果
 */
function ApiRsaVerify($data, $ali_public_key_path, $sign)  {
	$pubKey = file_get_contents($ali_public_key_path);
    $res = openssl_get_publickey($pubKey);
    $result = (bool)openssl_verify($data, base64_decode($sign), $res);
    openssl_free_key($res);    
    return $result;
}
開發者ID:8yong8,項目名稱:vshop,代碼行數:14,代碼來源:rsa.function.php

示例6: HandleCallback

 /**
  * Function that processes the callback from the bank and returns CPayment objects with isSuccessful
  * (and other applicable) parameters filled according to the answers from the bank.
  *
  * @return CPayment
  */
 public function HandleCallback()
 {
     $rsField = array();
     foreach ((array) $_REQUEST as $ixField => $fieldValue) {
         $rsField[$ixField] = $fieldValue;
     }
     $sSignatureBase = sprintf("%03s", $rsField['ver']) . sprintf("%-10s", $rsField['id']) . sprintf("%012s", $rsField['ecuno']) . sprintf("%06s", $rsField['receipt_no']) . sprintf("%012s", $rsField['eamount']) . sprintf("%3s", $rsField['cur']) . $rsField['respcode'] . $rsField['datetime'] . sprintf("%-40s", $rsField['msgdata']) . sprintf("%-40s", $rsField['actiontext']);
     function hex2str($hex)
     {
         for ($i = 0; $i < strlen($hex); $i += 2) {
             $str .= chr(hexdec(substr($hex, $i, 2)));
         }
         return $str;
     }
     $mac = hex2str($rsField['mac']);
     $sSignature = sha1($sSignatureBase);
     $flKey = openssl_get_publickey(file_get_contents($this->flBankCertificate));
     if (!openssl_verify($sSignatureBase, $mac, $flKey)) {
         trigger_error("Invalid signature", E_USER_ERROR);
     }
     if ($rsField['receipt_no'] == 00) {
         return new CPayment($rsField['ecuno'], $rsField['msgdata'], null, null, False);
     } else {
         return new CPayment($rsField['ecuno'], $rsField['msgdata'], $rsField['eamount'] / 100, $rsField['cur'], True);
     }
 }
開發者ID:vcgato29,項目名稱:poff,代碼行數:32,代碼來源:EstCardLink.class.php

示例7: verify

 public static function verify($data, $senderid)
 {
     gio::log("Verifying message ...", VERBOSE);
     $pubkeyid = self::getkey($senderid, false, true);
     if (!$pubkeyid) {
         $pubkeyid = openssl_get_publickey(self::getcert($senderid, true));
     }
     if (!$pubkeyid) {
         return false;
     }
     $data = explode("::SIGNATURE::", $data);
     $signature = base64_decode($data[1]);
     $data = $data[0];
     $ok = openssl_verify($data, $signature, $pubkeyid);
     if ($ok < 1) {
         if ($ok < 0) {
             gio::log("Error while verifying data from {$senderid} ...", E_USER_WARNING);
         } else {
             gio::log("Invalid signature detected while verifying data from {$senderid} ...", E_USER_WARNING);
         }
         return false;
     }
     gio::log("... Done verifying message", VERBOSE);
     return $data;
 }
開發者ID:perfectcode1,項目名稱:Gcoin,代碼行數:25,代碼來源:gcrypt.php

示例8: testSecureAuthSubSigning

 public function testSecureAuthSubSigning()
 {
     if (!extension_loaded('openssl')) {
         $this->markTestSkipped('The openssl extension is not available');
     } else {
         $c = new GData\HttpClient();
         $c->setAuthSubPrivateKeyFile("Zend/GData/_files/RsaKey.pem", null, true);
         $c->setAuthSubToken('abcdefg');
         $requestData = $c->filterHttpRequest('POST', 'http://www.example.com/feed', array(), 'foo bar', 'text/plain');
         $authHeaderCheckPassed = false;
         $headers = $requestData['headers'];
         foreach ($headers as $headerName => $headerValue) {
             if (strtolower($headerName) == 'authorization') {
                 preg_match('/data="([^"]*)"/', $headerValue, $matches);
                 $dataToSign = $matches[1];
                 preg_match('/sig="([^"]*)"/', $headerValue, $matches);
                 $sig = $matches[1];
                 if (function_exists('openssl_verify')) {
                     $fp = fopen('Zend/GData/_files/RsaCert.pem', 'r', true);
                     $cert = '';
                     while (!feof($fp)) {
                         $cert .= fread($fp, 8192);
                     }
                     fclose($fp);
                     $pubkeyid = openssl_get_publickey($cert);
                     $verified = openssl_verify($dataToSign, base64_decode($sig), $pubkeyid);
                     $this->assertEquals(1, $verified, 'The generated signature was unable ' . 'to be verified.');
                     $authHeaderCheckPassed = true;
                 }
             }
         }
         $this->assertEquals(true, $authHeaderCheckPassed, 'Auth header not found for sig verification.');
     }
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:34,代碼來源:AuthSubTest.php

示例9: verify

	function verify($pubKey, $toCheck, $signature) {
		$openSslPubKey = openssl_get_publickey($this->seclibToOpenSsl($pubKey));
		$verified = openssl_verify($toCheck, $signature, $openSslPubKey);
		openssl_free_key($openSslPubKey);
		
		return $verified;
	} # verify
開發者ID:remielowik,項目名稱:spotweb,代碼行數:7,代碼來源:SpotSeclibToOpenSsl.php

示例10: checkGooglePlay

function checkGooglePlay($signture_json, $signture)
{
    global $public_key;
    $public_key_handle = openssl_get_publickey($public_key);
    $result = openssl_verify($signture_json, base64_decode($signture), $public_key_handle, OPENSSL_ALGO_SHA1);
    return $result;
}
開發者ID:hiacai,項目名稱:test,代碼行數:7,代碼來源:CheckGooglePlay.php

示例11: pubkey_bits

 function pubkey_bits($pubkey)
 {
     $pubkey = openssl_get_publickey($pubkey);
     $keydata = openssl_pkey_get_details($pubkey);
     openssl_free_key($pubkey);
     return $keydata['bits'];
 }
開發者ID:billstclair,項目名稱:trubanc,代碼行數:7,代碼來源:ssl.php

示例12: check_license

    public static function check_license($license)
    {
        $signature = $license['Signature'];
        unset($license['Signature']);
        uksort($license, "strcasecmp");
        $total = '';
        foreach ($license as $value) {
            $total .= $value;
        }
        $key_raw = <<<EOD
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtl7Dgf4x0fi0lXfws7Cq/lk0d
TIEXnCu8PBMep0mtRia9WEJ8N53d+8gbuAcMzb4sW6MVOzTEKYrmtq/DTbiaXKiJ
o6osz5KgBjbcGrCzKKvk8uQuTZWusqp69LQfTYSwxwJIp45kl0g8yalewGUtpYuu
yWXBBsw7Z909BpTLBQIDAAAD
-----END PUBLIC KEY-----
EOD;
        $key = openssl_get_publickey($key_raw);
        openssl_public_decrypt(base64_decode($signature), $checkDigest, $key);
        $digest = sha1($total, true);
        if ($digest === $checkDigest) {
            return true;
        }
        return false;
    }
開發者ID:macauley,項目名稱:Dash-Annotations,代碼行數:25,代碼來源:DashLicenseUtil.php

示例13: isSuccesful

 public function isSuccesful()
 {
     foreach ((array) $_REQUEST as $ixField => $fieldValue) {
         $this->responseFields[$ixField] = $fieldValue;
     }
     $sSignatureBase = sprintf("%03s", $this->responseFields['ver']) . sprintf("%-10s", $this->responseFields['id']) . sprintf("%012s", $this->responseFields['ecuno']) . sprintf("%06s", $this->responseFields['receipt_no']) . sprintf("%012s", $this->responseFields['eamount']) . sprintf("%3s", $this->responseFields['cur']) . $this->responseFields['respcode'] . $this->responseFields['datetime'] . $this->mb_sprintf("%-40s", $this->responseFields['msgdata']) . $this->mb_sprintf("%-40s", $this->responseFields['actiontext']);
     function hex2str($hex)
     {
         $str = '';
         for ($i = 0; $i < strlen($hex); $i += 2) {
             $str .= chr(hexdec(substr($hex, $i, 2)));
         }
         return $str;
     }
     $mac = hex2str($this->responseFields['mac']);
     $flKey = openssl_get_publickey(\Configuration::where('code', '=', 'estcard/pubkey')->first()->value);
     if (!openssl_verify($sSignatureBase, $mac, $flKey)) {
         // invalidSignature
         return false;
     }
     if ($this->responseFields['receipt_no'] == 00) {
         # Payment was cancelled
         return false;
     }
     if ($this->responseFields['respcode'] == 00) {
         # Payment success
         return true;
     }
 }
開發者ID:Silxik,項目名稱:banklink,代碼行數:29,代碼來源:Estcard.php

示例14: setPubKey

 /**
  * 設置公鑰
  */
 public function setPubKey($key)
 {
     $pubKey = '-----BEGIN CERTIFICATE-----' . PHP_EOL;
     $pubKey .= chunk_split(base64_encode($key), 64, PHP_EOL);
     $pubKey .= '-----END CERTIFICATE-----' . PHP_EOL;
     $this->pubKey = openssl_get_publickey($pubKey);
 }
開發者ID:spiritwolf,項目名稱:Cellular,代碼行數:10,代碼來源:openssl.php

示例15: dec_pub

 function dec_pub($dat)
 {
     list($cry,$str) = array_map('base64_decode',explode(':',$dat));
     $res = openssl_get_publickey($this->pub);
     openssl_public_decrypt($cry,$key,$res);
     $ret = $this->dec_sym($key,$str);
     return trim($ret);
 }
開發者ID:spinit,項目名稱:osy,代碼行數:8,代碼來源:Crypt.php


注:本文中的openssl_get_publickey函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。