Skip to content

Commit

Permalink
Test Signer::new() function
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulstrackx committed Jan 22, 2024
1 parent 5c3e481 commit caed948
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion intel-sgx/sgxs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ sha2 = { version = "0.8", optional = true } # MIT OR Apache-2.0
[features]
crypto-openssl = ["openssl", "openssl-sys", "foreign-types"]

[dev-dependencies]
[target.'cfg(not(target_env = "sgx"))'.dev-dependencies]
crypto-hash = "0.3" # MIT
14 changes: 14 additions & 0 deletions intel-sgx/sgxs/src/sigstruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,17 @@ pub fn read<R: Read>(reader: &mut R) -> IoResult<Sigstruct> {
reader.read_exact(&mut buf)?;
Sigstruct::try_copy_from(&buf).ok_or_else(|| unreachable!())
}

#[cfg(test)]
mod tests {
use super::{EnclaveHash, Signer};

#[test]
fn signer() {
let signer = Signer::new(EnclaveHash::new([0; 32]));
assert!(signer.date & 0xff <= 0x31); // day
assert!(signer.date & 0xff00 <= 0x1200); // month
assert!(signer.date & 0xffff0000 >= 0x20240000); // year
assert!(signer.date & 0xffff0000 <= 0x20500000);
}
}

0 comments on commit caed948

Please sign in to comment.