#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/ntlm/ntlm.h"
#include <string.h>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/net_string_util.h"
#include "net/ntlm/ntlm_buffer_writer.h"
#include "net/ntlm/ntlm_constants.h"
#include "third_party/boringssl/src/include/openssl/des.h"
#include "third_party/boringssl/src/include/openssl/hmac.h"
#include "third_party/boringssl/src/include/openssl/md4.h"
#include "third_party/boringssl/src/include/openssl/md5.h"
namespace net::ntlm {
namespace {
void UpdateTargetInfoAvPairs(bool is_mic_enabled,
bool is_epa_enabled,
const std::string& channel_bindings,
const std::string& spn,
std::vector<AvPair>* av_pairs,
uint64_t* server_timestamp,
size_t* target_info_len) { … }
std::vector<uint8_t> WriteUpdatedTargetInfo(const std::vector<AvPair>& av_pairs,
size_t updated_target_info_len) { … }
void Splay56To64(base::span<const uint8_t, 7> key_56,
base::span<uint8_t, 8> key_64) { … }
}
void Create3DesKeysFromNtlmHash(
base::span<const uint8_t, kNtlmHashLen> ntlm_hash,
base::span<uint8_t, 24> keys) { … }
void GenerateNtlmHashV1(const std::u16string& password,
base::span<uint8_t, kNtlmHashLen> hash) { … }
void GenerateResponseDesl(base::span<const uint8_t, kNtlmHashLen> hash,
base::span<const uint8_t, kChallengeLen> challenge,
base::span<uint8_t, kResponseLenV1> response) { … }
void GenerateNtlmResponseV1(
const std::u16string& password,
base::span<const uint8_t, kChallengeLen> server_challenge,
base::span<uint8_t, kResponseLenV1> ntlm_response) { … }
void GenerateResponsesV1(
const std::u16string& password,
base::span<const uint8_t, kChallengeLen> server_challenge,
base::span<uint8_t, kResponseLenV1> lm_response,
base::span<uint8_t, kResponseLenV1> ntlm_response) { … }
void GenerateLMResponseV1WithSessionSecurity(
base::span<const uint8_t, kChallengeLen> client_challenge,
base::span<uint8_t, kResponseLenV1> lm_response) { … }
void GenerateSessionHashV1WithSessionSecurity(
base::span<const uint8_t, kChallengeLen> server_challenge,
base::span<const uint8_t, kChallengeLen> client_challenge,
base::span<uint8_t, kNtlmHashLen> session_hash) { … }
void GenerateNtlmResponseV1WithSessionSecurity(
const std::u16string& password,
base::span<const uint8_t, kChallengeLen> server_challenge,
base::span<const uint8_t, kChallengeLen> client_challenge,
base::span<uint8_t, kResponseLenV1> ntlm_response) { … }
void GenerateResponsesV1WithSessionSecurity(
const std::u16string& password,
base::span<const uint8_t, kChallengeLen> server_challenge,
base::span<const uint8_t, kChallengeLen> client_challenge,
base::span<uint8_t, kResponseLenV1> lm_response,
base::span<uint8_t, kResponseLenV1> ntlm_response) { … }
void GenerateNtlmHashV2(const std::u16string& domain,
const std::u16string& username,
const std::u16string& password,
base::span<uint8_t, kNtlmHashLen> v2_hash) { … }
std::vector<uint8_t> GenerateProofInputV2(
uint64_t timestamp,
base::span<const uint8_t, kChallengeLen> client_challenge) { … }
void GenerateNtlmProofV2(
base::span<const uint8_t, kNtlmHashLen> v2_hash,
base::span<const uint8_t, kChallengeLen> server_challenge,
base::span<const uint8_t, kProofInputLenV2> v2_input,
base::span<const uint8_t> target_info,
base::span<uint8_t, kNtlmProofLenV2> v2_proof) { … }
void GenerateSessionBaseKeyV2(
base::span<const uint8_t, kNtlmHashLen> v2_hash,
base::span<const uint8_t, kNtlmProofLenV2> v2_proof,
base::span<uint8_t, kSessionKeyLenV2> session_key) { … }
void GenerateChannelBindingHashV2(
const std::string& channel_bindings,
base::span<uint8_t, kNtlmHashLen> channel_bindings_hash) { … }
void GenerateMicV2(base::span<const uint8_t, kSessionKeyLenV2> session_key,
base::span<const uint8_t> negotiate_msg,
base::span<const uint8_t> challenge_msg,
base::span<const uint8_t> authenticate_msg,
base::span<uint8_t, kMicLenV2> mic) { … }
NET_EXPORT_PRIVATE std::vector<uint8_t> GenerateUpdatedTargetInfo(
bool is_mic_enabled,
bool is_epa_enabled,
const std::string& channel_bindings,
const std::string& spn,
const std::vector<AvPair>& av_pairs,
uint64_t* server_timestamp) { … }
}