Skip to content

Commit 5dced2b

Browse files
committed
Removing the now unnecessary random byte generator
dependency from the lm hasher
1 parent c1af530 commit 5dced2b

1 file changed

Lines changed: 3 additions & 26 deletions

File tree

src/Robin/Ntlm/Hasher/LmHasher.php

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Robin\Ntlm\Credential\Password;
1414
use Robin\Ntlm\Crypt\CipherMode;
1515
use Robin\Ntlm\Crypt\Des\DesEncrypterInterface;
16-
use Robin\Ntlm\Crypt\Random\RandomByteGeneratorInterface;
1716

1817
/**
1918
* Uses the "LM hash" computation strategy to hash a {@link Password} credential
@@ -52,14 +51,6 @@ class LmHasher implements HasherInterface
5251
*/
5352
const PASSWORD_SLICE_LENGTH = 7;
5453

55-
/**
56-
* The length of the randomly generated binary string used for generating
57-
* each piece of the resulting hash.
58-
*
59-
* @type int
60-
*/
61-
const RANDOM_BINARY_STRING_LENGTH = 8;
62-
6354
/**
6455
* The constant known ASCII text to encrypt with the generated keys.
6556
*
@@ -82,14 +73,6 @@ class LmHasher implements HasherInterface
8273
*/
8374
private $des_encrypter;
8475

85-
/**
86-
* The generator used to generate cryptographically secure random bytes to
87-
* provide an initialization vector for encryption.
88-
*
89-
* @type RandomByteGeneratorInterface
90-
*/
91-
private $random_byte_generator;
92-
9376

9477
/**
9578
* Methods
@@ -100,16 +83,10 @@ class LmHasher implements HasherInterface
10083
*
10184
* @param DesEncrypterInterface $des_encrypter The DES encryption engine
10285
* used to generate the hash.
103-
* @param RandomByteGeneratorInterface $random_byte_generator Used to
104-
* generate cryptographically secure random bytes to provide an
105-
* initialization vector for encryption.
10686
*/
107-
public function __construct(
108-
DesEncrypterInterface $des_encrypter,
109-
RandomByteGeneratorInterface $random_byte_generator
110-
) {
87+
public function __construct(DesEncrypterInterface $des_encrypter)
88+
{
11189
$this->des_encrypter = $des_encrypter;
112-
$this->random_byte_generator = $random_byte_generator;
11390
}
11491

11592
/**
@@ -137,7 +114,7 @@ function ($result, $half) {
137114
$half,
138115
static::ENCRYPT_DATA_CONSTANT,
139116
CipherMode::ECB,
140-
$this->random_byte_generator->generate(static::RANDOM_BINARY_STRING_LENGTH)
117+
'' // DES-ECB expects a 0-byte-length initialization vector
141118
);
142119
},
143120
''

0 commit comments

Comments
 (0)