Skip to content

Commit

Permalink
Fixed bug where does not include len when use mac in digest
Browse files Browse the repository at this point in the history
  • Loading branch information
joalopez1206 committed Jul 16, 2024
1 parent 689601d commit 2e546aa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tsig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ pub fn get_digest_request(mac: Vec<u8> ,dns_msg: Vec<u8>, tsig_rr: ResourceRecor
let mut res: Vec<u8> = vec![];

if (mac.len() != 0) {
let mac_len = mac.len() as u16;
let bytes_mac_len = mac_len.to_be_bytes();
res.push(bytes_mac_len[0]);
res.push(bytes_mac_len[1]);
res.extend(mac.clone());
}
res.extend(dns_msg.clone());
Expand Down Expand Up @@ -328,9 +332,10 @@ pub fn process_tsig(msg: &DnsMessage, key:&[u8], key_name: String, time: u64,
return (false, TsigErrorCode::BADKEY);
}

let cond1 = check_key(key_in_rr, key_name);
let cond1 = check_key(key_in_rr.clone(), key_name.clone());
if !cond1 {
println!("RCODE 9: NOAUTH\n TSIG ERROR 17: BADKEY");
println!("key in rr: {:?} key given {:?}", key_in_rr, key_name);
return (false, TsigErrorCode::BADKEY);
}

Expand Down

0 comments on commit 2e546aa

Please sign in to comment.