-
Notifications
You must be signed in to change notification settings - Fork 315
Performance | Use lower-allocation AE primitives in SqlColumnEncryptionCertificateStoreProvider #3660
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
base: main
Are you sure you want to change the base?
Performance | Use lower-allocation AE primitives in SqlColumnEncryptionCertificateStoreProvider #3660
Conversation
…ypair Also remove an indentation level and dispose of the intermediary X509Certificate2.
This changes some of the test behaviour: previously, it was calling RSADecrypt and RSAVerifySignature directly. Since these methods no longer exist, we follow the public API (which also calls these methods' equivalent functionality.) This also addresses a TODO: in the test code.
Also ensure that the ref structs implement IDisposable.
foreach (CryptoVector cryptoParameter in cryptoParametersListForTest) | ||
// Convert the PFX into a certificate and install it into the local user's certificate store. | ||
// We can only do this cross-platform on the CurrentUser store, which matches the baseline data we have. | ||
Debug.Assert(rsaPfx != null && rsaPfx.Length > 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.
Should this be an xUnit Assert() ? Here and below.
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.
Yes. There were a few other existing instances in the same test, I've changed those too.
...t.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCertificateStoreProvider.cs
Show resolved
Hide resolved
|
||
// Find the certificate and return | ||
return GetCertificate(storeLocation, storeName, keyPath, thumbprint, isSystemOp); | ||
else |
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.
Unnecessary else
here.
if (!certificate.HasPrivateKey) | ||
{ | ||
// Close the certificate store | ||
certificateStore?.Close(); |
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.
Do we still need to Close()? The X509Store docs don't say whether or not Dispose() includes whatever Close() does.
The source code clearly does though:
So you're good, despite the docs :(
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.
Yes - backed up by the netfx reference source.
It looks like this was new in net46 though, which might explain the old usage.
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
Swap Debug.Assert to xUnit assertions. Add explanatory comment when parsing master key path. Remove redundant else.
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.
Looks great!
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
Description
This is my final PR in this set of changes to this area, picking up where #3612 left off. Benchmarks for this PR are located in #3554.
The previous PR used the AlwaysEncrypted primitives in
SqlColumnEncryptionCspProvider
andSqlColumnEncryptionCngProvider
. This one introduces them toSqlColumnEncryptionCertificateStoreProvider
.While verifying this, I also noticed that the
TestRsaCryptoWithNativeBaseline
test was calling private methods using reflection, but that there was a TODO item in the test to use the public API surface instead. I've done this.Issues
PR 1/3: #3554.
PR 2/3: #3612.
PR 3/3: this one.
Testing
As in the previous PR, automated tests pass. I also created an AE-enabled table in SSMS which used a certificate store-based master key and confirmed that I was able to query it and insert records into it.