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


PHP Auth_OpenID_getMathLib函數代碼示例

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


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

示例1: Auth_OpenID_DiffieHellman

    function Auth_OpenID_DiffieHellman($mod = null, $gen = null,
                                       $private = null, $lib = null)
    {
        if ($lib === null) {
            $this->lib =& Auth_OpenID_getMathLib();
        } else {
            $this->lib =& $lib;
        }

        if ($mod === null) {
            $this->mod = $this->lib->init(Auth_OpenID_getDefaultMod());
        } else {
            $this->mod = $mod;
        }

        if ($gen === null) {
            $this->gen = $this->lib->init(Auth_OpenID_getDefaultGen());
        } else {
            $this->gen = $gen;
        }

        if ($private === null) {
            $r = $this->lib->rand($this->mod);
            $this->private = $this->lib->add($r, 1);
        } else {
            $this->private = $private;
        }

        $this->public = $this->lib->powmod($this->gen, $this->private,
                                           $this->mod);
    }
開發者ID:networksoft,項目名稱:seekerplus2.com,代碼行數:31,代碼來源:DiffieHellman.php

示例2: runTest

 function runTest()
 {
     $lib =& Auth_OpenID_getMathLib();
     $shared = $lib->init($this->shared);
     $dh1 = new Auth_OpenID_DiffieHellman(null, null, $this->p1);
     $dh2 = new Auth_OpenID_DiffieHellman(null, null, $this->p2);
     $sh1 = $dh1->getSharedSecret($dh2->getPublicKey());
     $sh2 = $dh2->getSharedSecret($dh1->getPublicKey());
     $this->assertEquals($lib->cmp($shared, $sh1), 0);
     $this->assertEquals($lib->cmp($shared, $sh2), 0);
 }
開發者ID:Jobava,項目名稱:diacritice-meta-repo,代碼行數:11,代碼來源:DiffieHellman.php

示例3: answer

	function answer($secret)
	{
		$lib =& Auth_OpenID_getMathLib();
		$mac_key = $this->dh->xorSecret($this->consumer_pubkey, $secret,
		$this->hash_func);
		return array(
           'dh_server_public' =>
		$lib->longToBase64($this->dh->public),
           'enc_mac_key' => base64_encode($mac_key));
	}
開發者ID:hoalangoc,項目名稱:ftf,代碼行數:10,代碼來源:Server.php

