Skip to content
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

Help/Feature Request: X509 Certificate Builder PublicKey RSA-PSS OID support #10655

Open
VaderBV opened this issue Mar 27, 2024 · 7 comments
Open

Comments

@VaderBV
Copy link

VaderBV commented Mar 27, 2024

Hi,

I am using the X.509 Certificate Builder to build a certificate which has an RSA Subject Public Key.

I am able to build the certificate successfully.

But, when I parse the DER serialized certificate using ASN.1 Parser, I notice that the SubjectPublicKeyInfo field of the certificate has an algorithm OID - rsaEncryption OID = 1.2.840.113549.1.1.1.

Is it possible for this Subject Public Key algorithm OID to be changed to id-RSASSA-PSS OID = 1.2.840.113549.1.1.10 ?

I am trying to use the certificate with a secure element, which requires id-RSASSA-PSS OID if the key is being used for RSASSA-PSS Signature scheme.

Thanks

@alex
Copy link
Member

alex commented Mar 27, 2024 via email

@VaderBV
Copy link
Author

VaderBV commented Mar 27, 2024

Hi @alex , thanks for the reply!

I am aware of the rsa_padding argument while signing using the root CA.

However, I am specifically looking for RSA-PSS OID for the certificate Subject Public Key.
https://cryptography.io/en/latest/x509/reference/#cryptography.x509.CertificateBuilder.public_key

When an RSAPublicKey is provided to this method, the serialized DER certificate has the rsaEncryption OID as the Subject Public Key algorithm.

I am trying to understand if it is possible for this subjectPublicKeyInfo - Algorithm OID to be id-RSASSA-PSS OID.
I have attached the ASN.1 parsed example of a certificate to showcase the above.
image

@alex
Copy link
Member

alex commented Mar 27, 2024 via email

@VaderBV
Copy link
Author

VaderBV commented Apr 1, 2024

Hi,

As a follow-up question, is it possible to add support to generate rsa-pss keys ?

Using openssl it is possible to generate rsa-pss keys, but I wasn't able to do it neither with cryptography nor with pyOpenSSL.

However, I was able to load the rsa-pss key from a pem file using pyOpenSSL and was able to use it to generate a certificate with SubjectPublicKey algorithm OID as id-RSASSA-PSS.

Trying to use Cryptography library for the same, resulted in an error while trying to load the rsa-pss key from pem file.

Thanks

@OlegAndrianov
Copy link

I second that request.
It appears there is a getter cert.public_key_algorithm_oid, but there is no way to define this parameter, specifically to generate a PSS public key.
That is used, as TLS 1.3 requires it:
"/* RSASSA-PSS algorithms with public key OID RSASSA-PSS */
rsa_pss_pss_sha256(0x0809),
rsa_pss_pss_sha384(0x080a),
rsa_pss_pss_sha512(0x080b),"
And we are using cryptography to generate matching certificates.

@alex
Copy link
Member

alex commented Dec 20, 2024 via email

@OlegAndrianov
Copy link

OlegAndrianov commented Dec 20, 2024

I am quoting Signature Algorithms Section in TLS 1.3 RFC,
and it specifically says that :

RSASSA-PSS PSS algorithms:  Indicates a signature algorithm using
      RSASSA-PSS [[RFC8017](https://datatracker.ietf.org/doc/html/rfc8017)] with mask generation function 1.  The digest
      used in the mask generation function and the digest being signed
      are both the corresponding hash algorithm as defined in [[SHS](https://datatracker.ietf.org/doc/html/rfc8446#ref-SHS)].
      The length of the Salt MUST be equal to the length of the digest
      algorithm.  If the public key is carried in an X.509 certificate,
      it MUST use the RSASSA-PSS OID [[RFC5756](https://datatracker.ietf.org/doc/html/rfc5756)].
      When used in certificate signatures, the algorithm parameters MUST be DER
      encoded.  If the corresponding public key's parameters are
      present, then the parameters in the signature MUST be identical to
      those in the public key.

I agree that certificates created by default are accepted by TLS 1.3 as RSASSA-PSS algorithms with public key OID rsaEncryption (as on the screenshot)
pck1s-RSAE

but we also need to create an instance for "RSASSA-PSS algorithms with public key OID RSASSA-PSS", as defined in the TLS 1.3 Signature extensions list
That ties to RFC 4055, which says

" When the RSA private key owner wishes to limit the use of the public key exclusively to RSASSA-PSS, then the id-RSASSA-PSS object identifier MUST be used in the algorithm field within the subject public key information, and, if present, the parameters field MUST contain RSASSA-PSS-params...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants