Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[API Proposal]: Ssl*AuthenticationOptions.AllowRsaPssPad, AllowRsaPkcs1Pad #114740

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

Open
rzikm opened this issue Apr 16, 2025 · 4 comments
Open

[API Proposal]: Ssl*AuthenticationOptions.AllowRsaPssPad, AllowRsaPkcs1Pad #114740

rzikm opened this issue Apr 16, 2025 · 4 comments
Labels
api-ready-for-review API is ready for review, it is NOT ready for implementation api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net.Security
Milestone

Comments

@rzikm
Copy link
Member

rzikm commented Apr 16, 2025

Background and motivation

See full discussion at dotnet/aspnetcore#58560

As part of TLS handshake the certificate private key is used to compute a signature over the handshake to ensure TLS properties. Normally, the type of the private key inside the certificate directly identifies the signature algorithm that can be used, but the RSA algorithm has two padding modes which can be used with the same certificate.

The linked issue above mentions a specific problem where particular RSA padding mode needs to be disabled to unblock users: some older TPM modules do not support the rsa_pss_rsae_* group of algorithms which causes the handshake failure. The ability to explicitly opt out of such padding mode allows the implementation to choose a different (=supported) signature algorithm.

WIP implementation available at #114741

API Proposal

namespace System.Net.Security;

public class SslClientAuthenticationOptions
{
+       public bool AllowRsaPssPad { get; set; } = true;
+       public bool AllowRsaPkcsPad { get; set; } = true;
}

public class SslServerAuthenticationOptions
{
+       public bool AllowRsaPssPad { get; set; } = true;
+       public bool AllowRsaPkcsPad { get; set; } = true;
}

AllowRsaPssPad controls rsa_pss_* algorithms, AllowRsaPkcsPad controls rsa_pkcs1_* algorithms.

API Usage

sslStream.AuthenticateAsServer(new SslServerAuthenticationOptions
{
    // ....
    AllowRsaPssPad = false,
}

The snippet above causes the following:

  • The server will not chose rsa_pss_* signature algorithm to sign the handshake (CertificateVerify message)
  • The server will not advertise willingness to accept rsa_pss_* when requesting client certificate (in CertificateRequest TLS message)

For client, the behavior is similar: the client will not advertise rsa_pss_* in ClientHello, and will if server requests a client certificate, will not choose rsa_pss_* to sign the handshake.

Alternative Designs

instead of two boolean fields, a flag enum field may be appropriate, however, RSASignaturePaddingMode already exists so this would introduce a similar, non-compatible type.

Risks

The API as proposed is implementable for Windows and Linux. It is unknown whether there is a viable way to implement this on OSX and mobile platforms.

Implementation hurdles on Linux

On Linux specifically, the underlying OpenSSL platform provides only the "allowlist" approach. By default no explicit allowed cipher list is specified and the list is left up to the library (and global openssl.cnf configuration). If any of the new propeties is set to false (non-default), we need to

  • detect the default allowed signature algorithms
  • remove the ones we want to disable

Due to implementation difficulties, it is necessary to embed the knowledge of existing signature algorithms in the System.Net.Security internals, and if ever new signature algorithms become standard (e.g. Post Quantum Cryptography), we would need to update the internal list of known sigalgs (and backport the change to servicing .NET releases), or ignore all new sigalgs introduced in the future (the less preferred solution). Note that this would affect only users who explicitly opt-out of any of the padding methods.

@rzikm
Copy link
Member Author

rzikm commented Apr 16, 2025

@avparuch Can you confirm this API addition would address your ask from dotnet/aspnetcore#58560?

@markalward
Copy link

This will work for our ask.

we would need to update the internal list (and backport to servicing .NET releases), or ignore all new sigalgs introduced in the future.

We need to keep up-to-date with any new changes in TLS, so ignoring new signature algorithms isn't an option. It would be useful to provide an AppContext switch that allows users to override this hardcoded list, as an escape hatch for any cases where the .NET hardcoded signature algorithm list doesn't match what is actually supported by the openssl version installed on the system.

The server will not chose rsa_pss_* signature algorithm

Does this include both the rsa_pss_pss* and rsa_pss_rsae* algorithms? I'm not sure it matters much for our use case, but it would be useful to specify the exact behavior here.

@rzikm
Copy link
Member Author

rzikm commented Apr 24, 2025

We need to keep up-to-date with any new changes in TLS

We expect to backport new sigalgs via servicing changes it should not happen too often, option of ignoring the new/unknown ones was mentioned for completeness.

Does this include both the rsa_pss_pss* and rsa_pss_rsae* algorithms? I'm not sure it matters much for our use case, but it would be useful to specify the exact behavior here.

yes, the SCH_RSA_PSS_PAD identifier used to disable those in SChannel affects both of these at the same time and it is not possible to select only one variant.

@rzikm rzikm added api-ready-for-review API is ready for review, it is NOT ready for implementation and removed untriaged New issue has not been triaged by the area owner labels Apr 24, 2025
@rzikm rzikm added this to the 10.0.0 milestone Apr 24, 2025
@wfurt
Copy link
Member

wfurt commented May 1, 2025

I don't expect wide use of this but it will make the option class bigger for everyone. Not by much but still something to consider. And what are we going to do on mobile platforms or any case when we cannot enforce is? Since this is related to certificate selection and validation, can we put it on something like SslCertificateTrust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-ready-for-review API is ready for review, it is NOT ready for implementation api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net.Security
Projects
None yet
Development

No branches or pull requests

3 participants