#include <icy/stun/attributes.h>Inherits:
Attribute
Implements the STUN MESSAGE-INTEGRITY attribute (RFC 5389 section 15.4). On write, computes an HMAC-SHA1 over the message bytes preceding this attribute when a key is set. On read, captures the raw HMAC bytes and the input bytes needed to verify them later via verifyHmac().
| Return | Name | Description |
|---|---|---|
MessageIntegrity | ||
MessageIntegrity | ||
std::unique_ptr< Attribute > | clone virtual | Returns a deep copy of this attribute. |
bool | verifyHmac const | Verifies the stored HMAC against the stored input bytes using key. |
std::string | input const inline | #### Returns |
std::string | hmac const inline | #### Returns |
std::string | key const inline | #### Returns |
void | setInput inline | Sets the raw message bytes used as HMAC input during verification. |
void | setHmac inline | Sets the raw HMAC value (used when copying a received attribute). |
void | setKey inline | Sets the HMAC key; triggers HMAC computation on write(). |
void | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const | Writes the body (not the type or size) to the given buffer. |
MessageIntegrity()MessageIntegrity(const MessageIntegrity & r)virtual
virtual std::unique_ptr< Attribute > clone()Returns a deep copy of this attribute.
const
bool verifyHmac(std::string_view key) constVerifies the stored HMAC against the stored input bytes using key.
key HMAC key (MD5 of username:realm:password for long-term creds).true if the computed HMAC matches the stored HMAC.
const inline
inline std::string input() constThe raw message bytes captured at read time, used for HMAC verification.
const inline
inline std::string hmac() constThe raw 20-byte HMAC value as read from the wire.
const inline
inline std::string key() constThe HMAC key set for outgoing message signing (empty if not set).
inline
inline void setInput(const std::string & input)Sets the raw message bytes used as HMAC input during verification.
input Byte string of the message up to this attribute.inline
inline void setHmac(const std::string & hmac)Sets the raw HMAC value (used when copying a received attribute).
hmac 20-byte HMAC string.inline
inline void setKey(const std::string & key)Sets the HMAC key; triggers HMAC computation on write().
key MD5 digest of the long-term credential (username:realm:password).virtual
virtual void read(BitReader & reader)Reads the body (not the type or size) for this type of attribute from the given buffer.
reader Source bit reader positioned at the attribute body.virtual const
virtual void write(BitWriter & writer) constWrites the body (not the type or size) to the given buffer.
writer Destination bit writer.| Return | Name | Description |
|---|---|---|
constexpr uint16_t | TypeID static | |
constexpr uint16_t | Size static | HMAC-SHA1 output is always 20 bytes. |
static
constexpr uint16_t TypeID = 0x0008static
constexpr uint16_t Size = 20HMAC-SHA1 output is always 20 bytes.
std::string _inputstd::string _hmacstd::string _key