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 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) theMessageIntegritySha256
attribute itself.key
- theHMACKey
key
§Returns:
true if the message integrity attribute matches the computed value.
Trait Implementations§
source§impl Clone for MessageIntegritySha256
impl Clone for MessageIntegritySha256
source§fn clone(&self) -> MessageIntegritySha256
fn clone(&self) -> MessageIntegritySha256
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 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§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 Freeze for MessageIntegritySha256
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
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
)