I generated two certificates using openssl cli. The first (if I'm not wrong) should be rsa_pss_rsae_sha256 and the second (dito) should be rsa_pss_pss_sha256.
openssl genpkey -out ca-rsa.key.pem -algorithm RSA
openssl genpkey -out ca-rsa-pss.key.pem -algorithm RSA-PSS
# rsae
openssl req -x509 -days 1 -subj "/CN=ca-rsae" \
-sigopt rsa_padding_mode:pss -sha1 -sigopt rsa_pss_saltlen:20 \
-key ca-rsa.key.pem -out ca-rsae.cert.pem
# rsa-pss
openssl req -x509 -days 1 -subj "/CN=ca-rsa-pss" \
-key ca-rsa-pss.key.pem -out ca-rsa-pss.cert.pem
Using openssl to print the two certificate gives the following (truncated for briefly) result:
# rsae
openssl x509 -noout -text -in ca-rsae.cert.pem
Certificate:
Data:
Signature Algorithm: rsassaPss
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
# rsa-pss
openssl x509 -noout -text -in ca-rsa-pss.cert.pem
Certificate:
Data:
Signature Algorithm: rsassaPss
Subject Public Key Info:
Public Key Algorithm: rsassaPss
Now I'm trying to determine the TLS SignatureScheme of each certificate using cryptography but it seems that the lib doesn't distinguish Public Key Algorithm: rsaEncryption from Public Key Algorithm: rsassaPss and just create an RSAPublicKey object for both:
>>> for cert in (rsae, rsa_pss):
... print(cert.public_key())
... print(cert.signature_algorithm_oid)
... print(cert.signature_algorithm_parameters)
... print(cert.signature_hash_algorithm)
... print()
...
<cryptography.hazmat.bindings._rust.openssl.rsa.RSAPublicKey object at 0x7f35b8dbd850>
<ObjectIdentifier(oid=1.2.840.113549.1.1.10, name=RSASSA-PSS)>
<cryptography.hazmat.primitives.asymmetric.padding.PSS object at 0x7f35b9c4ec50>
<cryptography.hazmat.primitives.hashes.SHA1 object at 0x7f35b9c4ec50>
<cryptography.hazmat.bindings._rust.openssl.rsa.RSAPublicKey object at 0x7f35b8dbd850>
<ObjectIdentifier(oid=1.2.840.113549.1.1.10, name=RSASSA-PSS)>
<cryptography.hazmat.primitives.asymmetric.padding.PSS object at 0x7f35b9c4f010>
<cryptography.hazmat.primitives.hashes.SHA256 object at 0x7f35b9c4f010>
I expected the public key to have an attribute to differentiate the two, kind of signature_algorithm_oid but for the public key. Introspecting the object (dir), no such attribute seems to exist.
Hence the question, how to differentiate the two using the cryptography python library?