Cross-platform Always Encrypted proposal #3048
Replies: 2 comments 1 reply
-
I love this. I will loop in the AE feature team for input. Given the time of year, though, it might take a while to see any movement. |
Beta Was this translation helpful? Give feedback.
-
@edwardneal thanks for starting this. On Windows the Certificate in the store can be a container for the Asymmetric key, for AKV, the encrypted DEK is sent to the Key vault for decryption etc. In your model you have proposed a OpenSSL provider. I am interested in understanding what the user experience looks like here. As you mentioned, the certificate (as an asymmetric key container) can be placed on the filesystem. (likely protected by file system permissions and also protected by an optional but recommended passphrase). Will the Provider accept the Certificate file system path, and then use OpenSSL to decrypt/unwrap the encrypted Data encryption key using this certificate? Also is OpenSSL an implementation detail, that we happen to use OpenSSL to unwrap the payload on Linux? If OpenSSL is an implementation detail, then should the provider be used to accept a file from the filesystem, which happens to use the OpenSSL APis on Linux, and its equivalent counterpart on Windows for decryption? This way the key provider can be certificate file based, and can work on both windows and linux, and can be orthogonal to operating system/platform. |
Beta Was this translation helpful? Give feedback.
-
I've noticed that #3014 is marked as needing partner approval, so this discussion is to show my end goal and to add some context to make that review easier.
Background context
At present, SqlClient supports Always Encrypted on Linux, but the in-box SqlColumnEncryptionKeyStoreProvider implementations are Windows-only. The only way to achieve cross-platform AE support is by using a custom implementation (such as the Azure Key Vault one.) Porting these capabilities is relatively low-hanging fruit.
My end goal is for SqlClient to have in-box cross-platform support for Always Encrypted with similar semantics on both Windows and Linux. Both Windows and Linux should be able to encrypt/decrypt data using AE based on a certificate or based on a key stored in a hardware security module such as a TPM.
Always Encrypted provider changes
We currently have three in-box providers:
All three have Windows support. #3014 adds Linux and macOS support to CertificateStoreProvider, with the caveat that it's limited by the underlying OS - it can only refer to the per-user personal certificate store on Linux. I'm personally content with that caveat - it's easy to understand why (Linux doesn't have a per-machine personal certificate store.)
This just leaves the notion of supporting TPMs on Linux. CngProvider and CspProvider are very tightly bound with Windows - CNG and CSP are Windows-only concepts and naturally can't be ported as-is to Linux. To provide a way for Linux clients to get the RSA key used for Always Encrypted, I'm thinking about a "SqlColumnEncryptionOpenSslProvider" implementation in SqlClient. This would naturally be an API change, and I've not yet prototyped it... but if the prototyping went well, I'd request that.
This would throw on Windows (and thus, on .NET Framework.) On Linux under .NET 9.0, it'd be nearly identical to CngProvider and CspProvider, but the RSA class would actually be an
RSAOpenSsl
instance. The new SqlColumnEncryptionOpenSslProvider would parse the master key path it receives from SQL Server, translating it into an OpenSSL provider name and key URI in the same way that CngProvider does. We can then pass those toSafeEvpPKeyHandle.OpenKeyFromProvider
, and pass that to theRSAOpenSsl
constructor. The existing AE implementation would be able to work with the RSA functionality from there as normal.Between the two pieces of work, Windows and Linux would have similar capabilities: cross-platform Always Encrypted support which allows us to encrypt column values via a certificate, via an RSA key in a TPM, or via the existing Azure Key Vault provider.
Beta Was this translation helpful? Give feedback.
All reactions