Deprecate non-message STUN integrity check functions

The one to use is StunMessage::ValidateMessageIntegrity(password).

Bug: chromium:1177125
Change-Id: I345f4d6b60090651bc23c3aa6358d4fb24723f9f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278601
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Johannes Kron <kron@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38338}
This commit is contained in:
Harald Alvestrand
2022-10-10 10:22:39 +00:00
committed by WebRTC LUCI CQ
parent b984c07dab
commit 4b255b1756
2 changed files with 37 additions and 19 deletions

View File

@ -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) {

View File

@ -283,29 +283,27 @@ class StunMessage {
bool EqualAttributes(const StunMessage* other,
std::function<bool(int type)> 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.