当前位置: 首页>>代码示例>>PHP>>正文


PHP Crypt_RSA::setSignatureMode方法代码示例

本文整理汇总了PHP中Crypt_RSA::setSignatureMode方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypt_RSA::setSignatureMode方法的具体用法?PHP Crypt_RSA::setSignatureMode怎么用?PHP Crypt_RSA::setSignatureMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Crypt_RSA的用法示例。


在下文中一共展示了Crypt_RSA::setSignatureMode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: seeValidSignature

 public function seeValidSignature()
 {
     $response = $this->getModule('REST')->response;
     $response = json_decode($response);
     $sign = base64_url_decode($response->sign);
     $this->rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $this->assertTrue($this->rsa->verify($response->data, $sign));
 }
开发者ID:amegatron,项目名称:cryptoapi,代码行数:8,代码来源:CryptoApiHelper.php

示例2: createPrivateKey

 public function createPrivateKey($sslCnfPath)
 {
     $rsa = new Crypt_RSA();
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $keyPair = $rsa->createKey();
     return array('public' => $keyPair['publickey'], 'private' => $keyPair['privatekey']);
 }
开发者ID:niel,项目名称:spotweb,代码行数:7,代码来源:Services_Signing_Php.php

示例3: downloadPlugin

 public function downloadPlugin($name, $url, $signature)
 {
     if (is_dir(ipFile("Plugin/{$name}/"))) {
         Service::deactivatePlugin($name);
         Helper::removeDir(ipFile("Plugin/{$name}/"));
     }
     //download plugin
     $net = new \Ip\Internal\NetHelper();
     $pluginTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
     if (!$pluginTempFilename) {
         throw new \Ip\Exception('Plugin file download failed.');
     }
     $archivePath = ipFile('file/secure/tmp/' . $pluginTempFilename);
     //check signature
     $fileMd5 = md5_file($archivePath);
     $rsa = new \Crypt_RSA();
     $rsa->loadKey($this->publicKey);
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $verified = $rsa->verify($fileMd5, base64_decode($signature));
     if (!$verified) {
         throw new \Ip\Exception('Plugin signature verification failed.');
     }
     //extract
     $secureTmpDir = ipFile('file/secure/tmp/');
     $tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
     \Ip\Internal\Helper\Zip::extract($secureTmpDir . $pluginTempFilename, $secureTmpDir . $tmpExtractedDir);
     unlink($archivePath);
     //install
     $extractedDir = $this->getFirstDir($secureTmpDir . $tmpExtractedDir);
     $installDir = Model::pluginInstallDir();
     $newPluginDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
     rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newPluginDir);
     Service::activatePlugin($name);
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:34,代码来源:PluginDownloader.php

示例4: _google_verify_token

function _google_verify_token($public_key, $signature, $signed_data, $sku, $base_url)
{
    $comments = array();
    $error = '';
    $status = 'unknown';
    if (!class_exists('Crypt_RSA')) {
        $comments[] = 'PHPSecLib is not in the PHP path.';
    }
    $purchaseToken = _google_get_product_id($signed_data, $sku);
    if (empty($purchaseToken)) {
        $status = 'invalid';
        $error = 'The SKU is not present in the data.';
    } else {
        $status = 'unverified';
        // unverified until verified
        $comments[] = 'The SKU is present in the data.';
        $comments[] = 'The purchase token is ' . str_replace("--", "-\n-", $purchaseToken);
        // Split any --'s otherwise XML is not well-formed
        // verify the data signature
        if (!class_exists('Crypt_RSA')) {
            $error = 'PHPSecLib is not in the PHP path.';
        } else {
            $rsa = new Crypt_RSA();
            $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
            $rsa->loadKey("-----BEGIN PUBLIC KEY-----\n" . $public_key . "\n-----END PUBLIC KEY-----");
            if ($rsa->verify($signed_data, base64_decode($signature))) {
                $comments[] = 'verified ok';
                $status = 'OK';
            } else {
                $comments[] = 'verification failed';
            }
        }
    }
    return array('status' => $status, 'comments' => $comments, 'error' => $error);
}
开发者ID:johnedelatorre,项目名称:fusion,代码行数:35,代码来源:pugpig_google.php

