Skip to content

Use correct data types for DWORD - #78

Merged
alexherrero merged 3 commits into
google:masterfrom
ZetaTwo:dword-fix
Jun 13, 2025
Merged

alexherrero merged 3 commits into
google:masterfrom
ZetaTwo:dword-fix

Conversation

@ZetaTwo

@ZetaTwo ZetaTwo commented Dec 3, 2024

Copy link
Copy Markdown
Contributor

Currently, the code reads a property that is supposed to be a DWORD (ref: https://learn.microsoft.com/en-us/windows/win32/seccng/key-storage-property-identifiers#ncrypt_impl_type_property) using a cast to a golang int but those are only guaranteed to be "at least" 32 bits. This caused an issue where it was actually reading a 64-bit value and thus setting the upper 32 bits to undefined data.

This int/uint32 inconsistency is present in the "Chain resolution constants" as well (and possible elsewhere) but I didn't touch them in this PR.

This was then combined with the fact that the nCryptImplSoftwareFlag is compared using == and not with a mask, which would be more proper for a flag, caused the condition to incorrectly be evaluated to false.

I have changed the reading of the property to be a uint32 to match the spec. I changed the name of the reading function since it was only ever used there anyway and now it's clearer. I also changed the comparison to treat the field as a flag.

@google-cla

google-cla Bot commented Dec 3, 2024

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@alexherrero alexherrero self-assigned this Jun 13, 2025
@alexherrero
alexherrero self-requested a review June 13, 2025 23:02
@alexherrero
alexherrero merged commit 2066ad1 into google:master Jun 13, 2025
@ZetaTwo
ZetaTwo deleted the dword-fix branch November 16, 2025 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants