-
Notifications
You must be signed in to change notification settings - Fork 77
PkcsOaepParams mis-aligned #266
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
Comments
I tested on softhsm and it still fails, I quickly subbed in bouncyHSM for a quick sanity check and the test passes on both Windows 11 and Linux. This is sadly a side-effect of what's discussed in #70. |
Given the circumstances I think it may be tough to action in it's entirety which I think #70 is attempting to do. From the looks of it (reading that issue as well as scouring SoftHSM), it appears Windows is the only one guaranteed to do struct packing. Would it be wise to conditionally do it on Windows only? I'd appreciate the sanity check. If that is sound, the next question would be how to accomplish that. |
…arams struct on windows only. Signed-off-by: Ivo Zeba <[email protected]>
From the conclusion of the other issue is seems that we could try packing all C structures on windows only (like you did in the PR but for all structs)? |
I think it's a great approach. Too bad we don't have any Windows CI runners :-/ |
ah right! Maybe we can start by asking a kind soul testing all on Windows 🙏 |
I was looking at why RSA PKCS OAEP fails with data and while debugging on Windows I noticed that CK_RSA_PKCS_OAEP_PARAMS should be 24 bytes, while checking
std::mem::size_of::<PkcsOaepParams>()
it was returning 32.The struct is defined as follows:
After a closer look it turns out that without
repr(C)
it's returning 24, meaning that it's being aligned to the next 8 bytes (green is expected while red is what appears to be happening):Adding packed (
#[repr(C, packed)]
) appears to remove the inter-field padding and thersa_pkcs_oaep_with_data
test passes.I need to test on linux but would welcome any thoughts :).
The text was updated successfully, but these errors were encountered: