diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-07 15:19:16 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-11 13:59:41 +0200 |
commit | 206414e55543e34ece06337132767f1887f569d7 (patch) | |
tree | f6b1eea7e743682d4bf1bd23612f542a9691631c | |
parent | 8d4b93d7beae6831f950f3f89c8688f01cd04f34 (diff) | |
download | gnutls-206414e55543e34ece06337132767f1887f569d7.tar.gz |
pkcs7: print the eContent type in output functions if it does not match the defaults
-rw-r--r-- | lib/x509/pkcs7-output.c | 12 | ||||
-rw-r--r-- | lib/x509/pkcs7.c | 9 | ||||
-rw-r--r-- | lib/x509/pkcs7_int.h | 3 |
3 files changed, 18 insertions, 6 deletions
diff --git a/lib/x509/pkcs7-output.c b/lib/x509/pkcs7-output.c index 79fc5e0113..b3da94d905 100644 --- a/lib/x509/pkcs7-output.c +++ b/lib/x509/pkcs7-output.c @@ -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"); diff --git a/lib/x509/pkcs7.c b/lib/x509/pkcs7.c index 0d57afa4e7..0ff6efdc4a 100644 --- a/lib/x509/pkcs7.c +++ b/lib/x509/pkcs7.c @@ -32,13 +32,10 @@ #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); diff --git a/lib/x509/pkcs7_int.h b/lib/x509/pkcs7_int.h index 57e72b96e5..b0f7e456e1 100644 --- a/lib/x509/pkcs7_int.h +++ b/lib/x509/pkcs7_int.h @@ -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 */ |