From 202c2b5b922eb0123d9c6ea551cb8b2d7e6cff75 Mon Sep 17 00:00:00 2001 From: Craig Edwards Date: Sat, 5 Oct 2024 14:06:32 +0000 Subject: [PATCH] Session -> session --- include/dpp/discordvoiceclient.h | 2 +- src/dpp/dave/session.cpp | 64 +++++++++++++------------- src/dpp/dave/session.h | 30 ++++++------ src/dpp/voice/enabled/enabled.h | 2 +- src/dpp/voice/enabled/handle_frame.cpp | 2 +- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/dpp/discordvoiceclient.h b/include/dpp/discordvoiceclient.h index 393cd30550..7777750e0b 100644 --- a/include/dpp/discordvoiceclient.h +++ b/include/dpp/discordvoiceclient.h @@ -75,7 +75,7 @@ namespace dpp { class audio_mixer; namespace dave::mls { - class Session; + class session; } // !TODO: change these to constexpr and rename every occurrence across the codebase diff --git a/src/dpp/dave/session.cpp b/src/dpp/dave/session.cpp index e58b9625aa..4da06f3bb9 100755 --- a/src/dpp/dave/session.cpp +++ b/src/dpp/dave/session.cpp @@ -56,9 +56,9 @@ struct QueuedProposal { ::mlspp::bytes_ns::bytes ref; }; -Session::Session(key_pair_context_type context, +session::session(key_pair_context_type context, const std::string& authSessionId, - MLSFailureCallback callback) noexcept + mls_failure_callback callback) noexcept : signingKeyId_(authSessionId) , keyPairContext_(context) , onMLSFailureCallback_(std::move(callback)) @@ -66,9 +66,9 @@ Session::Session(key_pair_context_type context, DISCORD_LOG(LS_INFO) << "Creating a new MLS session"; } -Session::~Session() noexcept = default; +session::~session() noexcept = default; -void Session::Init(protocol_version protocolVersion, +void session::Init(protocol_version protocolVersion, uint64_t groupId, std::string const& selfUserId, std::shared_ptr<::mlspp::SignaturePrivateKey>& transientKey) noexcept @@ -87,7 +87,7 @@ void Session::Init(protocol_version protocolVersion, CreatePendingGroup(); } -void Session::Reset() noexcept +void session::Reset() noexcept { DISCORD_LOG(LS_INFO) << "Resetting MLS session"; @@ -100,7 +100,7 @@ void Session::Reset() noexcept groupId_.clear(); } -void Session::SetProtocolVersion(protocol_version version) noexcept +void session::SetProtocolVersion(protocol_version version) noexcept { if (version != protocolVersion_) { // when we need to retain backwards compatibility @@ -110,7 +110,7 @@ void Session::SetProtocolVersion(protocol_version version) noexcept } } -std::vector Session::GetLastEpochAuthenticator() const noexcept +std::vector session::GetLastEpochAuthenticator() const noexcept { if (!currentState_) { DISCORD_LOG(LS_ERROR) << "Cannot get epoch authenticator without an established MLS group"; @@ -120,7 +120,7 @@ std::vector Session::GetLastEpochAuthenticator() const noexcept return std::move(currentState_->epoch_authenticator().as_vec()); } -void Session::SetExternalSender(const std::vector& marshalledExternalSender) noexcept +void session::SetExternalSender(const std::vector& marshalledExternalSender) noexcept try { if (currentState_) { DISCORD_LOG(LS_ERROR) << "Cannot set external sender after joining/creating an MLS group"; @@ -144,7 +144,7 @@ catch (const std::exception& e) { return; } -std::optional> Session::ProcessProposals( +std::optional> session::ProcessProposals( std::vector proposals, std::set const& recognizedUserIDs) noexcept try { @@ -267,8 +267,8 @@ catch (const std::exception& e) { return std::nullopt; } -bool Session::IsRecognizedUserID(const ::mlspp::Credential& cred, - std::set const& recognizedUserIDs) const +bool session::IsRecognizedUserID(const ::mlspp::Credential& cred, + std::set const& recognizedUserIDs) const { std::string uid = UserCredentialToString(cred, protocolVersion_); if (uid.empty()) { @@ -284,9 +284,9 @@ bool Session::IsRecognizedUserID(const ::mlspp::Credential& cred, return true; } -bool Session::ValidateProposalMessage(::mlspp::AuthenticatedContent const& message, - ::mlspp::State const& targetState, - std::set const& recognizedUserIDs) const +bool session::ValidateProposalMessage(::mlspp::AuthenticatedContent const& message, + ::mlspp::State const& targetState, + std::set const& recognizedUserIDs) const { if (message.wire_format != ::mlspp::WireFormat::mls_public_message) { DISCORD_LOG(LS_ERROR) << "MLS proposal message must be PublicMessage"; @@ -337,7 +337,7 @@ bool Session::ValidateProposalMessage(::mlspp::AuthenticatedContent const& messa return true; } -bool Session::CanProcessCommit(const ::mlspp::MLSMessage& commit) noexcept +bool session::CanProcessCommit(const ::mlspp::MLSMessage& commit) noexcept { if (!stateWithProposals_) { return false; @@ -351,7 +351,7 @@ bool Session::CanProcessCommit(const ::mlspp::MLSMessage& commit) noexcept return true; } -roster_variant Session::ProcessCommit(std::vector commit) noexcept +roster_variant session::ProcessCommit(std::vector commit) noexcept try { DISCORD_LOG(LS_INFO) << "Processing commit"; DISCORD_LOG(LS_INFO) << "Commit: " << ::mlspp::bytes_ns::bytes(commit); @@ -395,7 +395,7 @@ catch (const std::exception& e) { return failed_t{}; } -std::optional Session::ProcessWelcome( +std::optional session::ProcessWelcome( std::vector welcome, std::set const& recognizedUserIDs) noexcept try { @@ -453,7 +453,7 @@ catch (const std::exception& e) { return std::nullopt; } -roster_map Session::ReplaceState(std::unique_ptr<::mlspp::State>&& state) +roster_map session::ReplaceState(std::unique_ptr<::mlspp::State>&& state) { roster_map newRoster; for (const ::mlspp::LeafNode& node : state->roster()) { @@ -505,13 +505,13 @@ roster_map Session::ReplaceState(std::unique_ptr<::mlspp::State>&& state) return changeMap; } -bool Session::HasCryptographicStateForWelcome() const noexcept +bool session::HasCryptographicStateForWelcome() const noexcept { return joinKeyPackage_ && joinInitPrivateKey_ && selfSigPrivateKey_ && selfHPKEPrivateKey_; } -bool Session::VerifyWelcomeState(::mlspp::State const& state, - std::set const& recognizedUserIDs) const +bool session::VerifyWelcomeState(::mlspp::State const& state, + std::set const& recognizedUserIDs) const { if (!externalSender_) { DISCORD_LOG(LS_ERROR) << "Cannot verify MLS welcome without an external sender"; @@ -555,8 +555,8 @@ bool Session::VerifyWelcomeState(::mlspp::State const& state, return true; } -void Session::InitLeafNode(std::string const& selfUserId, - std::shared_ptr<::mlspp::SignaturePrivateKey>& transientKey) noexcept +void session::InitLeafNode(std::string const& selfUserId, + std::shared_ptr<::mlspp::SignaturePrivateKey>& transientKey) noexcept try { auto ciphersuite = ciphersuite_for_protocol_version(protocolVersion_); @@ -599,7 +599,7 @@ catch (const std::exception& e) { TRACK_MLS_ERROR(e.what()); } -void Session::ResetJoinKeyPackage() noexcept +void session::ResetJoinKeyPackage() noexcept try { if (!selfLeafNode_) { DISCORD_LOG(LS_ERROR) << "Cannot initialize join key package without a leaf node"; @@ -626,7 +626,7 @@ catch (const std::exception& e) { TRACK_MLS_ERROR(e.what()); } -void Session::CreatePendingGroup() noexcept +void session::CreatePendingGroup() noexcept try { if (groupId_.empty()) { DISCORD_LOG(LS_ERROR) << "Cannot create MLS group without a group ID"; @@ -663,7 +663,7 @@ catch (const std::exception& e) { return; } -std::vector Session::GetMarshalledKeyPackage() noexcept +std::vector session::GetMarshalledKeyPackage() noexcept try { // key packages are not meant to be re-used // so every time the client asks for a key package we create a new one @@ -682,7 +682,7 @@ catch (const std::exception& e) { return {}; } -std::unique_ptr Session::GetKeyRatchet(std::string const& userId) const noexcept +std::unique_ptr session::GetKeyRatchet(std::string const& userId) const noexcept { if (!currentState_) { DISCORD_LOG(LS_ERROR) << "Cannot get key ratchet without an established MLS group"; @@ -696,16 +696,16 @@ std::unique_ptr Session::GetKeyRatchet(std::string const& // generate the base secret for the hash ratchet auto baseSecret = - currentState_->do_export(Session::USER_MEDIA_KEY_BASE_LABEL, userIdBytes, AES_GCM_128_KEY_BYTES); + currentState_->do_export(session::USER_MEDIA_KEY_BASE_LABEL, userIdBytes, AES_GCM_128_KEY_BYTES); // this assumes the MLS ciphersuite produces a kAesGcm128KeyBytes sized key // would need to be updated to a different ciphersuite if there's a future mismatch return std::make_unique(currentState_->cipher_suite(), std::move(baseSecret)); } -void Session::GetPairwiseFingerprint(uint16_t version, - std::string const& userId, - PairwiseFingerprintCallback callback) const noexcept +void session::GetPairwiseFingerprint(uint16_t version, + std::string const& userId, + PairwiseFingerprintCallback callback) const noexcept try { if (!currentState_ || !selfSigPrivateKey_) { throw std::invalid_argument("No established MLS group"); @@ -787,7 +787,7 @@ catch (const std::exception& e) { callback({}); } -void Session::ClearPendingState() +void session::ClearPendingState() { pendingGroupState_.reset(); pendingGroupCommit_.reset(); diff --git a/src/dpp/dave/session.h b/src/dpp/dave/session.h index 74c8e266d6..90c7eb2199 100755 --- a/src/dpp/dave/session.h +++ b/src/dpp/dave/session.h @@ -38,30 +38,30 @@ #include "version.h" namespace mlspp { -struct AuthenticatedContent; -struct Credential; -struct ExternalSender; -struct HPKEPrivateKey; -struct KeyPackage; -struct LeafNode; -struct MLSMessage; -struct SignaturePrivateKey; -class State; + struct AuthenticatedContent; + struct Credential; + struct ExternalSender; + struct HPKEPrivateKey; + struct KeyPackage; + struct LeafNode; + struct MLSMessage; + struct SignaturePrivateKey; + class State; } // namespace mlspp namespace dpp::dave::mls { struct QueuedProposal; -class Session { +class session { public: - using MLSFailureCallback = std::function; + using mls_failure_callback = std::function; - Session(key_pair_context_type context, + session(key_pair_context_type context, const std::string& authSessionId, - MLSFailureCallback callback) noexcept; + mls_failure_callback callback) noexcept; - ~Session() noexcept; + ~session() noexcept; void Init(protocol_version version, uint64_t groupId, @@ -147,7 +147,7 @@ class Session { std::unique_ptr<::mlspp::State> stateWithProposals_; std::list proposalQueue_; - MLSFailureCallback onMLSFailureCallback_{}; + mls_failure_callback onMLSFailureCallback_{}; }; } // namespace dpp::dave::mls diff --git a/src/dpp/voice/enabled/enabled.h b/src/dpp/voice/enabled/enabled.h index 30a693611c..9daf86dc55 100644 --- a/src/dpp/voice/enabled/enabled.h +++ b/src/dpp/voice/enabled/enabled.h @@ -71,7 +71,7 @@ namespace dpp { struct dave_state { - std::unique_ptr dave_session{}; + std::unique_ptr dave_session{}; std::shared_ptr<::mlspp::SignaturePrivateKey> mls_key; std::vector cached_commit; uint64_t transition_id{0}; diff --git a/src/dpp/voice/enabled/handle_frame.cpp b/src/dpp/voice/enabled/handle_frame.cpp index 9b468671f7..2237088df1 100644 --- a/src/dpp/voice/enabled/handle_frame.cpp +++ b/src/dpp/voice/enabled/handle_frame.cpp @@ -317,7 +317,7 @@ bool discord_voice_client::handle_frame(const std::string &data, ws_opcode opcod } mls_state = std::make_unique(); - mls_state->dave_session = std::make_unique( + mls_state->dave_session = std::make_unique( nullptr, "" /* sessionid */, [this](std::string const& s1, std::string const& s2) { log(ll_debug, "Dave session constructor callback: " + s1 + ", " + s2); });