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

Missing definition(s) in Security.Cryptography #1491

Closed
vpopescu opened this issue Mar 14, 2023 · 3 comments
Closed

Missing definition(s) in Security.Cryptography #1491

vpopescu opened this issue Mar 14, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@vpopescu
Copy link

vpopescu commented Mar 14, 2023

Which crate is this about?

windows

Crate version

0.46.0

Summary

There are some structs missing from the crate. In C header, there is this definition:

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;

However in rust I cannot find definitions for some of them, such as CERT_NAME_BLOB CRYPT_HASH_BLOB, DATA_BLOB. I have not checked them all.

Yeah, they are all different names for the same root struct, but it helps readability to use the correct name in context.

Another issue is that some definitions seem to have taken a shortcut:

#[repr(C)]
#[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"]
pub struct CERT_ID {
    pub dwIdChoice: CERT_ID_OPTION,
    pub Anonymous: CERT_ID_0,
}
..
#[repr(C)]
#[doc = "*Required features: `\"Win32_Security_Cryptography\"`*"]
pub union CERT_ID_0 {
    pub IssuerSerialNumber: CERT_ISSUER_SERIAL_NUMBER,
    pub KeyId: CRYPT_INTEGER_BLOB,
    pub HashId: CRYPT_INTEGER_BLOB,
}

whereas the C header definition is:

typedef struct _CERT_ID {
  DWORD dwIdChoice;
  union {
    CERT_ISSUER_SERIAL_NUMBER IssuerSerialNumber;
    CRYPT_HASH_BLOB           KeyId;
    CRYPT_HASH_BLOB           HashId;
  } DUMMYUNIONNAME;
} CERT_ID, *PCERT_ID;

Toolchain version/configuration

No response

Reproducible example

Try to resolve any of the above mentioned names. No specific code.

Crate manifest

[dependencies.windows]
version = "0.46.0"
features = [
    "Win32_Foundation",
    "Win32_Security",
    "Win32_Security_Cryptography",
]

Expected behavior

The definitions mentioned in MSDN documentation should be available in the crate

Actual behavior

No response

Additional comments

No response

@vpopescu vpopescu added the bug Something isn't working label Mar 14, 2023
@kennykerr
Copy link
Contributor

Another issue is that some definitions seem to have taken a shortcut

Rust doesn't support nested structs/unions hence the distinct definitions.

they are all different names for the same root struct

I'm not we want to capture aliases as that may not translate well to metadata, but I'll transfer to the Win32 metadata repo for consideration.

@kennykerr kennykerr transferred this issue from microsoft/windows-rs Mar 14, 2023
@kennykerr
Copy link
Contributor

I see that we have CRYPT_INTEGER_BLOB - we want to replace that with the more generic CRYPT_BLOB that matches CRYPT_BLOB_ARRAY.

@mikebattista
Copy link
Collaborator

I believe this is a duplicate of #1339.

@mikebattista mikebattista closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants