Skip to content

Commit

Permalink
Update main.rs with Replacement unfinished
Browse files Browse the repository at this point in the history
TODO: read in-memory salt and password_hash
TODO: replace componentID
  • Loading branch information
jingdil2 authored Feb 28, 2024
1 parent 063d850 commit a27e77e
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions application_processor/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,43 @@ fn attest_component() {
}

// Host I/O should conform with https://github.com/sigpwny/2024-ectf-uiuc/blob/main/ectf_tools/replace_tool.py
fn replace_component() {
fn replace_component(replacement_token : [u8; 16], old_component_id: u32, new_component_id : u32) {
let target_duration = Duration::from_millis(4800); // Set target duration to be 4.8s
let start = Instant::now(); // Start timer

let mut flag : bool = false;
// delay for 3 seconds
delay(3000000);

// pre-defined salt needed
let salt =
let argon2 = Argon2::default();
let token_hash = argon2.hash_password(replacement_token, &salt)?.to_string();




// Compare Token Attempt hash to stored Correct Token hash
if(!(token_hash ^ )) {
flag = true;
}

// Wait until 4.8 seconds total time elapsed since beginning of transaction
if start.elapsed() < target_duration {
let remaining_time = target_duration - start.elapsed();
sleep(remaining_time);
}

// Update Component ID list with new Component ID if flag is true, and send success/error message
if (flag) {
//TODO: Replace component here

let success_message: [u8; LEN_MAX_SECURE] = "%success: Replacement success%".as_bytes();
send_host_success(success_message);
} else {
let error_message: [u8; LEN_MAX_SECURE] = "%error: Replacement failed%".as_bytes();
send_host_error(error_message);
}

}

Expand All @@ -123,4 +159,4 @@ fn boot_verify() {

fn post_boot() {

}
}

0 comments on commit a27e77e

Please sign in to comment.