Skip to content
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

CRYPTOAPI_BLOB exists in metadata but not in WinSDK #1339

Closed
timsneath opened this issue Oct 29, 2022 · 7 comments
Closed

CRYPTOAPI_BLOB exists in metadata but not in WinSDK #1339

timsneath opened this issue Oct 29, 2022 · 7 comments
Assignees
Labels
bug Something isn't working usability Touch-up to improve the user experience for a language projection

Comments

@timsneath
Copy link
Contributor

Windows.Win32.Security.Cryptography.CRYPTOAPI_BLOB is defined as a struct in the metadata, but this struct does not appear in the Win32 header files, to the best of my knowledge.

I think this is really CRYPT_INTEGER_BLOB.

Here is an extract from wincrypt.h, which I think shows that this name has been generated incorrectly:

typedef struct _CRYPTOAPI_BLOB {
                            DWORD   cbData;
    _Field_size_bytes_(cbData)  BYTE    *pbData;
} CRYPT_INTEGER_BLOB, *PCRYPT_INTEGER_BLOB,
CRYPT_UINT_BLOB, *PCRYPT_UINT_BLOB,
CRYPT_OBJID_BLOB, *PCRYPT_OBJID_BLOB,
CERT_NAME_BLOB, *PCERT_NAME_BLOB,
CERT_RDN_VALUE_BLOB, *PCERT_RDN_VALUE_BLOB,
CERT_BLOB, *PCERT_BLOB,
CRL_BLOB, *PCRL_BLOB,
DATA_BLOB, *PDATA_BLOB,
CRYPT_DATA_BLOB, *PCRYPT_DATA_BLOB,
CRYPT_HASH_BLOB, *PCRYPT_HASH_BLOB,
CRYPT_DIGEST_BLOB, *PCRYPT_DIGEST_BLOB,
CRYPT_DER_BLOB, *PCRYPT_DER_BLOB,
CRYPT_ATTR_BLOB, *PCRYPT_ATTR_BLOB;

It's critical (for my purposes) that the struct is the same as the C equivalent; amongst other things, I automatically generate tests that the generated Dart struct matches the equivalent C size, and I can only do that if the structs in the Win32 metadata resolve.

Thanks!

@kennykerr
Copy link
Contributor

I automatically generate tests that the generated Dart struct matches the equivalent C size

That sounds like what I requested here: #1330

How exhaustive is your testing so far? Just wondering how many more issues are lurking in metadata.

And are you testing against the original headers with MSVC or are you generating C structs to compare with? Obviously, the latter would hide errors in metadata.

@mikebattista
Copy link
Collaborator

This is just a naming issue. But there are several typedefs for this struct. Is CRYPT_INTEGER_BLOB what we want to use for all cases? Or should we stick with the more generic CRYPTOAPI_BLOB?

@kennykerr
Copy link
Contributor

A single struct seems preferable to an explosion of identical structs.

@timsneath
Copy link
Contributor Author

Yeah. But you could pick any one of the typedef names you like, so long as it's one that exists in C.

I recommended CRYPT_INTEGER_BLOB merely because that's the one that's documented as the canonical name for this struct.

@mikebattista
Copy link
Collaborator

Ok. It's first in the list and is the only one with documentation so that's a good reason to use it. Thanks.

@mikebattista mikebattista self-assigned this Nov 1, 2022
@mikebattista mikebattista added bug Something isn't working usability Touch-up to improve the user experience for a language projection labels Nov 1, 2022
@timsneath
Copy link
Contributor Author

@kennykerr

How exhaustive is your testing so far? Just wondering how many more issues are lurking in metadata.

I currently test about 350 structs with every build. I have some Dart code that autogenerates a C file, which is compiled on 32-bit and 64-bit architectures to generate a JSON-style map of structs to sizeof() data. Then I use that output to generate a Dart test file which compares my generated struct sizes to the MSVC data. It's not pretty, but I relied on this in the earliest days of my package (before Win32 metadata became available and when Dart didn't have good support for packed structs).

This is the first time I've seen a regression, which suggests that the problem isn't endemic. I think these handcrafted enum types are problematic, though -- I've seen two in the last few weeks which have been generated incorrectly (#1344 and #1340).

@kennykerr
Copy link
Contributor

Ah I was hoping you were comparing against the originals as in #1330 - that would flush out most all issues of this kind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working usability Touch-up to improve the user experience for a language projection
Projects
None yet
Development

No branches or pull requests

3 participants