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

Side by Side Diff: net/ntlm/ntlm_constants.h

Issue 2879353002: Add a buffer reader/writer for NTLM. (Closed)
Patch Set: Remove ReleaseBufferPtr 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
« no previous file with comments | « net/ntlm/ntlm_buffer_writer_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_CONSTANTS_H_
6 #define NET_BASE_NTLM_CONSTANTS_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10 #include <type_traits>
11
12 #include "base/macros.h"
13 #include "net/base/net_export.h"
14
15 namespace net {
16 namespace ntlm {
17
18 // A security buffer is a structure within an NTLM message that indicates
19 // the offset from the beginning of the message and the length of a payload
20 // that occurs later in the message. Within the raw message there is also
21 // an additional field, however the field is always written with the same
22 // value as length, and readers must always ignore it.
23 struct SecurityBuffer {
24 SecurityBuffer(uint32_t offset, uint16_t length)
25 : offset(offset), length(length) {}
26 SecurityBuffer() : SecurityBuffer(0, 0) {}
27
28 uint32_t offset;
29 uint16_t length;
30 };
31
32 enum class NtlmVersion {
33 kNtlmV1 = 0x01,
34 kNtlmV2 = 0x02,
35 };
36
37 // There are 3 types of messages in NTLM. The message type is a field in
38 // every NTLM message header.
39 enum class MessageType : uint32_t {
40 kNegotiate = 0x01,
41 kChallenge = 0x02,
42 kAuthenticate = 0x03,
43 };
44
45 // Defined in [MS-NLMP] Section 2.2.2.5
46 // Only the used subset is defined.
47 enum class NegotiateFlags : uint32_t {
48 kNone = 0,
49 kUnicode = 0x01,
50 kOem = 0x02,
51 kRequestTarget = 0x04,
52 kNtlm = 0x200,
53 kAlwaysSign = 0x8000,
54 kExtendedSessionSecurity = 0x80000,
55 };
56
57 constexpr inline NegotiateFlags operator|(NegotiateFlags lhs,
58 NegotiateFlags rhs) {
59 using TFlagsInt = std::underlying_type<NegotiateFlags>::type;
60
61 return static_cast<NegotiateFlags>(static_cast<TFlagsInt>(lhs) |
62 static_cast<TFlagsInt>(rhs));
63 }
64
65 constexpr inline NegotiateFlags operator&(NegotiateFlags lhs,
66 NegotiateFlags rhs) {
67 using TFlagsInt = std::underlying_type<NegotiateFlags>::type;
68
69 return static_cast<NegotiateFlags>(static_cast<TFlagsInt>(lhs) &
70 static_cast<TFlagsInt>(rhs));
71 }
72
73 static constexpr uint8_t kSignature[] = "NTLMSSP";
74 static constexpr size_t kSignatureLen = arraysize(kSignature);
75 static constexpr size_t kSecurityBufferLen =
76 (2 * sizeof(uint16_t)) + sizeof(uint32_t);
77 static constexpr size_t kNegotiateMessageLen = 32;
78 static constexpr size_t kResponseLenV1 = 24;
79 static constexpr size_t kChallengeLen = 8;
80 static constexpr size_t kNtlmHashLen = 16;
81
82 static constexpr NegotiateFlags kNegotiateMessageFlags =
83 NegotiateFlags::kUnicode | NegotiateFlags::kOem |
84 NegotiateFlags::kRequestTarget | NegotiateFlags::kNtlm |
85 NegotiateFlags::kAlwaysSign | NegotiateFlags::kExtendedSessionSecurity;
86
87 } // namespace ntlm
88 } // namespace net
89
90 #endif // NET_BASE_NTLM_CONSTANTS_H_
OLDNEW
« no previous file with comments | « net/ntlm/ntlm_buffer_writer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698