0x2B, 0x0E, 0x03, 0x02, 0x07
);
-/**
- * Implements pkcs7_t.is_data.
- */
-static bool is_data(private_pkcs7_t *this)
+METHOD(pkcs7_t, is_data, bool,
+ private_pkcs7_t *this)
{
return this->type == OID_PKCS7_DATA;
}
-/**
- * Implements pkcs7_t.is_signedData.
- */
-static bool is_signedData(private_pkcs7_t *this)
+METHOD(pkcs7_t, is_signedData, bool,
+ private_pkcs7_t *this)
{
return this->type == OID_PKCS7_SIGNED_DATA;
}
-/**
- * Implements pkcs7_t.is_envelopedData.
- */
-static bool is_envelopedData(private_pkcs7_t *this)
+METHOD(pkcs7_t, is_envelopedData, bool,
+ private_pkcs7_t *this)
{
return this->type == OID_PKCS7_ENVELOPED_DATA;
}
return FALSE;
}
-/**
- * Implements pkcs7_t.parse_data.
- */
-static bool parse_data(private_pkcs7_t *this)
+METHOD(pkcs7_t, parse_data, bool,
+ private_pkcs7_t *this)
{
chunk_t data = this->content;
#define PKCS7_DIGEST_ENC_ALGORITHM 21
#define PKCS7_ENCRYPTED_DIGEST 22
-/**
- * Implements pkcs7_t.parse_signedData.
- */
-static bool parse_signedData(private_pkcs7_t *this, x509_t *cacert)
+METHOD(pkcs7_t, parse_signedData, bool,
+ private_pkcs7_t *this, x509_t *cacert)
{
asn1_parser_t *parser;
chunk_t object;
#define PKCS7_CONTENT_ENC_ALGORITHM 13
#define PKCS7_ENCRYPTED_CONTENT 14
-/**
- * Parse PKCS#7 envelopedData content
- */
-static bool parse_envelopedData(private_pkcs7_t *this, chunk_t serialNumber,
- rsa_private_key_t *key)
+METHOD(parse_envelopedData, bool,
+ private_pkcs7_t *this, chunk_t serialNumber, rsa_private_key_t *key)
{
asn1_parser_t *parser;
chunk_t object;
return FALSE;
}
-/**
- * Implements pkcs7_t.get_data.
- */
-static chunk_t get_data(private_pkcs7_t *this)
+METHOD(pkcs7_t, get_data, chunk_t,
+ private_pkcs7_t *this)
{
return this->data;
}
-/**
- * Implements pkcs7_t.get_contentInfo.
- */
-static chunk_t get_contentInfo(private_pkcs7_t *this)
+METHOD(pkcs7_t, get_contentInfo, chunk_t,
+ private_pkcs7_t *this)
{
chunk_t content_type;
);
}
-/**
- * Implements pkcs7_t.create_certificate_enumerator
- */
-static enumerator_t *create_certificate_enumerator(const private_pkcs7_t *this)
+METHOD(pkcs7_t, create_certificate_enumerator, enumerator_t*,
+ private_pkcs7_t *this)
{
return this->certs->create_enumerator(this->certs);
}
-/**
- * Implements pkcs7_t.set_certificate
- */
-static void set_certificate(private_pkcs7_t *this, x509_t *cert)
+METHOD(pkcs7_t, set_certificate, void,
+ private_pkcs7_t *this, x509_t *cert)
{
if (cert)
{
}
}
-/**
- * Implements pkcs7_t.set_attributes
- */
-static void set_attributes(private_pkcs7_t *this, pkcs9_t *attributes)
+METHOD(pkcs7_t, set_attributes, void,
+ private_pkcs7_t *this, pkcs9_t *attributes)
{
this->attributes = attributes;
}
asn1_simple_object(ASN1_INTEGER, cert->get_serialNumber(cert)));
}
-/**
- * Implements pkcs7_t.build_envelopedData.
- */
-bool build_envelopedData(private_pkcs7_t *this, x509_t *cert,
- encryption_algorithm_t alg)
+METHOD(pkcs7_t, build_envelopedData, bool,
+ private_pkcs7_t *this, x509_t *cert, encryption_algorithm_t alg)
{
chunk_t iv, symmetricKey, in, out, alg_oid;
crypter_t *crypter;
return TRUE;
}
-/**
- * Implements pkcs7_t.build_signedData.
- */
-bool build_signedData(private_pkcs7_t *this, rsa_private_key_t *private_key,
- hash_algorithm_t alg)
+METHOD(pkcs7_t, build_signedData, bool,
+ private_pkcs7_t *this, rsa_private_key_t *private_key, hash_algorithm_t alg)
{
int signature_oid = hasher_signature_algorithm_to_oid(alg,
private_key->get_type(private_key));
return TRUE;
}
-/**
- * Implements pkcs7_t.destroy
- */
-static void destroy(private_pkcs7_t *this)
+METHOD(pkcs7_t, destroy, void,
+ private_pkcs7_t *this)
{
DESTROY_IF(this->attributes);
this->certs->destroy_offset(this->certs, offsetof(x509_t, destroy));
*/
static private_pkcs7_t *pkcs7_create_empty(void)
{
- private_pkcs7_t *this = malloc_thing(private_pkcs7_t);
-
- /* initialize */
- this->type = OID_UNKNOWN;
- this->content = chunk_empty;
- this->parsed = FALSE;
- this->level = 0;
- this->data = chunk_empty;
- this->attributes = NULL;
- this->certs = linked_list_create();
-
- /*public functions */
- this->public.is_data = (bool (*) (pkcs7_t*))is_data;
- this->public.is_signedData = (bool (*) (pkcs7_t*))is_signedData;
- this->public.is_envelopedData = (bool (*) (pkcs7_t*))is_envelopedData;
- this->public.parse_data = (bool (*) (pkcs7_t*))parse_data;
- this->public.parse_signedData = (bool (*) (pkcs7_t*,x509_t*))parse_signedData;
- this->public.parse_envelopedData = (bool (*) (pkcs7_t*,chunk_t,rsa_private_key_t*))parse_envelopedData;
- this->public.get_data = (chunk_t (*) (pkcs7_t*))get_data;
- this->public.get_contentInfo = (chunk_t (*) (pkcs7_t*))get_contentInfo;
- this->public.create_certificate_enumerator = (enumerator_t* (*) (pkcs7_t*))create_certificate_enumerator;
- this->public.set_certificate = (void (*) (pkcs7_t*,x509_t*))set_certificate;
- this->public.set_attributes = (void (*) (pkcs7_t*,pkcs9_t*))set_attributes;
- this->public.build_envelopedData = (bool (*) (pkcs7_t*,x509_t*,encryption_algorithm_t))build_envelopedData;
- this->public.build_signedData = (bool (*) (pkcs7_t*,rsa_private_key_t*,hash_algorithm_t))build_signedData;
- this->public.destroy = (void (*) (pkcs7_t*))destroy;
+ private_pkcs7_t *this;
+
+ INIT(this,
+ .public = {
+ .is_data = _is_data,
+ .is_signedData = _is_signedData,
+ .is_envelopedData = _is_envelopedData,
+ .parse_data = _parse_data,
+ .parse_signedData = _parse_signedData,
+ .parse_envelopedData = _parse_envelopedData,
+ .get_data = _get_data,
+ .get_contentInfo = _get_contentInfo,
+ .create_certificate_enumerator = _create_certificate_enumerator,
+ .set_certificate = _set_certificate,
+ .set_attributes = _set_attributes,
+ .build_envelopedData = _build_envelopedData,
+ .build_signedData = _build_signedData,
+ .destroy = _destroy,
+ },
+ .type = OID_UNKNOWN,
+ .certs = linked_list_create(),
+ );
return this;
}