示例5: downloadTheme

 public function downloadTheme($name, $url, $signature)
 {
     $model = Model::instance();
     //download theme
     $net = new \Ip\Internal\NetHelper();
     $themeTempFilename = $net->downloadFile($url, ipFile('file/secure/tmp/'), $name . '.zip');
     if (!$themeTempFilename) {
         throw new \Ip\Exception('Theme file download failed.');
     }
     $archivePath = ipFile('file/secure/tmp/' . $themeTempFilename);
     //check signature
     $fileMd5 = md5_file($archivePath);
     $rsa = new \Crypt_RSA();
     $rsa->loadKey($this->publicKey);
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $verified = $rsa->verify($fileMd5, base64_decode($signature));
     if (!$verified) {
         throw new \Ip\Exception('Theme signature verification failed.');
     }
     //extract
     $helper = Helper::instance();
     $secureTmpDir = ipFile('file/secure/tmp/');
     $tmpExtractedDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $secureTmpDir);
     \Ip\Internal\Helper\Zip::extract($secureTmpDir . $themeTempFilename, $secureTmpDir . $tmpExtractedDir);
     unlink($archivePath);
     //install
     $extractedDir = $helper->getFirstDir($secureTmpDir . $tmpExtractedDir);
     $installDir = $model->getThemeInstallDir();
     $newThemeDir = \Ip\Internal\File\Functions::genUnoccupiedName($name, $installDir);
     rename($secureTmpDir . $tmpExtractedDir . '/' . $extractedDir, $installDir . $newThemeDir);
 }
开发者ID:Umz,项目名称:ImpressPages,代码行数:31,代码来源:ThemeDownloader.php

示例6: descriptografar

function descriptografar($texto)
{
    $rsa = new Crypt_RSA();
    $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $rsa->loadKey(file_get_contents('key/rsa_private.pem'));
    return $rsa->decrypt(base64_decode($texto));
}
开发者ID:carlsonsantana,项目名称:SecureHTML,代码行数:8,代码来源:include.php

示例7: createPrivateKey

 public function createPrivateKey($sslCnfPath)
 {
     $rsa = new Crypt_RSA();
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $opensslPrivKey = openssl_pkey_new(array('private_key_bits' => 1024, 'config' => $sslCnfPath));
     openssl_pkey_export($opensslPrivKey, $privateKey, null, array('config' => $sslCnfPath));
     $publicKey = openssl_pkey_get_details($opensslPrivKey);
     $publicKey = $publicKey['key'];
     openssl_free_key($opensslPrivKey);
     return array('public' => $publicKey, 'private' => $privateKey);
 }
开发者ID:niel,项目名称:spotweb,代码行数:11,代码来源:Services_Signing_Openssl.php

示例8: verify

 public function verify($data, $signature, $publicKey)
 {
     $this->requireLibrary();
     $rsa = new Crypt_RSA();
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $rsa->loadKey($publicKey);
     $errorCatcher = new MWP_Debug_ErrorCatcher();
     $errorCatcher->register();
     $verify = $rsa->verify($data, $signature);
     $errorMessage = $errorCatcher->yieldErrorMessage(true);
     if (!$verify && $errorMessage !== null && $errorMessage !== 'Signature representative out of range' && $errorMessage !== 'Invalid signature') {
         throw new MWP_Worker_Exception(MWP_Worker_Exception::PHPSECLIB_VERIFY_ERROR, null, array('error' => $errorMessage));
     }
     return $verify;
 }
开发者ID:61pixels,项目名称:incnow,代码行数:15,代码来源:PhpSecLibSigner.php

