Skip to content

Commit c1af530

Browse files
committed
Removing code that's now handled at a different
layer
1 parent 2f737f9 commit c1af530

1 file changed

Lines changed: 1 addition & 39 deletions

File tree

src/Robin/Ntlm/Hasher/LmHasher.php

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Robin\Ntlm\Crypt\CipherMode;
1515
use Robin\Ntlm\Crypt\Des\DesEncrypterInterface;
1616
use Robin\Ntlm\Crypt\Random\RandomByteGeneratorInterface;
17-
use SplFixedArray;
1817

1918
/**
2019
* Uses the "LM hash" computation strategy to hash a {@link Password} credential
@@ -134,10 +133,8 @@ public function hash(Password $password)
134133
$binary_hash = array_reduce(
135134
$halves,
136135
function ($result, $half) {
137-
$expanded = static::expand56BitKeyTo64BitKey($half);
138-
139136
return $result . $this->des_encrypter->encrypt(
140-
$expanded,
137+
$half,
141138
static::ENCRYPT_DATA_CONSTANT,
142139
CipherMode::ECB,
143140
$this->random_byte_generator->generate(static::RANDOM_BINARY_STRING_LENGTH)
@@ -148,39 +145,4 @@ function ($result, $half) {
148145

149146
return Hash::fromBinaryString($binary_hash, HashType::LM);
150147
}
151-
152-
/**
153-
* Expands a 56-bit key to a full 64-bit key for DES encryption.
154-
*
155-
* @link http://php.net/manual/en/ref.hash.php#84587 Implementation basis.
156-
* @link https://github.com/jclulow/node-smbhash/blob/edc48e2b93067/lib/common.js Inspired by Joshua Clulow's work.
157-
* @param string $string_key The 56-bit key to expand
158-
* @return string
159-
*/
160-
public static function expand56BitKeyTo64BitKey($string_key)
161-
{
162-
$byte_array_56 = new SplFixedArray(7);
163-
$byte_array_64 = new SplFixedArray(8);
164-
$key_64bit = '';
165-
166-
// Get the byte value of each ASCII character in the string
167-
for ($i = 0; $i < $byte_array_56->getSize(); $i++) {
168-
$byte_array_56[$i] = isset($string_key[$i]) ? ord($string_key[$i]) : 0;
169-
}
170-
171-
$byte_array_64[0] = $byte_array_56[0] & 254;
172-
$byte_array_64[1] = ($byte_array_56[0] << 7) | ($byte_array_56[1] >> 1);
173-
$byte_array_64[2] = ($byte_array_56[1] << 6) | ($byte_array_56[2] >> 2);
174-
$byte_array_64[3] = ($byte_array_56[2] << 5) | ($byte_array_56[3] >> 3);
175-
$byte_array_64[4] = ($byte_array_56[3] << 4) | ($byte_array_56[4] >> 4);
176-
$byte_array_64[5] = ($byte_array_56[4] << 3) | ($byte_array_56[5] >> 5);
177-
$byte_array_64[6] = ($byte_array_56[5] << 2) | ($byte_array_56[6] >> 6);
178-
$byte_array_64[7] = $byte_array_56[6] << 1;
179-
180-
foreach ($byte_array_64 as $byte_val) {
181-
$key_64bit .= chr($byte_val);
182-
}
183-
184-
return $key_64bit;
185-
}
186148
}

0 commit comments

Comments
 (0)