// Copyright 2017 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_NTLM_NTLM_CONSTANTS_H_ #define NET_NTLM_NTLM_CONSTANTS_H_ #include <stddef.h> #include <stdint.h> #include <type_traits> #include <vector> #include "net/base/net_export.h" namespace net::ntlm { // A security buffer is a structure within an NTLM message that indicates // the offset from the beginning of the message and the length of a payload // that occurs later in the message. Within the raw message there is also // an additional field, however the field is always written with the same // value as length, and readers must always ignore it. struct SecurityBuffer { … }; struct NtlmFeatures { … }; // There are 3 types of messages in NTLM. The message type is a field in // every NTLM message header. See [MS-NLMP] Section 2.2. enum class MessageType : uint32_t { … }; // Defined in [MS-NLMP] Section 2.2.2.5 // Only the used subset is defined. enum class NegotiateFlags : uint32_t { … }; constexpr NegotiateFlags operator|(NegotiateFlags lhs, NegotiateFlags rhs) { … } constexpr NegotiateFlags operator&(NegotiateFlags lhs, NegotiateFlags rhs) { … } // Identifies the payload type in an AV Pair. See [MS-NLMP] 2.2.2.1 enum class TargetInfoAvId : uint16_t { … }; // Flags used in an TargetInfoAvId::kFlags AV Pair. See [MS-NLMP] 2.2.2.1 enum class TargetInfoAvFlags : uint32_t { … }; TAvFlagsInt; constexpr TargetInfoAvFlags operator|(TargetInfoAvFlags lhs, TargetInfoAvFlags rhs) { … } constexpr TargetInfoAvFlags operator&(TargetInfoAvFlags lhs, TargetInfoAvFlags rhs) { … } // An AV Pair is a structure that appears inside the target info field. It // consists of an |avid| to identify the data type and an |avlen| specifying // the size of the payload. Following that is |avlen| bytes of inline payload. // AV Pairs are concatenated together and a special terminator with |avid| // equal to |kEol| and |avlen| equal to zero signals that no further pairs // follow. See [MS-NLMP] 2.2.2.1 // // AV Pairs from the Challenge message are read from the challenge message // and a potentially modified version is written into the authenticate // message. In some cases the existing AV Pair is modified, eg. flags. In // some cases new AV Pairs are add, eg. channel bindings and spn. // // For simplicity of processing two special fields |flags|, and |timestamp| // are populated during the initial parsing phase for AVIDs |kFlags| and // |kTimestamp| respectively. This avoids subsequent code having to // manipulate the payload value through the buffer directly. For all // other AvPairs the value of these 2 fields is undefined and the payload // is in the |buffer| field. For these fields the payload is copied verbatim // and it's content is not read or validated in any way. struct NET_EXPORT_PRIVATE AvPair { … }; static constexpr uint8_t kSignature[] = …; static constexpr size_t kSignatureLen = …; static constexpr uint16_t kProofInputVersionV2 = …; static constexpr size_t kSecurityBufferLen = …; static constexpr size_t kNegotiateMessageLen = …; static constexpr size_t kMinChallengeHeaderLen = …; static constexpr size_t kChallengeHeaderLen = …; static constexpr size_t kResponseLenV1 = …; static constexpr size_t kChallengeLen = …; static constexpr size_t kVersionFieldLen = …; static constexpr size_t kNtlmHashLen = …; static constexpr size_t kNtlmProofLenV2 = …; static constexpr size_t kSessionKeyLenV2 = …; static constexpr size_t kMicLenV2 = …; static constexpr size_t kChannelBindingsHashLen = …; static constexpr size_t kEpaUnhashedStructHeaderLen = …; static constexpr size_t kProofInputLenV2 = …; static constexpr size_t kAvPairHeaderLen = …; static constexpr size_t kNtlmResponseHeaderLenV2 = …; static constexpr size_t kAuthenticateHeaderLenV1 = …; static constexpr size_t kMicOffsetV2 = …; static constexpr size_t kAuthenticateHeaderLenV2 = …; static constexpr size_t kMaxFqdnLen = …; static constexpr size_t kMaxUsernameLen = …; static constexpr size_t kMaxPasswordLen = …; static constexpr NegotiateFlags kNegotiateMessageFlags = …; } // namespace net::ntlm #endif // NET_NTLM_NTLM_CONSTANTS_H_