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
This commit is contained in:
Andreas Steffen
2022-07-29 07:59:00 +02:00
parent 49ddfe91f0
commit bcedd65a31
@@ -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);