本文整理汇总了PHP中openssl_get_publickey函数的典型用法代码示例。如果您正苦于以下问题:PHP openssl_get_publickey函数的具体用法?PHP openssl_get_publickey怎么用?PHP openssl_get_publickey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了openssl_get_publickey函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: verify
/**
* makes the verification of the incoming data with a public key
* @param string $signature
* @param string $data
* @param string $publicKeyPath
* @return boolean
*/
public static function verify($signature, $data, $publicKeyPath)
{
$publicKey = self::read($publicKeyPath);
$pKeyId = openssl_get_publickey($publicKey);
$result = openssl_verify($data, $signature, $pKeyId, "SHA256");
openssl_free_key($pKeyId);
return (bool) $result;
}
开发者ID:travijuu,项目名称:bkm-express,代码行数:15,代码来源:Certificate.php
示例17: verify
/**
* @param string $text
* @param string $signatureBase64
* @return bool
*/
function verify($text, $signatureBase64)
{
$publicKeyId = openssl_get_publickey($this->publicKey);
$signature = base64_decode($signatureBase64);
$res = openssl_verify($text, $signature, $publicKeyId);
openssl_free_key($publicKeyId);
return $res === 1;
}
开发者ID:bileto,项目名称:omnipay-csob,代码行数:13,代码来源:Verifier.php
示例18: encrypt
/**
* 对明文进行加密
*
* @param string $text 明文
*
* @return string 密文,并且进行base64转换
*/
static function encrypt($source)
{
global $cfg;
$prikey = $cfg['rsa']['pubkey'];
openssl_get_publickey($pubkey);
$res = openssl_public_encrypt($source, $crypttext, $pubkey, OPENSSL_PKCS1_PADDING);
return $res ? base64_encode($crypttext) : false;
}
开发者ID:a4m,项目名称:go1den-express,代码行数:15,代码来源:Rsa.class.php
示例19: verifySignature
/**
* Verify the returned response.
*
* @param $message
* @param $signature
* @return mixed
*/
public function verifySignature($message, $signature)
{
$cert = $this->getCertificate();
$pubkeyid = openssl_get_publickey($cert);
$verify = openssl_verify(substr($message, 0, strlen($message) - 128), $signature, $pubkeyid);
openssl_free_key($pubkeyid);
return $verify;
}
开发者ID:mirovit,项目名称:borica-api,代码行数:15,代码来源:Response.php
示例20: verify
function verify($text, $signature)
{
$pubkeyid = openssl_get_publickey($this->verejny);
$signature = base64_decode($signature);
$vysledek = openssl_verify($text, $signature, $pubkeyid);
openssl_free_key($pubkeyid);
return $vysledek == 1 ? true : false;
}
开发者ID:LubosCzech,项目名称:WiFiCisnik2,代码行数:8,代码来源:CSignatureComponent.php
注:本文中的openssl_get_publickey函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论