mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
Merge branch 'MDL-37625-master' of https://github.com/jfilip/moodle
This commit is contained in:
commit
74bf99ddad
1 changed files with 8 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Copyright (c) 2002-2003, Michael Bretterklieber <michael@bretterklieber.com>
|
Copyright (c) 2002-2010, Michael Bretterklieber <michael@bretterklieber.com>
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -101,7 +101,6 @@ class Crypt_CHAP extends PEAR
|
||||||
function generateChallenge($varname = 'challenge', $size = 8)
|
function generateChallenge($varname = 'challenge', $size = 8)
|
||||||
{
|
{
|
||||||
$this->$varname = '';
|
$this->$varname = '';
|
||||||
mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
|
|
||||||
for ($i = 0; $i < $size; $i++) {
|
for ($i = 0; $i < $size; $i++) {
|
||||||
$this->$varname .= pack('C', 1 + mt_rand() % 255);
|
$this->$varname .= pack('C', 1 + mt_rand() % 255);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +148,7 @@ class Crypt_CHAP_MD5 extends Crypt_CHAP
|
||||||
* Generate MS-CHAPv1 Packets. MS-CHAP doesen't use the plaintext password, it uses the
|
* Generate MS-CHAPv1 Packets. MS-CHAP doesen't use the plaintext password, it uses the
|
||||||
* NT-HASH wich is stored in the SAM-Database or in the smbpasswd, if you are using samba.
|
* NT-HASH wich is stored in the SAM-Database or in the smbpasswd, if you are using samba.
|
||||||
* The NT-HASH is MD4(str2unicode(plaintextpass)).
|
* The NT-HASH is MD4(str2unicode(plaintextpass)).
|
||||||
* You need the mhash extension for this class.
|
* You need the hash extension for this class.
|
||||||
*
|
*
|
||||||
* @package Crypt_CHAP
|
* @package Crypt_CHAP
|
||||||
*/
|
*/
|
||||||
|
@ -165,13 +164,13 @@ class Crypt_CHAP_MSv1 extends Crypt_CHAP
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* Loads the mhash extension
|
* Loads the hash extension
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function Crypt_CHAP_MSv1()
|
function Crypt_CHAP_MSv1()
|
||||||
{
|
{
|
||||||
$this->Crypt_CHAP();
|
$this->Crypt_CHAP();
|
||||||
$this->loadExtension('mhash');
|
$this->loadExtension('hash');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,9 +182,9 @@ class Crypt_CHAP_MSv1 extends Crypt_CHAP
|
||||||
function ntPasswordHash($password = null)
|
function ntPasswordHash($password = null)
|
||||||
{
|
{
|
||||||
if (isset($password)) {
|
if (isset($password)) {
|
||||||
return mhash(MHASH_MD4, $this->str2unicode($password));
|
return pack('H*',hash('md4', $this->str2unicode($password)));
|
||||||
} else {
|
} else {
|
||||||
return mhash(MHASH_MD4, $this->str2unicode($this->password));
|
return pack('H*',hash('md4', $this->str2unicode($this->password)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +431,7 @@ class Crypt_CHAP_MSv2 extends Crypt_CHAP_MSv1
|
||||||
*/
|
*/
|
||||||
function ntPasswordHashHash($nthash)
|
function ntPasswordHashHash($nthash)
|
||||||
{
|
{
|
||||||
return mhash(MHASH_MD4, $nthash);
|
return pack('H*',hash('md4', $nthash));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -444,7 +443,7 @@ class Crypt_CHAP_MSv2 extends Crypt_CHAP_MSv1
|
||||||
*/
|
*/
|
||||||
function challengeHash()
|
function challengeHash()
|
||||||
{
|
{
|
||||||
return substr(mhash(MHASH_SHA1, $this->peerChallenge . $this->authChallenge . $this->username), 0, 8);
|
return substr(pack('H*',hash('sha1', $this->peerChallenge . $this->authChallenge . $this->username)), 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue