-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
make CryptQueryObject call compliant to interop guidelines #60702
Conversation
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks Issue DetailsFixes partially issue #51564 This PR makes the following calls compliant with Interop gudielines :
There's a change to CERT_INFO class inside Common folder, so it uses the created struct FILENAME (like CERT_INFO inside System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.Windows\Native\Primitives.cs), using CERT_INFO with COM FILENAME causes overflows in tests since it uses int instead of uint. I create this file Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextProperty_NO_NULLABLE.cs instead of reusing Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextProperty.cs because it's referenced by System.Windows.Extensions which does not support nullable yet Sorry for the PR #60218 I was trying to solve a conflict by rebasing my branch on master and I did something wrong.
|
@@ -99,7 +99,7 @@ static delegate (void* pvDecoded, int cbDecoded) | |||
{ | |||
Debug.Assert(cbDecoded >= sizeof(CERT_BASIC_CONSTRAINTS_INFO)); | |||
CERT_BASIC_CONSTRAINTS_INFO* pBasicConstraints = (CERT_BASIC_CONSTRAINTS_INFO*)pvDecoded; | |||
return ((pBasicConstraints->SubjectType.pbData[0] & CERT_BASIC_CONSTRAINTS_INFO.CERT_CA_SUBJECT_FLAG) != 0, | |||
return ((pBasicConstraints->SubjectType.ToByteArray()[0] & CERT_BASIC_CONSTRAINTS_INFO.CERT_CA_SUBJECT_FLAG) != 0, |
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.
Surely we can do better than making a byte array here...
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.
Something like
return ((pBasicConstraints->SubjectType.ToByteArray()[0] & CERT_BASIC_CONSTRAINTS_INFO.CERT_CA_SUBJECT_FLAG) != 0, | |
return ((Marshal.ReadByte(pBasicConstraints->SubjectType.pbData) & CERT_BASIC_CONSTRAINTS_INFO.CERT_CA_SUBJECT_FLAG) != 0, |
Fixes partially issue #51564
(this issue is still under progress, more PRs are to come)
This PR makes the following calls compliant with Interop gudielines :
I know the PR should be small, but it's barely the minimum to move CryptQueryObject : this call uses many struct/enum/class and safe handles, that should either also be moved to Common folder.or deleted because they already exists there (so we need to reuse the later)
There's a change to CERT_INFO class inside Common folder, so it uses the created struct FILENAME (like CERT_INFO inside System.Security.Cryptography.X509Certificates\src\Internal\Cryptography\Pal.Windows\Native\Primitives.cs), using CERT_INFO with COM FILENAME causes overflows in tests since it uses int instead of uint.
I create this file Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextProperty_NO_NULLABLE.cs instead of reusing Common/src/Interop/Windows/Crypt32/Interop.CertGetCertificateContextProperty.cs because it's referenced by System.Windows.Extensions which does not support nullable yet
Sorry for the PR #60218 I was trying to solve a conflict in interop.crypt32.cs by rebasing my branch on master and I did something wrong.