From bcedd65a31667a25427ad6f12ccdbf88d01af3a6 Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Thu, 28 Jul 2022 11:18:54 +0200 Subject: [PATCH] pkcs7: Allow for missing optional content field The content field of type OCTET STRING of a ContentInfo object with ContentType Data ContentInfo ::= SEQUENCE { contentType ContentType, content [0] EXPLICIT OCTET STRING OPTIONAL is optional and can be missing if no data is available --- src/libstrongswan/plugins/pkcs7/pkcs7_data.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libstrongswan/plugins/pkcs7/pkcs7_data.c b/src/libstrongswan/plugins/pkcs7/pkcs7_data.c index 235b9fe30..98af13805 100644 --- a/src/libstrongswan/plugins/pkcs7/pkcs7_data.c +++ b/src/libstrongswan/plugins/pkcs7/pkcs7_data.c @@ -60,6 +60,13 @@ METHOD(container_t, get_data, bool, chunk_t chunk; chunk = this->content; + + /* The content field is optional */ + if (chunk.len == 0) + { + *data = chunk_empty; + return TRUE; + } if (asn1_unwrap(&chunk, &chunk) == ASN1_OCTET_STRING) { *data = chunk_clone(chunk);