summaryrefslogtreecommitdiff
path: root/lib/x509
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2020-05-14 02:22:20 +0300
committerDmitry Baryshkov <dbaryshkov@gmail.com>2020-05-14 11:05:04 +0300
commita4978e8884cfb97af0d0f95fdaaa59c1cfa7e2d1 (patch)
treee0014fb99f41f5ccd5a08e2b331d8659b3902478 /lib/x509
parent76e024246565d5369f9c9aebc0f22dbd0543a551 (diff)
downloadgnutls-a4978e8884cfb97af0d0f95fdaaa59c1cfa7e2d1.tar.gz
pkcs7: decode attribute OIDs when printing
Try printing symbolic names for well-known OIDs when printing PKCS7 signature info. Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
Diffstat (limited to 'lib/x509')
-rw-r--r--lib/x509/pkcs7-output.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/x509/pkcs7-output.c b/lib/x509/pkcs7-output.c
index bf5dbac837..bcffbaafd5 100644
--- a/lib/x509/pkcs7-output.c
+++ b/lib/x509/pkcs7-output.c
@@ -64,6 +64,31 @@ static void print_dn(gnutls_buffer_st * str, const char *prefix,
gnutls_free(output.data);
}
+/* Do not encode ASN1 and type for now */
+#define ENTRY(oid, name, type) {oid, sizeof(oid)-1, name, sizeof(name)-1, NULL, type}
+#define ENTRY2(oid, name) {oid, sizeof(oid)-1, name, sizeof(name)-1, NULL, ASN1_ETYPE_INVALID}
+
+static const struct oid_to_string pkcs7_attrs[] = {
+ ENTRY ("1.2.840.113549.1.9.3", "contentType", ASN1_ETYPE_OBJECT_ID),
+ ENTRY ("1.2.840.113549.1.9.4", "messageDigest", ASN1_ETYPE_OCTET_STRING),
+ ENTRY ("1.2.840.113549.1.9.5", "signingTime", ASN1_ETYPE_INVALID),
+ ENTRY2("1.2.840.113549.1.9.6", "countersignature"),
+ ENTRY2("1.2.840.113549.1.9.15", "smimeCapabilities"),
+
+ ENTRY2("1.2.840.113549.1.9.16.2.1", "aa-receiptRequest"),
+ ENTRY2("1.2.840.113549.1.9.16.2.2", "aa-securityLabel"),
+ ENTRY2("1.2.840.113549.1.9.16.2.3", "aa-mlExpandHistory"),
+ ENTRY2("1.2.840.113549.1.9.16.2.4", "aa-contentHint"),
+ ENTRY2("1.2.840.113549.1.9.16.2.9", "aa-equivalentLabels"),
+ ENTRY2("1.2.840.113549.1.9.16.2.10", "aa-contentReference"),
+ ENTRY2("1.2.840.113549.1.9.16.2.11", "aa-encrypKeyPref"),
+ ENTRY2("1.2.840.113549.1.9.16.2.12", "aa-signingCertificate"),
+ ENTRY2("1.2.840.113549.1.9.16.2.19", "aa-ets-otherSigCert"),
+ ENTRY2("1.2.840.113549.1.9.16.2.47", "aa-signingCertificateV2"),
+
+ {NULL, 0, NULL, 0, NULL, 0}
+};
+
static void print_raw(gnutls_buffer_st * str, const char *prefix,
const gnutls_datum_t * raw)
{
@@ -94,6 +119,7 @@ static void print_pkcs7_info(gnutls_pkcs7_signature_info_st * info,
char s[42];
size_t max;
int ret;
+ const struct oid_to_string * entry;
if (info->issuer_dn.size > 0)
print_dn(str, "\tSigner's issuer DN", &info->issuer_dn);
@@ -130,7 +156,9 @@ static void print_pkcs7_info(gnutls_pkcs7_signature_info_st * info,
if (i == 0)
addf(str, "\tSigned Attributes:\n");
- snprintf(prefix, sizeof(prefix), "\t\t%s", oid);
+ entry = _gnutls_oid_get_entry(pkcs7_attrs, oid);
+ snprintf(prefix, sizeof(prefix), "\t\t%s",
+ (entry && entry->name_desc) ? entry->name_desc : oid);
print_raw(str, prefix, &data);
gnutls_free(data.data);
}
@@ -145,7 +173,9 @@ static void print_pkcs7_info(gnutls_pkcs7_signature_info_st * info,
if (i == 0)
addf(str, "\tUnsigned Attributes:\n");
- snprintf(prefix, sizeof(prefix), "\t\t%s", oid);
+ entry = _gnutls_oid_get_entry(pkcs7_attrs, oid);
+ snprintf(prefix, sizeof(prefix), "\t\t%s",
+ (entry && entry->name_desc) ? entry->name_desc : oid);
print_raw(str, prefix, &data);
gnutls_free(data.data);
}