OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Based on [MS-NLMP]: NT LAN Manager (NTLM) Authentication Protocol | |
6 // Specification version 28.0 [1]. Additional NTLM reference [2]. | |
7 // | |
8 // [1] https://msdn.microsoft.com/en-us/library/cc236621.aspx | |
9 // [2] http://davenport.sourceforge.net/ntlm.html | |
10 | |
11 #ifndef NET_BASE_NTLM_CLIENT_H_ | |
12 #define NET_BASE_NTLM_CLIENT_H_ | |
13 | |
14 #include <stddef.h> | |
15 #include <stdint.h> | |
16 | |
17 #include <memory> | |
18 #include <string> | |
19 | |
20 #include "base/strings/string16.h" | |
21 #include "base/strings/string_piece.h" | |
22 #include "net/base/net_export.h" | |
23 #include "net/ntlm/ntlm_constants.h" | |
24 | |
25 namespace net { | |
26 namespace ntlm { | |
27 | |
28 // Provides an implementation of an NTLMv1 Client. | |
29 // | |
30 // The implementation supports NTLMv1 with extended session security (NTLM2). | |
31 class NET_EXPORT_PRIVATE NtlmClient { | |
32 public: | |
33 NtlmClient(); | |
34 ~NtlmClient(); | |
35 | |
36 // Returns a new buffer containing the Negotiate message that the caller | |
37 // 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.
| |
38 void GetNegotiateMessage(uint8_t** negotiate_message, | |
39 size_t* negotiate_message_len) const; | |
40 | |
41 // Returns a new buffer containing the Authenticate message that the caller | |
42 // is responsible for cleaning up. | |
43 bool GenerateAuthenticateMessage(const base::string16& domain, | |
44 const base::string16& username, | |
45 const base::string16& password, | |
46 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.
| |
47 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.
| |
48 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.
| |
49 size_t challenge_message_len, | |
50 uint8_t** authenticate_message, | |
51 size_t* authenticate_message_len) const; | |
52 | |
53 private: | |
54 // Calculates the lengths and offset for all the payloads in the message. | |
55 void CalculatePayloadLayout(bool is_unicode, | |
56 const base::string16& domain, | |
57 const base::string16& username, | |
58 const std::string& hostname, | |
59 SecurityBuffer* lm_info, | |
60 SecurityBuffer* ntlm_info, | |
61 SecurityBuffer* domain_info, | |
62 SecurityBuffer* username_info, | |
63 SecurityBuffer* hostname_info, | |
64 size_t* authenticate_message_len) const; | |
65 | |
66 // Returns the length of the header part of the Authenticate message. | |
67 // NOTE: When NTLMv2 support is added this is no longer a fixed value. | |
68 size_t GetAuthenticateHeaderLength() const; | |
69 | |
70 // Returns the length of the NTLM response. | |
71 // NOTE: When NTLMv2 support is added this is no longer a fixed value. | |
72 size_t GetNtlmResponseLength() const; | |
73 | |
74 // Generates the negotiate message (which is always the same) into | |
75 // |negotiate_message_|. | |
76 void GenerateNegotiateMessage(); | |
77 | |
78 NegotiateFlags negotiate_flags_; | |
79 std::unique_ptr<uint8_t[]> negotiate_message_; | |
80 | |
81 DISALLOW_COPY_AND_ASSIGN(NtlmClient); | |
82 }; | |
83 | |
84 } // namespace ntlm | |
85 } // namespace net | |
86 | |
87 #endif // NET_BASE_NTLM_CLIENT_H_ | |
OLD | NEW |