Skip to content

Commit 93fb234

Browse files
committed
Merge pull request #3 from Rican7/bugfix/handling-no-lm-hash
Bugfix - Handling no LM hash
2 parents 5da8f81 + aeede34 commit 93fb234

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

src/Robin/Ntlm/Message/NtlmV1AuthenticateMessageEncoder.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,20 +196,32 @@ public function encode(
196196
}
197197
}
198198

199-
if (null !== $lm_hash && $calculate_lm_response) {
200-
$lm_challenge_response = $this->calculateLmResponse(
201-
$lm_hash,
199+
if (null !== $nt_hash && $calculate_nt_response) {
200+
$nt_challenge_response = $this->calculateNtResponse(
201+
$nt_hash,
202202
$client_challenge,
203203
$server_challenge_nonce
204204
);
205205
}
206206

207-
if (null !== $nt_hash && $calculate_nt_response) {
208-
$nt_challenge_response = $this->calculateNtResponse(
209-
$nt_hash,
207+
// If we have a client challenge, extended session security must be negotiated
208+
if (null !== $client_challenge) {
209+
// Set the LM challenge response to the client challenge, null-padded to the expected length
210+
$lm_challenge_response = str_pad(
211+
$client_challenge,
212+
static::LM_RESPONSE_LENGTH,
213+
static::NULL_PAD_CHARACTER
214+
);
215+
} elseif (null !== $lm_hash && $calculate_lm_response) {
216+
$lm_challenge_response = $this->calculateLmResponse(
217+
$lm_hash,
210218
$client_challenge,
211219
$server_challenge_nonce
212220
);
221+
} else {
222+
// According to the spec, we're supposed to use the NT challenge response for the LM challenge response,
223+
// if an LM challenge response isn't calculated
224+
$lm_challenge_response = $nt_challenge_response;
213225
}
214226

215227
// TODO: Generate an encrypted random session key
@@ -229,6 +241,10 @@ public function encode(
229241
/**
230242
* Calculates the LM response.
231243
*
244+
* TODO: Remove this method as it's no longer necessary.
245+
*
246+
* @deprecated This logic is now a simple pass-through to
247+
* {@link self::calculateChallengeResponseData()}.
232248
* @param HashCredentialInterface $hash_credential The user's authentication
233249
* LM hash credential.
234250
* @param string|null $client_challenge A randomly generated 64-bit (8-byte)
@@ -242,19 +258,7 @@ public function calculateLmResponse(
242258
$client_challenge = null,
243259
$server_challenge_nonce = null
244260
) {
245-
// If we have a client challenge, extended session security must be negotiated
246-
if (null !== $client_challenge) {
247-
// Set the LM challenge response to the client challenge, null-padded to the expected length
248-
$lm_challenge_response = str_pad(
249-
$client_challenge,
250-
static::LM_RESPONSE_LENGTH,
251-
static::NULL_PAD_CHARACTER
252-
);
253-
} else {
254-
$lm_challenge_response = $this->calculateChallengeResponseData($hash_credential, $server_challenge_nonce);
255-
}
256-
257-
return $lm_challenge_response;
261+
return $this->calculateChallengeResponseData($hash_credential, $server_challenge_nonce);
258262
}
259263

260264
/**

0 commit comments

Comments
 (0)