Add a getter for signed PKCS#7 attributes
This commit is contained in:
@@ -98,6 +98,7 @@ static private_pkcs7_data_t* create_empty()
|
||||
.get_encoding = _get_encoding,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_attribute = (void*)return_false,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -380,6 +380,7 @@ static private_pkcs7_enveloped_data_t* create_empty()
|
||||
.get_encoding = _get_encoding,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_attribute = (void*)return_false,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -172,6 +172,8 @@ typedef struct {
|
||||
enumerator_t *inner;
|
||||
/** currently enumerated auth_cfg */
|
||||
auth_cfg_t *auth;
|
||||
/** currently enumerating signerinfo */
|
||||
signerinfo_t *info;
|
||||
/** reference to container */
|
||||
private_pkcs7_signed_data_t *this;
|
||||
} signature_enumerator_t;
|
||||
@@ -275,8 +277,10 @@ METHOD(enumerator_t, enumerate, bool,
|
||||
continue;
|
||||
}
|
||||
*out = this->auth;
|
||||
this->info = info;
|
||||
return TRUE;
|
||||
}
|
||||
this->info = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -307,6 +311,25 @@ METHOD(container_t, create_signature_enumerator, enumerator_t*,
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
METHOD(pkcs7_t, get_attribute, bool,
|
||||
private_pkcs7_signed_data_t *this, int oid, enumerator_t *enumerator, chunk_t *value)
|
||||
{
|
||||
signature_enumerator_t *e;
|
||||
chunk_t chunk;
|
||||
|
||||
e = (signature_enumerator_t*)enumerator;
|
||||
if (e->info)
|
||||
{
|
||||
chunk = e->info->attributes->get_attribute(e->info->attributes, oid);
|
||||
if (chunk.len)
|
||||
{
|
||||
*value = chunk;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(container_t, get_data, bool,
|
||||
private_pkcs7_signed_data_t *this, chunk_t *data)
|
||||
{
|
||||
@@ -351,6 +374,7 @@ static private_pkcs7_signed_data_t* create_empty()
|
||||
.get_encoding = _get_encoding,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.get_attribute = _get_attribute,
|
||||
},
|
||||
.creds = mem_cred_create(),
|
||||
.signerinfos = linked_list_create(),
|
||||
|
||||
Reference in New Issue
Block a user