pub enum MessageIntegrity {
Encodable(EncodableMessageIntegrity),
Decodable(DecodableMessageIntegrity),
}
Expand description
The MessageIntegrity
attribute contains an HMAC-SHA1
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 = MessageIntegrity::new(key);
assert_eq!(attr.attribute_type(), AttributeType::from(0x0008));
Variants§
Encodable(EncodableMessageIntegrity)
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(DecodableMessageIntegrity)
Decodable version of this attribute. This is the decoded attribute received from the network.
Implementations§
source§impl MessageIntegrity
impl MessageIntegrity
sourcepub fn new(key: HMACKey) -> Self
pub fn new(key: HMACKey) -> Self
Creates a new attribute.
§Arguments:
key
- The key used for theHMAC
depends 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) theMessageIntegrity
attribute itself.key
- theHMACKey
key
§Returns:
true if the message integrity attribute matches the computed value.
Trait Implementations§
source§impl Clone for MessageIntegrity
impl Clone for MessageIntegrity
source§fn clone(&self) -> MessageIntegrity
fn clone(&self) -> MessageIntegrity
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MessageIntegrity
impl Debug for MessageIntegrity
source§impl From<MessageIntegrity> for StunAttribute
impl From<MessageIntegrity> for StunAttribute
source§fn from(value: MessageIntegrity) -> Self
fn from(value: MessageIntegrity) -> Self
Converts to this type from the input type.
source§impl PartialEq for MessageIntegrity
impl PartialEq for MessageIntegrity
source§impl StunAttributeType for MessageIntegrity
impl StunAttributeType for MessageIntegrity
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 MessageIntegrity
impl StructuralPartialEq for MessageIntegrity
Auto Trait Implementations§
impl Freeze for MessageIntegrity
impl RefUnwindSafe for MessageIntegrity
impl !Send for MessageIntegrity
impl !Sync for MessageIntegrity
impl Unpin for MessageIntegrity
impl UnwindSafe for MessageIntegrity
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)