pub fn match_on_short_cred(&self, passwd: &str) -> bool {
        // 1. Get password and SASLprep(password);
        let ped = stringprep::saslprep(passwd);
        if ped.is_err() {
            return false
        }
        let ped = ped.unwrap().into_owned();

        // 2. Modify the message len to point to MessageIntegrity's end
        let mut raw = self.raw_up_to.clone();
        // msg_len = size of msg up to attribute - header length + attribute
        // size (attribute header + hash size)
        let msg_len = raw.len() - DATA_OFFSET + 4 + 20;
        BigEndian::write_u16(&mut raw[2..4], msg_len as u16);

        // 3. Hash 2. using 1. as key
        let mhash = hmacsha1::hmac_sha1(ped.as_bytes(), &raw);
        // Sha computed doesn't match the expected, return error
        if mhash != self.hash {
            return false
        }

        true
    }
// Verify the MessageIntegraty attribute, using the short-term credentials.
// Returns 'true' if the expected hash is computed, or 'false' otherwise.
Verify the MessageIntegraty attribute, using the short-term credentials.
Returns 'true' if the expected hash is computed, or 'false' otherwise.
Verify the MessageIntegraty attribute using the short - term credentials . Returns ' true ' if the expected hash is computed or ' false ' otherwise .
pub fn match_on_short_cred(&self, passwd: &str) -> bool {
        // 1. Get password and SASLprep(password);
        let ped = stringprep::saslprep(passwd);
        if ped.is_err() {
            return false
        }
        let ped = ped.unwrap().into_owned();
        // 2. Modify the message len to point to MessageIntegrity's end
        let mut raw = self.raw_up_to.clone();
        // msg_len = size of msg up to attribute - header length + attribute
        // size (attribute header + hash size)
        let msg_len = raw.len() - DATA_OFFSET + 4 + 20;
        BigEndian::write_u16(&mut raw[2..4], msg_len as u16);
        // 3. Hash 2. using 1. as key
        let mhash = hmacsha1::hmac_sha1(ped.as_bytes(), &raw);
        // Sha computed doesn't match the expected, return error
        if mhash != self.hash {
            return false
        }
        true
    }
pub fn match_on_short_cred ( & self , passwd : & str ) -> bool { // 1. Get password and SASLprep(password); let ped = stringprep :: saslprep ( passwd ) ; if ped . is_err ( ) { return false } let ped = ped . unwrap ( ) . into_owned ( ) ; // 2. Modify the message len to point to MessageIntegrity's end let mut raw = self . raw_up_to . clone ( ) ; // msg_len = size of msg up to attribute - header length + attribute // size (attribute header + hash size) let msg_len = raw . len ( ) - DATA_OFFSET + 4 + 20 ; BigEndian :: write_u16 ( & mut raw [ 2 .. 4 ] , msg_len as u16 ) ; // 3. Hash 2. using 1. as key let mhash = hmacsha1 :: hmac_sha1 ( ped . as_bytes ( ) , & raw ) ; // Sha computed doesn't match the expected, return error if mhash != self . hash { return false } true }
Verify the MessageIntegraty attribute, using the short-term credentials.
Verify the MessageIntegraty attribute using the short - term credentials .
&self
passwd
&str
&self
passwd
&str