Enum stun_rs::attributes::stun::MessageIntegritySha256
source · pub enum MessageIntegritySha256 {
Encodable(EncodableMessageIntegritySha256),
Decodable(DecodableMessageIntegritySha256),
}Expand description
The MessageIntegritySha256 attribute contains an HMAC-SHA256
RFC2104
of the STUN message. This attribute can be present in any STUN
message type.
§Examples
// use short-term-credentials to generate the key
let key = HMACKey::new_short_term("foo bar")?;
let attr = MessageIntegritySha256::new(key);
assert_eq!(attr.attribute_type(), AttributeType::from(0x001C));Variants§
Encodable(EncodableMessageIntegritySha256)
Encodable version of this attribute. This is used when the attribute is added to a STUN message that is going to be sent to the network.
Decodable(DecodableMessageIntegritySha256)
Decodable version of this attribute. This is the decoded attribute received from the network.
Implementations§
source§impl MessageIntegritySha256
impl MessageIntegritySha256
sourcepub fn new(key: HMACKey) -> Self
pub fn new(key: HMACKey) -> Self
Creates a new attribute.
§Arguments:
key- The key used for theHMACdepends on which credential mechanism is in use.
sourcepub fn validate(&self, input: &[u8], key: &HMACKey) -> bool
pub fn validate(&self, input: &[u8], key: &HMACKey) -> bool
Validates the message using the HMAC value generated from the key
§Arguments:
input- the STUN message up to (but excluding) theMessageIntegritySha256attribute itself.key- theHMACKeykey
§Returns:
true if the message integrity attribute matches the computed value.
Trait Implementations§
source§impl Debug for MessageIntegritySha256
impl Debug for MessageIntegritySha256
source§impl From<MessageIntegritySha256> for StunAttribute
impl From<MessageIntegritySha256> for StunAttribute
source§fn from(value: MessageIntegritySha256) -> Self
fn from(value: MessageIntegritySha256) -> Self
Converts to this type from the input type.
source§impl PartialEq for MessageIntegritySha256
impl PartialEq for MessageIntegritySha256
source§fn eq(&self, other: &MessageIntegritySha256) -> bool
fn eq(&self, other: &MessageIntegritySha256) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl StunAttributeType for MessageIntegritySha256
impl StunAttributeType for MessageIntegritySha256
source§fn get_type() -> AttributeTypewhere
Self: Sized,
fn get_type() -> AttributeTypewhere
Self: Sized,
Returns the STUN attribute type.
source§fn attribute_type(&self) -> AttributeType
fn attribute_type(&self) -> AttributeType
Returns the STUN attribute type of this instance.
impl Eq for MessageIntegritySha256
impl StructuralPartialEq for MessageIntegritySha256
Auto Trait Implementations§
impl RefUnwindSafe for MessageIntegritySha256
impl !Send for MessageIntegritySha256
impl !Sync for MessageIntegritySha256
impl Unpin for MessageIntegritySha256
impl UnwindSafe for MessageIntegritySha256
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more