Skip to content

Commit

Permalink
Shorter Nonce and Created in UsernameToken, to let it working with HI…
Browse files Browse the repository at this point in the history
…KVISION camera
  • Loading branch information
asuper0 committed Feb 5, 2024
1 parent 16d0694 commit 2a3b3f5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions onvif/src/soap/auth/username_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ pub struct UsernameToken {

impl UsernameToken {
pub fn new(username: &str, password: &str) -> UsernameToken {
let nonce = uuid::Uuid::new_v4().to_string();
let created = chrono::Utc::now().to_rfc3339();
let concat = format!("{}{}{}", nonce, created, password);
let uuid = uuid::Uuid::new_v4();
let nonce = uuid.as_bytes();
let created = chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true);

let mut concat = Vec::with_capacity(nonce.len() + created.len() + password.len());

concat.extend_from_slice(nonce);
concat.extend_from_slice(created.as_bytes());
concat.extend_from_slice(password.as_bytes());

let digest = {
let mut hasher = sha1::Sha1::new();
hasher.update(concat.as_bytes());
hasher.update(&concat);
hasher.digest().bytes()
};

Expand Down

0 comments on commit 2a3b3f5

Please sign in to comment.