diff --git a/api/transport/stun.cc b/api/transport/stun.cc index 53515b17aa..0bd2d24fa5 100644 --- a/api/transport/stun.cc +++ b/api/transport/stun.cc @@ -327,6 +327,25 @@ StunMessage::IntegrityStatus StunMessage::ValidateMessageIntegrity( return integrity_; } +bool StunMessage::ValidateMessageIntegrityForTesting( + const char* data, + size_t size, + const std::string& password) { + return ValidateMessageIntegrityOfType(STUN_ATTR_MESSAGE_INTEGRITY, + kStunMessageIntegritySize, data, size, + password); +} + +bool StunMessage::ValidateMessageIntegrity32ForTesting( + const char* data, + size_t size, + const std::string& password) { + return ValidateMessageIntegrityOfType(STUN_ATTR_GOOG_MESSAGE_INTEGRITY_32, + kStunMessageIntegrity32Size, data, size, + password); +} + +// Deprecated bool StunMessage::ValidateMessageIntegrity(const char* data, size_t size, const std::string& password) { @@ -335,6 +354,7 @@ bool StunMessage::ValidateMessageIntegrity(const char* data, password); } +// Deprecated bool StunMessage::ValidateMessageIntegrity32(const char* data, size_t size, const std::string& password) { diff --git a/api/transport/stun.h b/api/transport/stun.h index 2098330f5a..72a77990b4 100644 --- a/api/transport/stun.h +++ b/api/transport/stun.h @@ -283,29 +283,27 @@ class StunMessage { bool EqualAttributes(const StunMessage* other, std::function attribute_type_mask) const; - // Expose raw-buffer ValidateMessageIntegrity function for testing. - static bool ValidateMessageIntegrityForTesting(const char* data, - size_t size, - const std::string& password) { - return ValidateMessageIntegrity(data, size, password); - } - // Expose raw-buffer ValidateMessageIntegrity function for testing. - static bool ValidateMessageIntegrity32ForTesting( - const char* data, - size_t size, - const std::string& password) { - return ValidateMessageIntegrity32(data, size, password); - } // Validates that a STUN message in byte buffer form // has a correct MESSAGE-INTEGRITY value. // These functions are not recommended and will be deprecated; use // ValidateMessageIntegrity(password) on the parsed form instead. - static bool ValidateMessageIntegrity(const char* data, - size_t size, - const std::string& password); - static bool ValidateMessageIntegrity32(const char* data, - size_t size, - const std::string& password); + [[deprecated("Use member function")]] static bool ValidateMessageIntegrity( + const char* data, + size_t size, + const std::string& password); + [[deprecated("Use member function")]] static bool ValidateMessageIntegrity32( + const char* data, + size_t size, + const std::string& password); + + // Expose raw-buffer ValidateMessageIntegrity function for testing. + static bool ValidateMessageIntegrityForTesting(const char* data, + size_t size, + const std::string& password); + // Expose raw-buffer ValidateMessageIntegrity function for testing. + static bool ValidateMessageIntegrity32ForTesting(const char* data, + size_t size, + const std::string& password); protected: // Verifies that the given attribute is allowed for this message.