]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
pkcs7: print the eContent type in output functions if it does not match the defaults
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 7 Oct 2016 13:19:16 +0000 (15:19 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 11 Oct 2016 11:59:41 +0000 (13:59 +0200)
lib/x509/pkcs7-output.c
lib/x509/pkcs7.c
lib/x509/pkcs7_int.h

index 79fc5e01137f7bec92313c39216fa9b21247426e..b3da94d905ebe2d010a3e19b23f56ddddb5be016 100644 (file)
@@ -27,6 +27,7 @@
 #include <num.h>
 #include "errors.h"
 #include <extras/randomart.h>
+#include <pkcs7_int.h>
 #include <gnutls-idna.h>
 
 #define addf _gnutls_buffer_append_printf
@@ -177,9 +178,20 @@ int gnutls_pkcs7_print(gnutls_pkcs7_t pkcs7,
        int count, ret, i;
        gnutls_pkcs7_signature_info_st info;
        gnutls_buffer_st str;
+       const char *oid;
 
        _gnutls_buffer_init(&str);
 
+       /* For backwards compatibility with structures using the default OID,
+        * we don't print the eContent Type explicitly */
+       oid = gnutls_pkcs7_get_embedded_data_oid(pkcs7);
+       if (oid) {
+               if (strcmp(oid, DATA_OID) != 0
+                   && strcmp(oid, DIGESTED_DATA_OID) != 0) {
+                       addf(&str, "eContent Type: %s\n", oid);
+               }
+       }
+
        for (i = 0;; i++) {
                if (i == 0)
                        addf(&str, "Signers:\n");
index 0d57afa4e7b672d69236ad1c157ae7276b888bfb..0ff6efdc4a6581130b38683c098322a9eb642da2 100644 (file)
 #include "errors.h"
 #include <common.h>
 #include <x509_b64.h>
+#include <pkcs7_int.h>
 #include <gnutls/abstract.h>
 #include <gnutls/pkcs7.h>
 
-#define SIGNED_DATA_OID "1.2.840.113549.1.7.2"
-#define PLAIN_DATA_OID "1.2.840.113549.1.7.1"
-#define DIGESTED_DATA_OID "1.2.840.113549.1.7.5"
-
 #define ATTR_MESSAGE_DIGEST "1.2.840.113549.1.9.4"
 #define ATTR_SIGNING_TIME "1.2.840.113549.1.9.5"
 #define ATTR_CONTENT_TYPE "1.2.840.113549.1.9.3"
@@ -104,7 +101,7 @@ static int _decode_pkcs7_signed_data(gnutls_pkcs7_t pkcs7)
                goto cleanup;
        }
 
-       if (strcmp(pkcs7->encap_data_oid, PLAIN_DATA_OID) != 0
+       if (strcmp(pkcs7->encap_data_oid, DATA_OID) != 0
            && strcmp(pkcs7->encap_data_oid, DIGESTED_DATA_OID) != 0) {
                _gnutls_debug_log
                    ("Unknown PKCS#7 Encapsulated Content OID '%s'; treating as raw data\n",
@@ -2155,7 +2152,7 @@ int gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7,
 
        result =
            asn1_write_value(pkcs7->signed_data,
-                            "encapContentInfo.eContentType", PLAIN_DATA_OID,
+                            "encapContentInfo.eContentType", DATA_OID,
                             0);
        if (result != ASN1_SUCCESS) {
                ret = _gnutls_asn2err(result);
index 57e72b96e5f521ca8d0378c6ec704b3ec459f6a8..b0f7e456e1aa6b88f17cf29d3848767ab6e44324 100644 (file)
@@ -31,6 +31,9 @@
 #define DATA_OID "1.2.840.113549.1.7.1"
 #define ENC_DATA_OID "1.2.840.113549.1.7.6"
 
+#define SIGNED_DATA_OID "1.2.840.113549.1.7.2"
+#define DIGESTED_DATA_OID "1.2.840.113549.1.7.5"
+
 
 typedef enum schema_id {
        PBES2_GENERIC=1,        /* when the algorithm is unknown, temporal use when reading only */