use xmpp_parsers::{ hashes::{Algo, Hash}, jingle_dtls_srtp::Setup, ns::JINGLE_DTLS, Error, }; use crate::helpers::ColonSeparatedHex; generate_element!( /// Fingerprint of the key used for a DTLS handshake. Fingerprint, "fingerprint", JINGLE_DTLS, attributes: [ /// The hash algorithm used for this fingerprint. hash: Required = "hash", /// Indicates which of the end points should initiate the TCP connection establishment. setup: Option = "setup" ], text: ( /// Hash value of this fingerprint. value: ColonSeparatedHex> ) ); impl Fingerprint { /// Create a new Fingerprint from a Setup and a Hash. pub fn from_hash(setup: Setup, hash: Hash) -> Fingerprint { Fingerprint { hash: hash.algo, setup: Some(setup), value: hash.hash, } } /// Create a new Fingerprint from a Setup and parsing the hash. pub fn from_colon_separated_hex( setup: Setup, algo: &str, hash: &str, ) -> Result { let algo = algo.parse()?; let hash = Hash::from_colon_separated_hex(algo, hash)?; Ok(Fingerprint::from_hash(setup, hash)) } }