Index: net/ntlm/ntlm_client.h |
diff --git a/net/ntlm/ntlm_client.h b/net/ntlm/ntlm_client.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..db5d69b0558e142fdaa2953cbcd37e9388abc33d |
--- /dev/null |
+++ b/net/ntlm/ntlm_client.h |
@@ -0,0 +1,87 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Based on [MS-NLMP]: NT LAN Manager (NTLM) Authentication Protocol |
+// Specification version 28.0 [1]. Additional NTLM reference [2]. |
+// |
+// [1] https://msdn.microsoft.com/en-us/library/cc236621.aspx |
+// [2] http://davenport.sourceforge.net/ntlm.html |
+ |
+#ifndef NET_BASE_NTLM_CLIENT_H_ |
+#define NET_BASE_NTLM_CLIENT_H_ |
+ |
+#include <stddef.h> |
+#include <stdint.h> |
+ |
+#include <memory> |
+#include <string> |
+ |
+#include "base/strings/string16.h" |
+#include "base/strings/string_piece.h" |
+#include "net/base/net_export.h" |
+#include "net/ntlm/ntlm_constants.h" |
+ |
+namespace net { |
+namespace ntlm { |
+ |
+// Provides an implementation of an NTLMv1 Client. |
+// |
+// The implementation supports NTLMv1 with extended session security (NTLM2). |
+class NET_EXPORT_PRIVATE NtlmClient { |
+ public: |
+ NtlmClient(); |
+ ~NtlmClient(); |
+ |
+ // Returns a new buffer containing the Negotiate message that the caller |
+ // is responsible for cleaning up. |
asanka
2017/07/14 16:52:39
Let's discuss our buffer management strategy. I do
zentaro
2017/07/19 15:20:12
Done.
|
+ void GetNegotiateMessage(uint8_t** negotiate_message, |
+ size_t* negotiate_message_len) const; |
+ |
+ // Returns a new buffer containing the Authenticate message that the caller |
+ // is responsible for cleaning up. |
+ bool GenerateAuthenticateMessage(const base::string16& domain, |
+ const base::string16& username, |
+ const base::string16& password, |
+ const std::string& hostname, |
asanka
2017/07/14 16:52:39
Indicate how this is used, and whether a FQDN is r
zentaro
2017/07/19 15:20:12
Done.
|
+ const uint8_t* client_challenge, |
asanka
2017/07/14 16:52:39
Document buffer size and content.
zentaro
2017/07/19 15:20:12
Done.
|
+ const uint8_t* challenge_message, |
asanka
2017/07/14 16:52:39
Let's call this server_challenge_message or someth
zentaro
2017/07/19 15:20:12
Done.
|
+ size_t challenge_message_len, |
+ uint8_t** authenticate_message, |
+ size_t* authenticate_message_len) const; |
+ |
+ private: |
+ // Calculates the lengths and offset for all the payloads in the message. |
+ void CalculatePayloadLayout(bool is_unicode, |
+ const base::string16& domain, |
+ const base::string16& username, |
+ const std::string& hostname, |
+ SecurityBuffer* lm_info, |
+ SecurityBuffer* ntlm_info, |
+ SecurityBuffer* domain_info, |
+ SecurityBuffer* username_info, |
+ SecurityBuffer* hostname_info, |
+ size_t* authenticate_message_len) const; |
+ |
+ // Returns the length of the header part of the Authenticate message. |
+ // NOTE: When NTLMv2 support is added this is no longer a fixed value. |
+ size_t GetAuthenticateHeaderLength() const; |
+ |
+ // Returns the length of the NTLM response. |
+ // NOTE: When NTLMv2 support is added this is no longer a fixed value. |
+ size_t GetNtlmResponseLength() const; |
+ |
+ // Generates the negotiate message (which is always the same) into |
+ // |negotiate_message_|. |
+ void GenerateNegotiateMessage(); |
+ |
+ NegotiateFlags negotiate_flags_; |
+ std::unique_ptr<uint8_t[]> negotiate_message_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NtlmClient); |
+}; |
+ |
+} // namespace ntlm |
+} // namespace net |
+ |
+#endif // NET_BASE_NTLM_CLIENT_H_ |