示例9: activateKeyGen

function activateKeyGen($key, $hwid, $privKey, $offline = false)
{
    $rsa = new Crypt_RSA();
    $rsa->loadKey($privKey);
    $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
    $rsa->setHash('sha512');
    $activateKey = $rsa->sign(sha1(base64_decode($key) . hash('sha512', $hwid, true)));
    if ($offline) {
        $license = '------BEGIN ACTIVATION KEY------' . "\r\n";
        $license .= chunk_split(base64_encode($activateKey));
        $license .= '------END ACTIVATION KEY------';
    } else {
        $license = base64_encode($activateKey);
    }
    return $license;
}
开发者ID:hartmantam,项目名称:php-license-system,代码行数:16,代码来源:activateKeyGenerator.php

示例10: rsa

 private function rsa($public_or_private_key, $padding_mode)
 {
     if ($public_or_private_key instanceof JOSE_JWK) {
         $rsa = $public_or_private_key->toKey();
     } else {
         if ($public_or_private_key instanceof Crypt_RSA) {
             $rsa = $public_or_private_key;
         } else {
             $rsa = new Crypt_RSA();
             $rsa->loadKey($public_or_private_key);
         }
     }
     $rsa->setHash($this->digest());
     $rsa->setMGFHash($this->digest());
     $rsa->setSignatureMode($padding_mode);
     return $rsa;
 }
开发者ID:nask0,项目名称:jose,代码行数:17,代码来源:JWS.php

示例11: CreateLicense

 public static function CreateLicense($licensee, $type)
 {
     // Gleiche Generalisierung wie am Client:
     $licenseeGen = self::GeneralizeDataString($licensee);
     $dataStr = $licenseeGen . (int) $type;
     // "ERIKAMUSTERMANN2"
     $rsa = new Crypt_RSA();
     // Neue RSA-Klasse erstellen
     // Setzen der RSA-Optionen auf die, die auch am Client verwendet werden:
     $rsa->setPrivateKeyFormat(CRYPT_RSA_PRIVATE_FORMAT_XML);
     $rsa->setHash('SHA1');
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     // privaten Schlüssel laden
     $rsa->loadKey(self::privateKey);
     // Erstellen der Signatur
     $signature = $rsa->sign($dataStr);
     // Formatierte Lizenzdaten zurückgeben
     return self::FormatLicense($licensee, $type, $signature);
 }
开发者ID:vainamov,项目名称:license-system,代码行数:19,代码来源:LicenseCreator.php

示例12: pac_message_receiver

 public function pac_message_receiver()
 {
     $content = Req::post("content");
     if (!isset($content)) {
         $this->returnXML("false", "S09", "返回报文为空");
     }
     $signature = Req::post("data_digest");
     if (!isset($signature)) {
         $this->returnXML("false", "S09", "返回报文为空");
     }
     Tiny::log("异步审批结果回执信息【content:" . $content . "】data_digest【" . $signature . "】");
     // 测试密钥
     $aeskey = base64_decode($this->jkf['aes_key']);
     //AES解密,采用ECB模式
     $aes = new Crypt_AES(CRYPT_MODE_ECB);
     //设置AES密钥
     $aes->setKey($aeskey);
     //解密AES密文
     $plaintext = $aes->decrypt(base64_decode($content));
     //测试rsa公钥
     $publickey = $this->jkf['public_key'];
     $rsa = new Crypt_RSA();
     //设置RSA签名模式 CRYPT_RSA_SIGNATURE_PSS or CRYPT_RSA_SIGNATURE_PKCS1
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     //使用RSA公钥验证签名
     $rsa->loadKey(base64_decode($publickey));
     //签名通过
     if ($rsa->verify($plaintext, base64_decode($signature))) {
         $contentXML = simplexml_load_string($plaintext);
         $businessType = (string) $contentXML->head->businessType;
         $model = new GatewayModel();
         if ($businessType == "RESULT") {
             $model->insertResult($contentXML, "1");
         } else {
             if ($businessType == "PRODUCT_RECORD") {
                 $model->insertExamineResult($contentXML);
             }
         }
         $this->returnXML();
     } else {
         $this->returnXML("false", "S02", "非法的数字签名");
     }
 }
