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 #ifndef NET_BASE_NTLM_H_ | |
6 #define NET_BASE_NTLM_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <stdint.h> | |
10 | |
asanka
2017/06/23 17:59:14
#include <type_traits>
zentaro
2017/06/26 14:34:26
Done.
| |
11 #include "base/macros.h" | |
12 #include "net/base/net_export.h" | |
13 | |
14 namespace net { | |
15 namespace ntlm { | |
16 | |
17 // A security buffer is a structure within an NTLM message that indicates | |
18 // the offset from the beginning of the message and the length of a payload | |
19 // that occurs later in the message. Within the raw message there is also | |
20 // an additional field, however the field is always written with the same | |
21 // value as length, and readers must always ignore it. | |
22 struct SecurityBuffer { | |
23 SecurityBuffer(uint32_t offset, uint16_t length) | |
24 : offset(offset), length(length) {} | |
25 | |
26 SecurityBuffer() : SecurityBuffer(0, 0) {} | |
27 uint32_t offset; | |
28 uint16_t length; | |
29 }; | |
30 | |
31 enum class NtlmVersion { | |
32 NTLM_V1 = 0x01, | |
33 NTLM_V2 = 0x02, | |
34 }; | |
35 | |
36 // There are 3 types of messages in NTLM. The message type is a field in | |
37 // every NTLM message header. | |
38 enum class MessageType : uint32_t { | |
39 NEGOTIATE = 0x01, | |
40 CHALLENGE = 0x02, | |
41 AUTHENTICATE = 0x03, | |
42 }; | |
43 | |
44 // Defined in [MS-NLMP] Section 2.2.2.5 | |
45 // Only the used subset is defined. | |
46 enum class NegotiateFlags : uint32_t { | |
47 NONE = 0, | |
48 UNICODE = 0x01, | |
49 OEM = 0x02, | |
50 REQUEST_TARGET = 0x04, | |
51 NTLM = 0x200, | |
52 ALWAYS_SIGN = 0x8000, | |
53 EXTENDED_SESSIONSECURITY = 0x80000, | |
54 }; | |
55 | |
56 using TFlagsInt = std::underlying_type<NegotiateFlags>::type; | |
asanka
2017/06/23 17:59:14
Nit: this can go inside the functions. There'll be
zentaro
2017/06/26 14:34:26
Done.
| |
57 | |
58 constexpr inline NegotiateFlags operator|(NegotiateFlags lhs, | |
59 NegotiateFlags rhs) { | |
60 return static_cast<NegotiateFlags>(static_cast<TFlagsInt>(lhs) | | |
61 static_cast<TFlagsInt>(rhs)); | |
62 } | |
63 | |
64 constexpr inline NegotiateFlags operator&(NegotiateFlags lhs, | |
65 NegotiateFlags rhs) { | |
66 return static_cast<NegotiateFlags>(static_cast<TFlagsInt>(lhs) & | |
67 static_cast<TFlagsInt>(rhs)); | |
68 } | |
69 | |
70 static constexpr uint8_t SIGNATURE[] = "NTLMSSP"; | |
71 static constexpr size_t SIGNATURE_LEN = arraysize(SIGNATURE); | |
72 static constexpr size_t SECURITY_BUFFER_LEN = | |
73 (2 * sizeof(uint16_t)) + sizeof(uint32_t); | |
74 static constexpr size_t NEGOTIATE_MESSAGE_LEN = 32; | |
75 static constexpr size_t RESPONSE_V1_LEN = 24; | |
76 static constexpr size_t CHALLENGE_LEN = 8; | |
77 static constexpr size_t NTLM_HASH_LEN = 16; | |
78 | |
79 static constexpr NegotiateFlags NEGOTIATE_MESSAGE_FLAGS = | |
80 NegotiateFlags::UNICODE | NegotiateFlags::OEM | | |
81 NegotiateFlags::REQUEST_TARGET | NegotiateFlags::NTLM | | |
82 NegotiateFlags::ALWAYS_SIGN | NegotiateFlags::EXTENDED_SESSIONSECURITY; | |
83 | |
84 } // namespce ntlm | |
85 } // namespace net | |
86 | |
87 #endif // NET_BASE_NTLM_H_ | |
OLD | NEW |