Skip to content

Commit

Permalink
Revert "New NTLMv2 Implementation."
Browse files Browse the repository at this point in the history
This reverts commit a240cac.

Reason for revert: <INSERT REASONING HERE>
Cause build failure:
https://build.chromium.org/p/chromium.linux/builders/Cast%20Audio%20Linux/builds/4848

Original change's description:
> New NTLMv2 Implementation.
> 
> - Supports NTLMv2 with Extended Protection for Authentication (EPA)
>   and Message Integrity Check (MIC).
> - Adds required methods to buffer reader/writers to support NTLMv2
> - Adds optional version/mic fields to all messages
> - Removes protocol level tests from HttpAuthHandlerNtlmPortableTest.
>   A previous CL already implemented all those tests directly against
>   NtlmClient. The tests at that level only existed to validate that
>   the behavior of the old and new implementation were the same.
> - Future CL updates fuzzer to support v2.
> - This CL does not activate NTLMv2. The code still defaults to NTLMv1.
> 
> BUG=chromium:22532
> 
> Change-Id: I5b6dcbf6cdcf8f671008f60ae49c9bacb4e1d2f3
> Reviewed-on: https://chromium-review.googlesource.com/608620
> Commit-Queue: Zentaro Kavanagh <zentaro@google.com>
> Reviewed-by: Asanka Herath <asanka@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#504808}

TBR=rsleevi@chromium.org,zentaro@google.com,asanka@chromium.org

Change-Id: Ie6fead019bc26fa2394ba50d19f7c4e10772e566
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:22532
Reviewed-on: https://chromium-review.googlesource.com/688800
Reviewed-by: Xida Chen <xidachen@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#504811}
  • Loading branch information
xidachen authored and Commit Bot committed Sep 28, 2017
1 parent 15d4e52 commit 950d94c
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 1,965 deletions.
16 changes: 3 additions & 13 deletions net/http/http_auth_handler_ntlm.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler {
};

#if defined(NTLM_PORTABLE)
// A function that returns the time as the number of 100 nanosecond ticks
// since Jan 1, 1601 (UTC).
typedef uint64_t (*GetMSTimeProc)();

// A function that generates n random bytes in the output buffer.
typedef void (*GenerateRandomProc)(uint8_t* output, size_t n);

Expand All @@ -87,22 +83,18 @@ class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler {
// GetHostName functions.
class ScopedProcSetter {
public:
ScopedProcSetter(GetMSTimeProc ms_time_proc,
GenerateRandomProc random_proc,
ScopedProcSetter(GenerateRandomProc random_proc,
HostNameProc host_name_proc) {
old_ms_time_proc_ = SetGetMSTimeProc(ms_time_proc);
old_random_proc_ = SetGenerateRandomProc(random_proc);
old_host_name_proc_ = SetHostNameProc(host_name_proc);
}

~ScopedProcSetter() {
SetGetMSTimeProc(old_ms_time_proc_);
SetGenerateRandomProc(old_random_proc_);
SetHostNameProc(old_host_name_proc_);
}

private:
GetMSTimeProc old_ms_time_proc_;
GenerateRandomProc old_random_proc_;
HostNameProc old_host_name_proc_;
};
Expand Down Expand Up @@ -140,9 +132,8 @@ class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler {
~HttpAuthHandlerNTLM() override;

#if defined(NTLM_PORTABLE)
// For unit tests to override the GetMSTime, GenerateRandom and GetHostName
// functions. Returns the old function.
static GetMSTimeProc SetGetMSTimeProc(GetMSTimeProc proc);
// For unit tests to override the GenerateRandom and GetHostName functions.
// Returns the old function.
static GenerateRandomProc SetGenerateRandomProc(GenerateRandomProc proc);
static HostNameProc SetHostNameProc(HostNameProc proc);

Expand All @@ -165,7 +156,6 @@ class NET_EXPORT_PRIVATE HttpAuthHandlerNTLM : public HttpAuthHandler {
#endif

#if defined(NTLM_PORTABLE)
static GetMSTimeProc get_ms_time_proc_;
static GenerateRandomProc generate_random_proc_;
static HostNameProc get_host_name_proc_;
#endif
Expand Down
24 changes: 2 additions & 22 deletions net/http/http_auth_handler_ntlm_portable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,19 @@
#include "net/http/http_auth_handler_ntlm.h"

#include "base/rand_util.h"
#include "base/time/time.h"
#include "net/base/net_errors.h"
#include "net/base/network_interfaces.h"

namespace net {

namespace {

uint64_t GetMSTime() {
return base::Time::Now().since_origin().InMicroseconds() * 10;
}

void GenerateRandom(uint8_t* output, size_t n) {
base::RandBytes(output, n);
}

} // namespace

// static
HttpAuthHandlerNTLM::GetMSTimeProc HttpAuthHandlerNTLM::get_ms_time_proc_ =
GetMSTime;

// static
HttpAuthHandlerNTLM::GenerateRandomProc
HttpAuthHandlerNTLM::generate_random_proc_ = GenerateRandom;
Expand All @@ -35,8 +26,7 @@ HttpAuthHandlerNTLM::GenerateRandomProc
HttpAuthHandlerNTLM::HostNameProc HttpAuthHandlerNTLM::get_host_name_proc_ =
GetHostName;

HttpAuthHandlerNTLM::HttpAuthHandlerNTLM()
: ntlm_client_(ntlm::NtlmFeatures(false)) {}
HttpAuthHandlerNTLM::HttpAuthHandlerNTLM() : ntlm_client_() {}

bool HttpAuthHandlerNTLM::NeedsIdentity() {
// This gets called for each round-trip. Only require identity on
Expand All @@ -57,14 +47,6 @@ int HttpAuthHandlerNTLM::InitializeBeforeFirstChallenge() {

HttpAuthHandlerNTLM::~HttpAuthHandlerNTLM() {}

// static
HttpAuthHandlerNTLM::GetMSTimeProc HttpAuthHandlerNTLM::SetGetMSTimeProc(
GetMSTimeProc proc) {
GetMSTimeProc old_proc = get_ms_time_proc_;
get_ms_time_proc_ = proc;
return old_proc;
}

// static
HttpAuthHandlerNTLM::GenerateRandomProc
HttpAuthHandlerNTLM::SetGenerateRandomProc(GenerateRandomProc proc) {
Expand Down Expand Up @@ -98,12 +80,10 @@ ntlm::Buffer HttpAuthHandlerNTLM::GetNextToken(const ntlm::Buffer& in_token) {
return ntlm::Buffer();
uint8_t client_challenge[8];
generate_random_proc_(client_challenge, 8);
uint64_t client_time = get_ms_time_proc_();

return ntlm_client_.GenerateAuthenticateMessage(
domain_, credentials_.username(), credentials_.password(), hostname,
channel_bindings_, CreateSPN(origin_), client_time, client_challenge,
in_token);
client_challenge, in_token);
}

int HttpAuthHandlerNTLM::Factory::CreateAuthHandler(
Expand Down
Loading

0 comments on commit 950d94c

Please sign in to comment.