-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
I'm a little lost on what the signatureAlgorithm is supposed to be, and it seems to vary depending on key algorithm, at least looking at our implementation. Looking at the code we produce a Subject Public Key Algorithm for RSA (https://tools.ietf.org/html/rfc3279#section-2.3.1), while we produce a Signature Algorithm for DSA (https://tools.ietf.org/html/rfc3279#section-2.2.2) and ECDSA (https://tools.ietf.org/html/rfc3279#section-2.2.3).
Evidence for RSA:
openssl/crypto/rsa/rsa_ameth.c
Lines 812 to 815 in 8158cf2
| if (pad_mode == RSA_PKCS1_PADDING) { | |
| X509_ALGOR_set0(alg, OBJ_nid2obj(NID_rsaEncryption), V_ASN1_NULL, 0); | |
| return 1; | |
| } |
openssl/crypto/rsa/rsa_ameth.c
Line 822 in 8158cf2
| X509_ALGOR_set0(alg, OBJ_nid2obj(EVP_PKEY_RSA_PSS), V_ASN1_SEQUENCE, os); |
Evidence for DSA (snid is the composed digest-sign NID):
openssl/crypto/dsa/dsa_ameth.c
Lines 492 to 497 in 8158cf2
| hnid = OBJ_obj2nid(alg1->algorithm); | |
| if (hnid == NID_undef) | |
| return -1; | |
| if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | |
| return -1; | |
| X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); |
Evidence for ECDSA:
Lines 493 to 498 in 8158cf2
| hnid = OBJ_obj2nid(alg1->algorithm); | |
| if (hnid == NID_undef) | |
| return -1; | |
| if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey))) | |
| return -1; | |
| X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0); |
So I wonder, why the difference? And most of all, I wonder why the digest-sign algid should be used at all, considering that the SignerInfo structure has a separate digestAlgorithm and the Message Signature Verification Process isn't interest in a digest-sign algorithm at all
Is this possibly a bug? Otherwise, what am I missing? Am I reading the code wrong?
If this is indeed an correct inconsistency, is this documented in a standard somewhere?