summaryrefslogtreecommitdiff
path: root/modules/openid
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2013-11-20 15:45:59 -0500
committerDavid Rothstein <drothstein@gmail.com>2013-11-20 15:45:59 -0500
commit782d1155c62c0a879bf587c7e40c3a13bcf6879c (patch)
tree380060c81a7ebd76870cfd7fb566933b3a7c6efd /modules/openid
parentbf704d6ffe55d66a440a55a9d43e8846d46d2440 (diff)
downloadbrdo-782d1155c62c0a879bf587c7e40c3a13bcf6879c.tar.gz
brdo-782d1155c62c0a879bf587c7e40c3a13bcf6879c.tar.bz2
Drupal 7.24
Diffstat (limited to 'modules/openid')
-rw-r--r--modules/openid/openid.inc23
-rw-r--r--modules/openid/openid.test7
-rw-r--r--modules/openid/tests/openid_test.install2
3 files changed, 6 insertions, 26 deletions
diff --git a/modules/openid/openid.inc b/modules/openid/openid.inc
index 74a08d576..d7ef663b4 100644
--- a/modules/openid/openid.inc
+++ b/modules/openid/openid.inc
@@ -380,6 +380,9 @@ function _openid_parse_message($message) {
/**
* Return a nonce value - formatted per OpenID spec.
+ *
+ * NOTE: This nonce is not cryptographically secure and only suitable for use
+ * by the test framework.
*/
function _openid_nonce() {
// YYYY-MM-DDThh:mm:ssZ, plus some optional extra unique characters.
@@ -549,7 +552,7 @@ function _openid_dh_rand($stop) {
}
do {
- $bytes = "\x00" . _openid_get_bytes($nbytes);
+ $bytes = "\x00" . drupal_random_bytes($nbytes);
$n = _openid_dh_binary_to_long($bytes);
// Keep looping if this value is in the low duplicated range.
} while (_openid_math_cmp($n, $duplicate) < 0);
@@ -558,23 +561,7 @@ function _openid_dh_rand($stop) {
}
function _openid_get_bytes($num_bytes) {
- $f = &drupal_static(__FUNCTION__);
- $bytes = '';
- if (!isset($f)) {
- $f = @fopen(OPENID_RAND_SOURCE, "r");
- }
- if (!$f) {
- // pseudorandom used
- $bytes = '';
- for ($i = 0; $i < $num_bytes; $i += 4) {
- $bytes .= pack('L', mt_rand());
- }
- $bytes = substr($bytes, 0, $num_bytes);
- }
- else {
- $bytes = fread($f, $num_bytes);
- }
- return $bytes;
+ return drupal_random_bytes($num_bytes);
}
function _openid_response($str = NULL) {
diff --git a/modules/openid/openid.test b/modules/openid/openid.test
index 292c5317c..41af3f82f 100644
--- a/modules/openid/openid.test
+++ b/modules/openid/openid.test
@@ -695,13 +695,6 @@ class OpenIDTestCase extends DrupalWebTestCase {
}
/**
- * Test _openid_get_bytes().
- */
- function testOpenidGetBytes() {
- $this->assertEqual(strlen(_openid_get_bytes(20)), 20, '_openid_get_bytes() returned expected result.');
- }
-
- /**
* Test _openid_signature().
*/
function testOpenidSignature() {
diff --git a/modules/openid/tests/openid_test.install b/modules/openid/tests/openid_test.install
index 3bd4978f1..d30e2dc4d 100644
--- a/modules/openid/tests/openid_test.install
+++ b/modules/openid/tests/openid_test.install
@@ -13,5 +13,5 @@ function openid_test_install() {
// Generate a MAC key (Message Authentication Code) used for signing messages.
// The variable is base64-encoded, because variables cannot contain non-UTF-8
// data.
- variable_set('openid_test_mac_key', base64_encode(_openid_get_bytes(20)));
+ variable_set('openid_test_mac_key', drupal_random_key(20));
}