-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes issue wrong max size in some sized buffer types. #549
Fixes issue wrong max size in some sized buffer types. #549
Conversation
65258c9
to
8d19bf2
Compare
Some of the sized buffers had their buffer sizes set as numbers. Even though this in some cases were the correct numbers they were a little hard to determine if they actually followed the size specified in the standard. So this PR fixes parallaxsecond#548 in the main branch by using the the calculations specified in the standard for the buffer sizes. Signed-off-by: Jesper Brynolf <[email protected]>
8d19bf2
to
bf24797
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the effort, that was very quick!
fn test_max_sized_ecc_parameter_conversions() { | ||
let expected_secret = [0xffu8; EncryptedSecret::MAX_SIZE]; | ||
let native = EncryptedSecret::try_from(expected_secret.as_slice().to_vec()).expect( | ||
"It should be possible to convert an array of MAX size into a EncryptedSecret object.", | ||
); | ||
let tss = TPM2B_ENCRYPTED_SECRET::from(native); | ||
assert_eq!(EncryptedSecret::MAX_SIZE, tss.size as usize); | ||
// This will be a compiler error if the max size does not match the TSS buffer size. | ||
assert_eq!(expected_secret, tss.secret); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess in the future we can make a macro out of this sort of test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty straightforward, thanks for the work! 👏
Some of the sized buffers had their buffer sizes
set as numbers. Even though this in some cases
were the correct numbers they were a little hard
to determine if they actually followed the size
specified in the standard. So this PR fixes #548
in the main branch by using the the calculations
specified in the standard for the buffer sizes.