| Index: net/ntlm/ntlm.h
|
| diff --git a/net/ntlm/ntlm.h b/net/ntlm/ntlm.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..153ef721d1765c34aa2aa7947222424c36fe1bb5
|
| --- /dev/null
|
| +++ b/net/ntlm/ntlm.h
|
| @@ -0,0 +1,90 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_BASE_NTLM_H_
|
| +#define NET_BASE_NTLM_H_
|
| +
|
| +#include <stddef.h>
|
| +#include <stdint.h>
|
| +#include <type_traits>
|
| +
|
| +#include "base/macros.h"
|
| +#include "net/base/net_export.h"
|
| +
|
| +namespace net {
|
| +namespace 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 {
|
| + SecurityBuffer(uint32_t offset, uint16_t length)
|
| + : offset(offset), length(length) {}
|
| +
|
| + SecurityBuffer() : SecurityBuffer(0, 0) {}
|
| + uint32_t offset;
|
| + uint16_t length;
|
| +};
|
| +
|
| +enum class NtlmVersion {
|
| + NTLM_V1 = 0x01,
|
| + NTLM_V2 = 0x02,
|
| +};
|
| +
|
| +// There are 3 types of messages in NTLM. The message type is a field in
|
| +// every NTLM message header.
|
| +enum class MessageType : uint32_t {
|
| + NEGOTIATE = 0x01,
|
| + CHALLENGE = 0x02,
|
| + AUTHENTICATE = 0x03,
|
| +};
|
| +
|
| +// Defined in [MS-NLMP] Section 2.2.2.5
|
| +// Only the used subset is defined.
|
| +enum class NegotiateFlags : uint32_t {
|
| + NONE = 0,
|
| + UNICODE = 0x01,
|
| + OEM = 0x02,
|
| + REQUEST_TARGET = 0x04,
|
| + NTLM = 0x200,
|
| + ALWAYS_SIGN = 0x8000,
|
| + EXTENDED_SESSIONSECURITY = 0x80000,
|
| +};
|
| +
|
| +constexpr inline NegotiateFlags operator|(NegotiateFlags lhs,
|
| + NegotiateFlags rhs) {
|
| + using TFlagsInt = std::underlying_type<NegotiateFlags>::type;
|
| +
|
| + return static_cast<NegotiateFlags>(static_cast<TFlagsInt>(lhs) |
|
| + static_cast<TFlagsInt>(rhs));
|
| +}
|
| +
|
| +constexpr inline NegotiateFlags operator&(NegotiateFlags lhs,
|
| + NegotiateFlags rhs) {
|
| + using TFlagsInt = std::underlying_type<NegotiateFlags>::type;
|
| +
|
| + return static_cast<NegotiateFlags>(static_cast<TFlagsInt>(lhs) &
|
| + static_cast<TFlagsInt>(rhs));
|
| +}
|
| +
|
| +static constexpr uint8_t SIGNATURE[] = "NTLMSSP";
|
| +static constexpr size_t SIGNATURE_LEN = arraysize(SIGNATURE);
|
| +static constexpr size_t SECURITY_BUFFER_LEN =
|
| + (2 * sizeof(uint16_t)) + sizeof(uint32_t);
|
| +static constexpr size_t NEGOTIATE_MESSAGE_LEN = 32;
|
| +static constexpr size_t RESPONSE_V1_LEN = 24;
|
| +static constexpr size_t CHALLENGE_LEN = 8;
|
| +static constexpr size_t NTLM_HASH_LEN = 16;
|
| +
|
| +static constexpr NegotiateFlags NEGOTIATE_MESSAGE_FLAGS =
|
| + NegotiateFlags::UNICODE | NegotiateFlags::OEM |
|
| + NegotiateFlags::REQUEST_TARGET | NegotiateFlags::NTLM |
|
| + NegotiateFlags::ALWAYS_SIGN | NegotiateFlags::EXTENDED_SESSIONSECURITY;
|
| +
|
| +} // namespce ntlm
|
| +} // namespace net
|
| +
|
| +#endif // NET_BASE_NTLM_H_
|
|
|