-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
OpenSSL provider support #89167
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones Issue DetailsIn #88656 we've added ENGINE support but ENGINEs are deprecated by OpenSSL. #55356 has approved APIs for provider but during testing (#55356 (comment)) we've found that APIs for provider will need to be adjusted since they require Example design could look like: public class OpenSslProvider : IDisposable
{
public OpenSslProvider(string providerName);
public RSA OpenRSAPrivateKey(string keyUri); // this could return alternative implementation of RSA which includes all implementation details - downside of that it will need some plumbing in X509Certificate2.CopyWithPrivateKey/X509Certificate2/SslStream etc
// .. similar for other key types
// other ideas to consider:
public SafeEvpPKeyHandle OpenRSAPrivateKey(string keyUri); // this one has downside of having to attach library handle to SafeEvpPKeyHandle handle but all pieces already understand it
public AssymetricAlgorithm OpenPrivateKey(string keyUri); // similar to above but it would be checking key type and creating appropriate instance
} This needs a bit more experimentation. I've already done some experimentation trying to get originally designed APIs to work without changes but:
My experiments can be found here: https://github.com/krwq/runtime/blob/open_named_keys/src/libraries/System.Security.Cryptography/tests/osslplugins/testprovider.c
|
I'm not sure that a new API shape is needed; or that the suggestion here is the right approach. For all other crypto primitives in .NET, the object itself maintains all related handles to keep things working so that two things with two independent lifetimes need to be managed. Using the example above: OpenSslProvider provider = new("some_pkcs11_module");
SafeEvpPKeyHandle foo = provider.OpenRSAPrivateKey("my key uri");
provider.Dispose();
RSA rsa = new RSAOpenSsl(foo); // What happens here? Trying to make that work sensibly, even just making sure we throw a managed exception instead of a SIGSEGV, I think would be difficult. I think it probably makes sense to have the provider lifetime managed by the
I view the way we could solve this with |
Note: I've updated proposal to look as it was before. |
(marking as api-approved for clarity) |
In #88656 we've added ENGINE support but we've left out providers pending more investigation on issues discovered during implementation. This API was already approved last year but asking for re-approval given time which passed.
Original issue: #55356
Background
ENGINE and providers are plug-in systems for OpenSSL which allow to make custom implementation of some crypto algorithms. That enables scenarios such as using TPM keys.
ENGINE is an old (now deprecated) plug-in system which was the only FIPS approved plugin system until recently. Providers is new plug-in system allowing a bit more flexibility to developers (but also harder to implement).
Proposal
Usage Example
Security considerations
Those APIs are not meant to be used with untrusted inputs. Allowing untrusted inputs may potentially allow attacker to use TPM or other private keys in an unintended way. Some providers i.e. "default" allow reading files from arbitrary paths (in order to read the key) which makes it further dangerous to use with untrusted inputs. Additionally providerName may load libraries into the process which adds additional risk (depending on OSSL_PROVIDER_set_default_search_path setting this may or may not be a big issue).
(considerations also apply to already added ENGINE APIs)
The text was updated successfully, but these errors were encountered: