MessageIntegrity
MessageIntegrity
#include <icy/stun/attributes.h>class MessageIntegrityDefined in src/stun/include/icy/stun/attributes.h:468
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().
List of all members
| Name | Kind | Owner |
|---|---|---|
MessageIntegrity | function | Declared here |
MessageIntegrity | function | Declared here |
~MessageIntegrity | function | Declared here |
clone | function | Declared here |
verifyHmac | function | Declared here |
input | function | Declared here |
hmac | function | Declared here |
key | function | Declared here |
setInput | function | Declared here |
setHmac | function | Declared here |
setKey | function | Declared here |
read | function | Declared here |
write | function | Declared here |
TypeID | variable | Declared here |
Size | variable | Declared here |
_input | variable | Declared here |
_hmac | variable | Declared here |
_key | variable | Declared here |
~Attribute | function | Inherited from Attribute |
clone | function | Inherited from Attribute |
read | function | Inherited from Attribute |
write | function | Inherited from Attribute |
type | function | Inherited from Attribute |
size | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
consumePadding | function | Inherited from Attribute |
writePadding | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
TypeID | variable | Inherited from Attribute |
create | function | Inherited from Attribute |
paddingBytes | function | Inherited from Attribute |
paddedBytes | function | Inherited from Attribute |
typeString | function | Inherited from Attribute |
_type | variable | Inherited from Attribute |
_size | variable | Inherited from Attribute |
Attribute | function | Inherited from Attribute |
setLength | function | Inherited from Attribute |
Type | enum | Inherited from Attribute |
Inherited from Attribute
| Kind | Name | Description |
|---|---|---|
function | ~Attribute virtual inline | |
function | clone virtual | Returns a deep copy of this attribute. |
function | read virtual | Reads the body (not the type or size) for this type of attribute from the given buffer. |
function | write virtual const | Writes the body (not the type or size) to the given buffer. |
function | type const | |
function | size const | |
function | paddingBytes const inline | |
function | paddedBytes const inline | |
function | consumePadding const | Advances the reader past any 4-byte alignment padding that follows this attribute's body. |
function | writePadding const | Writes zero-fill padding bytes to align this attribute to a 4-byte boundary. |
function | typeString | |
variable | TypeID static constexpr | |
function | create static | Creates an attribute of the given wire type and body size. Returns nullptr if the type is unknown or the size is invalid. |
function | paddingBytes static inline constexpr | Returns the 4-byte alignment padding required for a body of size bytes. |
function | paddedBytes static inline constexpr | Returns the body length including 4-byte alignment padding. |
function | typeString static | |
variable | _type | |
variable | _size | |
function | Attribute | |
function | setLength | Updates the stored body length. |
enum | Type |
Public Methods
| Return | Name | Description |
|---|---|---|
MessageIntegrity | ||
MessageIntegrity | ||
std::unique_ptr< Attribute > | clone virtual override | 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 | |
std::string | hmac const inline | |
std::string | key const inline | |
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 override | Reads the body (not the type or size) for this type of attribute from the given buffer. |
void | write virtual const override | Writes the body (not the type or size) to the given buffer. |
MessageIntegrity
MessageIntegrity()Defined in src/stun/include/icy/stun/attributes.h:471
MessageIntegrity
MessageIntegrity(const MessageIntegrity & r)Defined in src/stun/include/icy/stun/attributes.h:472
clone
virtual override
virtual std::unique_ptr< Attribute > clone() overrideDefined in src/stun/include/icy/stun/attributes.h:476
Returns a deep copy of this attribute.
Reimplements
verifyHmac
const
bool verifyHmac(std::string_view key) constDefined in src/stun/include/icy/stun/attributes.h:484
Verifies the stored HMAC against the stored input bytes using key.
Parameters
keyHMAC key (MD5 of username:realm:password for long-term creds).
Returns
true if the computed HMAC matches the stored HMAC.
input
const inline
inline std::string input() constDefined in src/stun/include/icy/stun/attributes.h:487
Returns
The raw message bytes captured at read time, used for HMAC verification.
hmac
const inline
inline std::string hmac() constDefined in src/stun/include/icy/stun/attributes.h:490
Returns
The raw 20-byte HMAC value as read from the wire.
key
const inline
inline std::string key() constDefined in src/stun/include/icy/stun/attributes.h:493
Returns
The HMAC key set for outgoing message signing (empty if not set).
setInput
inline
inline void setInput(const std::string & input)Defined in src/stun/include/icy/stun/attributes.h:497
Sets the raw message bytes used as HMAC input during verification.
Parameters
inputByte string of the message up to this attribute.
setHmac
inline
inline void setHmac(const std::string & hmac)Defined in src/stun/include/icy/stun/attributes.h:501
Sets the raw HMAC value (used when copying a received attribute).
Parameters
hmac20-byte HMAC string.
setKey
inline
inline void setKey(const std::string & key)Defined in src/stun/include/icy/stun/attributes.h:505
Sets the HMAC key; triggers HMAC computation on write().
Parameters
keyMD5 digest of the long-term credential (username:realm:password).
read
virtual override
virtual void read(BitReader & reader) overrideDefined in src/stun/include/icy/stun/attributes.h:507
Reads the body (not the type or size) for this type of attribute from the given buffer.
Parameters
readerSource bit reader positioned at the attribute body.
Reimplements
write
virtual const override
virtual void write(BitWriter & writer) const overrideDefined in src/stun/include/icy/stun/attributes.h:508
Writes the body (not the type or size) to the given buffer.
Parameters
writerDestination bit writer.
Reimplements
Public Static Attributes
| Return | Name | Description |
|---|---|---|
constexpr uint16_t | TypeID static constexpr | |
constexpr uint16_t | Size static constexpr | HMAC-SHA1 output is always 20 bytes. |
TypeID
static constexpr
constexpr uint16_t TypeID = 0x0008Defined in src/stun/include/icy/stun/attributes.h:478
Size
static constexpr
constexpr uint16_t Size = 20Defined in src/stun/include/icy/stun/attributes.h:479
HMAC-SHA1 output is always 20 bytes.
Private Attributes
_input
std::string _inputDefined in src/stun/include/icy/stun/attributes.h:511
_hmac
std::string _hmacDefined in src/stun/include/icy/stun/attributes.h:512
_key
std::string _key