Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: net/http/http_auth_handler_ntlm.h

Issue 2904633002: Replace NTLMv1 implementation with a functionally equivalent one.
Patch Set: Only return malloc memory from NtlmClient Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_
6 #define NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ 6 #define NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 12
13 // This contains the portable and the SSPI implementations for NTLM. 13 // This contains the portable and the SSPI implementations for NTLM.
14 // We use NTLM_SSPI for Windows, and NTLM_PORTABLE for other platforms. 14 // We use NTLM_SSPI for Windows, and NTLM_PORTABLE for other platforms.
15 #if defined(OS_WIN) 15 #if defined(OS_WIN)
16 #define NTLM_SSPI 16 #define NTLM_SSPI
17 #else 17 #else
18 #define NTLM_PORTABLE 18 #define NTLM_PORTABLE
19 #endif 19 #endif
20 20
21 #if defined(NTLM_SSPI) 21 #if defined(NTLM_SSPI)
22 #define SECURITY_WIN32 1 22 #define SECURITY_WIN32 1
23 #include <windows.h> 23 #include <windows.h>
24 #include <security.h> 24 #include <security.h>
25 #include "net/http/http_auth_sspi_win.h" 25 #include "net/http/http_auth_sspi_win.h"
26 #elif defined(NTLM_PORTABLE)
27 #include "net/ntlm/ntlm_client.h"
26 #endif 28 #endif
27 29
28 #include <string> 30 #include <string>
29 31
30 #include "base/strings/string16.h" 32 #include "base/strings/string16.h"
31 #include "net/base/net_export.h" 33 #include "net/base/net_export.h"
32 #include "net/http/http_auth_handler.h" 34 #include "net/http/http_auth_handler.h"
33 #include "net/http/http_auth_handler_factory.h" 35 #include "net/http/http_auth_handler_factory.h"
34 36
35 namespace net { 37 namespace net {
(...skipping 27 matching lines...) Expand all
63 #endif // defined(NTLM_SSPI) 65 #endif // defined(NTLM_SSPI)
64 private: 66 private:
65 #if defined(NTLM_SSPI) 67 #if defined(NTLM_SSPI)
66 ULONG max_token_length_; 68 ULONG max_token_length_;
67 bool is_unsupported_; 69 bool is_unsupported_;
68 std::unique_ptr<SSPILibrary> sspi_library_; 70 std::unique_ptr<SSPILibrary> sspi_library_;
69 #endif // defined(NTLM_SSPI) 71 #endif // defined(NTLM_SSPI)
70 }; 72 };
71 73
72 #if defined(NTLM_PORTABLE) 74 #if defined(NTLM_PORTABLE)
75 static void GenerateRandom(uint8_t* output, size_t n);
asanka 2017/07/14 16:52:38 This doesn't need to be a part of HttpAuthHandlerN
zentaro 2017/07/19 15:20:12 Done.
76
73 // A function that generates n random bytes in the output buffer. 77 // A function that generates n random bytes in the output buffer.
74 typedef void (*GenerateRandomProc)(uint8_t* output, size_t n); 78 typedef void (*GenerateRandomProc)(uint8_t* output, size_t n);
75 79
76 // A function that returns the local host name. Returns an empty string if 80 // A function that returns the local host name. Returns an empty string if
77 // the local host name is not available. 81 // the local host name is not available.
78 typedef std::string (*HostNameProc)(); 82 typedef std::string (*HostNameProc)();
79 83
80 // For unit tests to override and restore the GenerateRandom and 84 // For unit tests to override and restore the GenerateRandom and
81 // GetHostName functions. 85 // GetHostName functions.
82 class ScopedProcSetter { 86 class ScopedProcSetter {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 int GetNextToken(const void* in_token, 149 int GetNextToken(const void* in_token,
146 uint32_t in_token_len, 150 uint32_t in_token_len,
147 void** out_token, 151 void** out_token,
148 uint32_t* out_token_len); 152 uint32_t* out_token_len);
149 153
150 // Create an NTLM SPN to identify the |origin| server. 154 // Create an NTLM SPN to identify the |origin| server.
151 static std::string CreateSPN(const GURL& origin); 155 static std::string CreateSPN(const GURL& origin);
152 156
153 #if defined(NTLM_SSPI) 157 #if defined(NTLM_SSPI)
154 HttpAuthSSPI auth_sspi_; 158 HttpAuthSSPI auth_sspi_;
159 #elif defined(NTLM_PORTABLE)
160 ntlm::NtlmClient ntlm_client_;
155 #endif 161 #endif
156 162
157 #if defined(NTLM_PORTABLE) 163 #if defined(NTLM_PORTABLE)
158 static GenerateRandomProc generate_random_proc_; 164 static GenerateRandomProc generate_random_proc_;
159 static HostNameProc get_host_name_proc_; 165 static HostNameProc get_host_name_proc_;
160 #endif 166 #endif
161 167
162 base::string16 domain_; 168 base::string16 domain_;
163 AuthCredentials credentials_; 169 AuthCredentials credentials_;
164 std::string channel_bindings_; 170 std::string channel_bindings_;
165 171
166 // The base64-encoded string following "NTLM" in the "WWW-Authenticate" or 172 // The base64-encoded string following "NTLM" in the "WWW-Authenticate" or
167 // "Proxy-Authenticate" response header. 173 // "Proxy-Authenticate" response header.
168 std::string auth_data_; 174 std::string auth_data_;
169 175
170 #if defined(NTLM_SSPI) 176 #if defined(NTLM_SSPI)
171 const HttpAuthPreferences* http_auth_preferences_; 177 const HttpAuthPreferences* http_auth_preferences_;
172 #endif 178 #endif
173 }; 179 };
174 180
175 } // namespace net 181 } // namespace net
176 182
177 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_ 183 #endif // NET_HTTP_HTTP_AUTH_HANDLER_NTLM_H_
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/http/http_auth_handler_ntlm_portable.cc » ('j') | net/ntlm/ntlm.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698