Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ChocolateLoverRaj committed Jul 3, 2024
1 parent 1c8d728 commit 05120f1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion crosec/src/commands/fp_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bytemuck::{bytes_of, Pod, Zeroable};

use crate::ec_command::ec_command_with_dynamic_output_size;

use super::{CrosEcCmd, fp_info::EcResponseFpInfo, get_protocol_info::EcResponseGetProtocolInfo};
use super::{fp_info::EcResponseFpInfo, get_protocol_info::EcResponseGetProtocolInfo, CrosEcCmd};

#[repr(C)]
#[derive(Pod, Zeroable, Clone, Copy)]
Expand Down
12 changes: 7 additions & 5 deletions crosec/src/commands/fp_get_encryption_status.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::os::fd::AsRawFd;
use bytemuck::{Pod, Zeroable};
use crate::commands::CrosEcCmd;
use crate::ec_command::ec_command_bytemuck;
use crate::EcCmdResult;
use bytemuck::{Pod, Zeroable};
use std::os::fd::AsRawFd;

#[repr(u32)]
pub enum FpEncryptionStatus {
SeedSet = 0b1
SeedSet = 0b1,
}

#[derive(Pod, Zeroable, Copy, Clone)]
Expand All @@ -16,6 +16,8 @@ pub struct EcResponseFpGetEncryptionStatus {
pub status: u32,
}

pub fn fp_get_encryption_status<File: AsRawFd>(file: &mut File) -> EcCmdResult<EcResponseFpGetEncryptionStatus> {
pub fn fp_get_encryption_status<File: AsRawFd>(
file: &mut File,
) -> EcCmdResult<EcResponseFpGetEncryptionStatus> {
ec_command_bytemuck(CrosEcCmd::FpGetEncryptionStatus, 0, &(), file.as_raw_fd())
}
}
2 changes: 1 addition & 1 deletion crosec/src/commands/fp_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bytemuck::{Pod, Zeroable};
use crate::{ec_command::ec_command_bytemuck, EcCmdResult};

use super::{
CrosEcCmd,
get_cmd_versions::{ec_cmd_get_cmd_versions, V1},
CrosEcCmd,
};

#[repr(C, align(4))]
Expand Down
5 changes: 4 additions & 1 deletion crosec/src/commands/fp_set_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ struct EcParamsFpSeed {
pub seed: [u8; FP_CONTEXT_TPM_BYTES],
}

pub fn fp_set_seed<File: AsRawFd>(file: &mut File, seed: [u8; FP_CONTEXT_TPM_BYTES]) -> EcCmdResult<()> {
pub fn fp_set_seed<File: AsRawFd>(
file: &mut File,
seed: [u8; FP_CONTEXT_TPM_BYTES],
) -> EcCmdResult<()> {
ec_command_bytemuck(
CrosEcCmd::FpSetSeed,
0,
Expand Down
4 changes: 2 additions & 2 deletions crosec/src/commands/fp_upload_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use bytemuck::{bytes_of, Pod, Zeroable};
use crate::{ec_command::ec_command_with_dynamic_output_size, EcCmdResult};

use super::{
CrosEcCmd, fp_download::FpTemplate,
fp_info::EcResponseFpInfo, get_protocol_info::EcResponseGetProtocolInfo,
fp_download::FpTemplate, fp_info::EcResponseFpInfo,
get_protocol_info::EcResponseGetProtocolInfo, CrosEcCmd,
};

#[derive(Pod, Zeroable, Clone, Copy)]
Expand Down
11 changes: 8 additions & 3 deletions ectool/src/fp_get_encryption_status_command.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
use std::fs::File;
use crosec::commands::fp_get_encryption_status::{EcResponseFpGetEncryptionStatus, fp_get_encryption_status};
use crosec::commands::fp_get_encryption_status::{
fp_get_encryption_status, EcResponseFpGetEncryptionStatus,
};
use crosec::CROS_FP_PATH;
use std::fs::File;

pub fn fp_get_encryption_status_command() -> color_eyre::Result<()> {
let mut file = File::open(CROS_FP_PATH)?;
let EcResponseFpGetEncryptionStatus { status, valid_flags } = fp_get_encryption_status(&mut file)?;
let EcResponseFpGetEncryptionStatus {
status,
valid_flags,
} = fp_get_encryption_status(&mut file)?;
println!("FPMCU encryption status: {status:#b}");
println!("Valid flags: {valid_flags:#b}");
Ok(())
Expand Down

0 comments on commit 05120f1

Please sign in to comment.