Skip to content

Commit

Permalink
Fixes max size issue with SensitiveData.
Browse files Browse the repository at this point in the history
This fixes parallaxsecond#481

Signed-off-by: Jesper Brynolf <[email protected]>
  • Loading branch information
Superhepper committed Dec 31, 2023
1 parent 2dfc315 commit d6260ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tss-esapi/src/structures/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ pub mod public_key_rsa {
}

pub mod sensitive_data {
use crate::tss2_esys::TPMU_SENSITIVE_CREATE;
buffer_type!(
SensitiveData,
::std::mem::size_of::<TPM2B_SENSITIVE_DATA>(),
::std::mem::size_of::<TPMU_SENSITIVE_CREATE>(),
TPM2B_SENSITIVE_DATA
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tss_esapi::{
tss2_esys::TPM2B_SENSITIVE_CREATE,
Error, WrapperErrorKind,
};
use tss_esapi_sys::TPM2B_SENSITIVE_DATA;

// TPM2B_AUTH = TPM2B_DIGEST = u16 + [u8;64] = 2 + 64 = 66
// TPM2B_SENSITIVE_DATA = u16 + [u8; 256] = 2 + 256 = 258
Expand Down Expand Up @@ -124,3 +125,12 @@ fn test_marshall_unmarshall() {
"SensitiveCreate converted from SenstiveCreateBuffer did not contain the expected values"
);
}

#[test]
fn test_conversion_from_max_size_buffer() {
let data = vec![1u8; SensitiveData::MAX_SIZE];
let sensitive_data = SensitiveData::try_from(data)
.expect("It should be possible to convert maximum amount of data into SensitiveData.");
TPM2B_SENSITIVE_DATA::try_from(sensitive_data)
.expect("It should be possible to valid convert SensitiveData into TPM2B_SENSITIVE_DATA.");
}

0 comments on commit d6260ed

Please sign in to comment.