示例4: serverAssociate

 /**
  * Perform the server side of the OpenID Diffie-Hellman association
  */
 function serverAssociate($consumer_args, $assoc_secret)
 {
     $lib =& Auth_OpenID_getMathLib();
     if (isset($consumer_args['openid.dh_modulus'])) {
         $mod = $lib->base64ToLong($consumer_args['openid.dh_modulus']);
     } else {
         $mod = null;
     }
     if (isset($consumer_args['openid.dh_gen'])) {
         $gen = $lib->base64ToLong($consumer_args['openid.dh_gen']);
     } else {
         $gen = null;
     }
     $cpub64 = @$consumer_args['openid.dh_consumer_public'];
     if (!isset($cpub64)) {
         return false;
     }
     $dh = new Auth_OpenID_DiffieHellman($mod, $gen);
     $cpub = $lib->base64ToLong($cpub64);
     $mac_key = $dh->xorSecret($cpub, $assoc_secret);
     $enc_mac_key = base64_encode($mac_key);
     $spub64 = $lib->longToBase64($dh->getPublicKey());
     $server_args = array('session_type' => 'DH-SHA1', 'dh_server_public' => $spub64, 'enc_mac_key' => $enc_mac_key);
     return $server_args;
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:28,代碼來源:DiffieHellman.php

示例5: extractSecret

 function extractSecret($response)
 {
     if (!$response->hasKey(Auth_OpenID_OPENID_NS, 'dh_server_public')) {
         return null;
     }
     if (!$response->hasKey(Auth_OpenID_OPENID_NS, 'enc_mac_key')) {
         return null;
     }
     $math = Auth_OpenID_getMathLib();
     $spub = $math->base64ToLong($response->getArg(Auth_OpenID_OPENID_NS, 'dh_server_public'));
     $enc_mac_key = base64_decode($response->getArg(Auth_OpenID_OPENID_NS, 'enc_mac_key'));
     return $this->dh->xorSecret($spub, $enc_mac_key, $this->hash_func);
 }
開發者ID:raphox,項目名稱:php-openid,代碼行數:13,代碼來源:Consumer.php

示例6: answer

 function answer($assoc)
 {
     $ml =& Auth_OpenID_getMathLib();
     $response = new Auth_OpenID_ServerResponse($this);
     $response->fields = array('expires_in' => $assoc->getExpiresIn(), 'assoc_type' => 'HMAC-SHA1', 'assoc_handle' => $assoc->handle);
     $r = $this->session->answer($assoc->secret);
     foreach ($r as $k => $v) {
         $response->fields[$k] = $v;
     }
     if ($this->session->session_type != 'plaintext') {
         $response->fields['session_type'] = $this->session->session_type;
     }
     return $response;
 }
開發者ID:Fellah,項目名稱:govnobaki,代碼行數:14,代碼來源:Server.php

示例7: Auth_OpenID_include_init

function Auth_OpenID_include_init()
{
    if (Auth_OpenID_getMathLib() === null) {
        Auth_OpenID_setNoMathSupport();
    }
}
開發者ID:rb26,項目名稱:zenphoto,代碼行數:6,代碼來源:OpenID.php

示例8: define

/**
 * Status code returned when there were no OpenID arguments
 * passed. This code indicates that the caller should return a 200 OK
 * response and display an HTML page that says that this is an OpenID
 * server endpoint.
 *
 * @see Auth_OpenID_Server
 */
define('Auth_OpenID_DO_ABOUT', 'do_about');
/**
 * Defines for regexes and format checking.
 */
define('Auth_OpenID_letters', "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
define('Auth_OpenID_digits', "0123456789");
define('Auth_OpenID_punct', "!\"#\$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
if (Auth_OpenID_getMathLib() === null) {
    Auth_OpenID_setNoMathSupport();
}
/**
 * The OpenID utility function class.
 *
 * @package OpenID
 * @access private
 */
class Auth_OpenID
{
    /**
     * Return true if $thing is an Auth_OpenID_FailureResponse object;
     * false if not.
     *
     * @access private
開發者ID:Kraiany,項目名稱:kraiany_site_docker,代碼行數:31,代碼來源:OpenID.php

示例9: setUp

 function setUp()
 {
     // Pre-compute DH with small prime so tests run quickly.
     $this->server_dh = new Auth_OpenID_DiffieHellman(100389557, 2);
     $this->consumer_dh = new Auth_OpenID_DiffieHellman(100389557, 2);
     $lib =& Auth_OpenID_getMathLib();
     $cls = $this->session_cls;
     $this->consumer_session = new $cls($this->consumer_dh);
     // base64(btwoc(g ^ xb mod p))
     $this->dh_server_public = $lib->longToBase64($this->server_dh->public);
     $this->secret = Auth_OpenID_CryptUtil::randomString($this->consumer_session->secret_size);
     $this->enc_mac_key = base64_encode($this->server_dh->xorSecret($this->consumer_dh->public, $this->secret, $this->consumer_session->hash_func));
     $this->msg = new Auth_OpenID_Message($this->message_namespace);
 }
開發者ID:umbecr,項目名稱:camilaframework,代碼行數:14,代碼來源:Consumer.php

示例10: test_dh

 function test_dh()
 {
     if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) {
         $dh = new Auth_OpenID_DiffieHellman();
         $ml =& Auth_OpenID_getMathLib();
         $cpub = $dh->public;
         $session = new Auth_OpenID_DiffieHellmanServerSession(new Auth_OpenID_DiffieHellman(), $cpub);
         $this->request = new Auth_OpenID_AssociateRequest($session);
         $response = $this->request->answer($this->assoc);
         $this->assertEquals(Auth_OpenID::arrayGet($response->fields, "assoc_type"), "HMAC-SHA1");
         $this->assertEquals(Auth_OpenID::arrayGet($response->fields, "assoc_handle"), $this->assoc->handle);
         $this->assertFalse(Auth_OpenID::arrayGet($response->fields, "mac_key"));
         $this->assertEquals(Auth_OpenID::arrayGet($response->fields, "session_type"), "DH-SHA1");
         $this->assertTrue(Auth_OpenID::arrayGet($response->fields, "enc_mac_key"));
         $this->assertTrue(Auth_OpenID::arrayGet($response->fields, "dh_server_public"));
         $enc_key = base64_decode(Auth_OpenID::arrayGet($response->fields, "enc_mac_key"));
         $spub = $ml->base64ToLong(Auth_OpenID::arrayGet($response->fields, "dh_server_public"));
         $secret = $dh->xorSecret($spub, $enc_key);
         $this->assertEquals($secret, $this->assoc->secret);
     }
 }
開發者ID:aprilchild,項目名稱:aprilchild,代碼行數:21,代碼來源:Server.php

示例11: extractSecret

 function extractSecret($response)
 {
     if (!array_key_exists('dh_server_public', $response)) {
         return null;
     }
     if (!array_key_exists('enc_mac_key', $response)) {
         return null;
     }
     $math =& Auth_OpenID_getMathLib();
     $spub = $math->base64ToLong($response['dh_server_public']);
     $enc_mac_key = base64_decode($response['enc_mac_key']);
     return $this->dh->xorSecret($spub, $enc_mac_key);
 }
開發者ID:JJYing,項目名稱:Anyway-Website,代碼行數:13,代碼來源:Consumer.php

示例12: define

/**
 * Status code returned when there were no OpenID arguments
 * passed. This code indicates that the caller should return a 200 OK
 * response and display an HTML page that says that this is an OpenID
 * server endpoint.
 *
 * @see Auth_OpenID_Server
 */
define('Auth_OpenID_DO_ABOUT', 'do_about');
/**
 * Defines for regexes and format checking.
 */
define('Auth_OpenID_letters', "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
define('Auth_OpenID_digits', "0123456789");
define('Auth_OpenID_punct', "!\"#\$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
if (Auth_OpenID_getMathLib() === null && !defined('Auth_OpenID_NO_MATH_SUPPORT')) {
    define('Auth_OpenID_NO_MATH_SUPPORT', true);
}
/**
 * The OpenID utility function class.
 *
 * @package OpenID
 * @access private
 */
class Auth_OpenID
{
    /**
     * Return true if $thing is an Auth_OpenID_FailureResponse object;
     * false if not.
     *
     * @access private
開發者ID:ramziammar,項目名稱:websites,代碼行數:31,代碼來源:OpenID.php

示例13: test_dhSHA256

 function test_dhSHA256()
 {
     if (defined('Auth_OpenID_NO_MATH_SUPPORT') || !Auth_OpenID_SHA256_SUPPORTED) {
         print "(Skipping test_dhSHA256)";
         return;
     }
     $this->assoc = $this->signatory->createAssociation(false, 'HMAC-SHA256');
     $consumer_dh = new Auth_OpenID_DiffieHellman();
     $cpub = $consumer_dh->public;
     $server_dh = new Auth_OpenID_DiffieHellman();
     $session = new Auth_OpenID_DiffieHellmanSHA256ServerSession($server_dh, $cpub);
     $this->request = new Auth_OpenID_AssociateRequest($session, 'HMAC-SHA256');
     $response = $this->request->answer($this->assoc);
     $this->assertFalse($response->fields->getArg(Auth_OpenID_OPENID_NS, "mac_key"));
     $this->assertTrue($response->fields->getArg(Auth_OpenID_OPENID_NS, "enc_mac_key"));
     $this->assertTrue($response->fields->getArg(Auth_OpenID_OPENID_NS, "dh_server_public"));
     $fields = array('assoc_type' => 'HMAC-SHA256', 'assoc_handle' => $this->assoc->handle, 'session_type' => 'DH-SHA256');
     foreach ($fields as $k => $v) {
         $this->assertEquals($response->fields->getArg(Auth_OpenID_OPENID_NS, $k), $v);
     }
     $enc_key = base64_decode($response->fields->getArg(Auth_OpenID_OPENID_NS, "enc_mac_key"));
     $lib =& Auth_OpenID_getMathLib();
     $spub = $lib->base64ToLong($response->fields->getArg(Auth_OpenID_OPENID_NS, "dh_server_public"));
     $secret = $consumer_dh->xorSecret($spub, $enc_key, 'Auth_OpenID_SHA256');
     $s = base64_encode($secret);
     $assoc_s = base64_encode($this->assoc->secret);
     $this->assertEquals($s, $assoc_s);
 }
開發者ID:alexandreeffetb,項目名稱:yos-social-php5,代碼行數:28,代碼來源:Server.php

示例14: Tests_Auth_OpenID_BigMath

 function Tests_Auth_OpenID_BigMath($name)
 {
     $this->setName($name);
     if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) {
         $this->addTestSuite('Tests_Auth_OpenID_BigInt');
         $this->_addB64Tests();
         $this->_addBinLongTests();
         $test = new Tests_Auth_OpenID_Rand(Auth_OpenID_getMathLib());
         $test->setName('Big number rand');
         $this->addTest($test);
     }
 }
開發者ID:Jobava,項目名稱:diacritice-meta-repo,代碼行數:12,代碼來源:BigMath.php


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