开发者ID:sammychan1981,项目名称:quanpin,代码行数:43,代码来源:gateway.php

示例13: _pugpig_google_verify_token

function _pugpig_google_verify_token($public_key, $signature, $signed_data, $sku, $base_url, $subscriptionPrefix, $allowedSubscriptionArray)
{
    $comments = array();
    $error = '';
    $status = 'unknown';
    if (!class_exists('Crypt_RSA')) {
        $comments[] = 'PHPSecLib is not in the PHP path.';
    }
    $comments[] = "The public key is '{$public_key}'";
    $comments[] = "The signature is '{$signature}'";
    $comments[] = "The receipt is '{$signed_data}'";
    $comments[] = "The sku is '{$sku}'";
    $comments[] = "The base url is '{$base_url}'";
    $comments[] = "The subscription prefix is '{$subscriptionPrefix}'";
    $comments[] = 'The subscription array is (' . implode(', ', $allowedSubscriptionArray) . ')';
    $purchaseToken = _pugpig_google_get_sku_product_token($signed_data, $sku, $subscriptionPrefix, $allowedSubscriptionArray);
    if (empty($purchaseToken)) {
        $status = 'invalid';
        $error = 'The SKU is not present in the data.';
    } else {
        $status = 'unverified';
        // unverified until verified
        $comments[] = 'The SKU is present in the data.';
        $comments[] = 'The purchase token is ' . str_replace("--", "-\n-", $purchaseToken);
        // Split any --'s otherwise XML is not well-formed
        // verify the data signature
        if (!class_exists('Crypt_RSA')) {
            $error = 'PHPSecLib is not in the PHP path.';
        } else {
            $rsa = new Crypt_RSA();
            $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
            $rsa->loadKey("-----BEGIN PUBLIC KEY-----\n" . $public_key . "\n-----END PUBLIC KEY-----");
            if ($rsa->verify($signed_data, base64_decode($signature))) {
                $comments[] = 'verified ok';
                $status = 'OK';
            } else {
                $comments[] = 'verification failed';
            }
        }
    }
    return array('status' => $status, 'comments' => $comments, 'error' => $error);
}
开发者ID:shortlist-digital,项目名称:agreable-pugpig-plugin,代码行数:42,代码来源:pugpig_google.php

示例14: signMessage

 public function signMessage($privatekey, $message)
 {
     /**
      * Test code:
      * 
      * $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
      * extract($rsa->createKey());
      * $spotSigning = new SpotSigning();
      * $x = $spotSigning->signMessage($privatekey, 'testmessage');
      * var_dump($x);
      * var_dump($spotSigning->checkRsaSignature('testmessage', $x['signature'], $x['publickey']));
      *
      */
     $rsa = new Crypt_RSA();
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     $rsa->loadKey($privatekey);
     # extract de public key
     $signature = $rsa->sign($message);
     $publickey = $rsa->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_RAW);
     return array('signature' => base64_encode($signature), 'publickey' => array('modulo' => base64_encode($publickey['n']->toBytes()), 'exponent' => base64_encode($publickey['e']->toBytes())), 'message' => $message);
 }
开发者ID:Retired-Coder,项目名称:spotweb,代码行数:21,代码来源:SpotSigning.php

示例15: rsa

 public function rsa($hashAlg, $key)
 {
     $rsa = new Crypt_RSA();
     $rsa->loadKey($key);
     $rsa->setHash($hashAlg);
     $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
     return $rsa;
 }
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:8,代码来源:JWS.php


注:本文中的Crypt_RSA::setSignatureMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。