Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "MDL-31248 - lib - Alteration to the rc4encrypt function to al…

…low for old password use."

This reverts commit 0c9edc9.
  • Loading branch information...
commit 0e2a80c97bb9fad6436010fe2b2d69234e34db35 1 parent f194dcf
@stronk7 stronk7 authored
Showing with 13 additions and 31 deletions.
  1. +10 −20 lib/moodlelib.php
  2. +3 −11 lib/sessionlib.php
View
30 lib/moodlelib.php
@@ -6804,17 +6804,12 @@ protected function prepare_emoticon_object($text, $imagename, $altidentifier = n
*
* @todo Finish documenting this function
*
- * @param string $data Data to encrypt.
- * @param bool $usesecurekey Lets us know if we are using the old or new password.
- * @return string The now encrypted data.
+ * @param string $data Data to encrypt
+ * @return string The now encrypted data
*/
-function rc4encrypt($data, $usesecurekey = false) {
- if (!$usesecurekey) {
- $passwordkey = 'nfgjeingjk';
- } else {
- $passwordkey = get_site_identifier();
- }
- return endecrypt($passwordkey, $data, '');
+function rc4encrypt($data) {
+ $password = get_site_identifier();
+ return endecrypt($password, $data, '');
}
/**
@@ -6822,17 +6817,12 @@ function rc4encrypt($data, $usesecurekey = false) {
*
* @todo Finish documenting this function
*
- * @param string $data Data to decrypt.
- * @param bool $usesecurekey Lets us know if we are using the old or new password.
- * @return string The now decrypted data.
+ * @param string $data Data to decrypt
+ * @return string The now decrypted data
*/
-function rc4decrypt($data, $usesecurekey = false) {
- if (!$usesecurekey) {
- $passwordkey = 'nfgjeingjk';
- } else {
- $passwordkey = get_site_identifier();
- }
- return endecrypt($passwordkey, $data, 'de');
+function rc4decrypt($data) {
+ $password = get_site_identifier();
+ return endecrypt($password, $data, 'de');
}
/**
View
14 lib/sessionlib.php
@@ -828,7 +828,7 @@ function set_moodle_cookie($username) {
if ($username !== '') {
// set username cookie for 60 days
- setcookie($cookiename, rc4encrypt($username, true), time()+(DAYSECS*60), $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure, $CFG->cookiehttponly);
+ setcookie($cookiename, rc4encrypt($username), time()+(DAYSECS*60), $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure, $CFG->cookiehttponly);
}
}
@@ -849,18 +849,10 @@ function get_moodle_cookie() {
if (empty($_COOKIE[$cookiename])) {
return '';
} else {
- $username = rc4decrypt($_COOKIE[$cookiename], true);
- if ($username != clean_param($username, PARAM_USERNAME)) {
- $username = rc4decrypt($_COOKIE[$cookiename]);
- if ($username == clean_param($username, PARAM_USERNAME)) {
- set_moodle_cookie($username);
- } else {
- $username = '';
- }
- }
+ $username = rc4decrypt($_COOKIE[$cookiename]);
if ($username === 'guest' or $username === 'nobody') {
// backwards compatibility - we do not set these cookies any more
- $username = '';
+ return '';
}
return $username;
}
Please sign in to comment.
Something went wrong with that request. Please try again.