Skip to content

Conversation

edwardneal
Copy link
Contributor

Description

This builds on #3554, using the lower-allocation AE primitives in SqlColumnEncryptionCspProvider and SqlColumnEncryptionCngProvider. Benchmarks for this are located in the original PR.

I'm separating these two changes from SqlColumnEncryptionCertificateStoreProvider due to the latter's size, but it'll be fairly similar once the use of X509Certificate2 has been refactored into an RSA instance. I'll incorporate the feedback from this PR into the second one.

We make some minor code style changes, largely to remove a few Yoda conditions, replace == null with is null comparisons and clean up the comments. Besides this though, almost all of the DecryptColumnEncryptionKey and EncryptColumnEncryptionKey methods are replaced with references to the new AE primitives.

While not the main goal, I also noticed and fixed one case where we were opening a CngKey and never disposing it.

Issues

Builds on #3554.

Testing

Automated tests pass.

I also created an AE-enabled table in SSMS which used a CNG-based master key, and confirmed that I was able to query values from it. This should confirm that data created outside of SqlClient can now be read successfully.

Could someone run CI please?

@edwardneal edwardneal requested a review from a team as a code owner September 11, 2025 22:18
@paulmedynski
Copy link
Contributor

/azp run

@paulmedynski paulmedynski self-assigned this Sep 12, 2025
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Contributor

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great. Some comments about [NotNull] and usings.

Simplify CreateRSACngProvider.
Use static CngProvider instances for well-known providers where possible.
@paulmedynski
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 96.77419% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.61%. Comparing base (cd3dbd1) to head (3152361).
⚠️ Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
...qlClient/SqlColumnEncryptionCngProvider.Windows.cs 93.75% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (cd3dbd1) and HEAD (3152361). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (cd3dbd1) HEAD (3152361)
addons 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3612      +/-   ##
==========================================
- Coverage   65.48%   59.61%   -5.88%     
==========================================
  Files         275      271       -4     
  Lines       61518    61253     -265     
==========================================
- Hits        40288    36517    -3771     
- Misses      21230    24736    +3506     
Flag Coverage Δ
addons ?
netcore 63.84% <96.77%> (-3.82%) ⬇️
netfx 60.81% <98.33%> (-8.40%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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