Migrated x509_pkcs10 to INIT/METHOD macros

This commit is contained in:
Andreas Steffen
2011-09-29 16:47:36 +02:00
parent 3a4c3fdb93
commit 658ed38d74
+51 -77
View File
@@ -104,34 +104,26 @@ struct private_x509_pkcs10_t {
extern void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_list_t *list); extern void x509_parse_generalNames(chunk_t blob, int level0, bool implicit, linked_list_t *list);
extern chunk_t x509_build_subjectAltNames(linked_list_t *list); extern chunk_t x509_build_subjectAltNames(linked_list_t *list);
/** METHOD(certificate_t, get_type, certificate_type_t,
* Implementation of certificate_t.get_type. private_x509_pkcs10_t *this)
*/
static certificate_type_t get_type(private_x509_pkcs10_t *this)
{ {
return CERT_PKCS10_REQUEST; return CERT_PKCS10_REQUEST;
} }
/** METHOD(certificate_t, get_subject, identification_t*,
* Implementation of certificate_t.get_subject and get_issuer. private_x509_pkcs10_t *this)
*/
static identification_t* get_subject(private_x509_pkcs10_t *this)
{ {
return this->subject; return this->subject;
} }
/** METHOD(certificate_t, has_subject, id_match_t,
* Implementation of certificate_t.has_subject and has_issuer. private_x509_pkcs10_t *this, identification_t *subject)
*/
static id_match_t has_subject(private_x509_pkcs10_t *this, identification_t *subject)
{ {
return this->subject->matches(this->subject, subject); return this->subject->matches(this->subject, subject);
} }
/** METHOD(certificate_t, issued_by, bool,
* Implementation of certificate_t.issued_by. private_x509_pkcs10_t *this, certificate_t *issuer)
*/
static bool issued_by(private_x509_pkcs10_t *this, certificate_t *issuer)
{ {
public_key_t *key; public_key_t *key;
signature_scheme_t scheme; signature_scheme_t scheme;
@@ -162,20 +154,16 @@ static bool issued_by(private_x509_pkcs10_t *this, certificate_t *issuer)
this->signature); this->signature);
} }
/** METHOD(certificate_t, get_public_key, public_key_t*,
* Implementation of certificate_t.get_public_key. private_x509_pkcs10_t *this)
*/
static public_key_t* get_public_key(private_x509_pkcs10_t *this)
{ {
this->public_key->get_ref(this->public_key); this->public_key->get_ref(this->public_key);
return this->public_key; return this->public_key;
} }
/** METHOD(certificate_t, get_validity, bool,
* Implementation of certificate_t.get_validity. private_x509_pkcs10_t *this, time_t *when, time_t *not_before,
*/ time_t *not_after)
static bool get_validity(private_x509_pkcs10_t *this, time_t *when,
time_t *not_before, time_t *not_after)
{ {
if (not_before) if (not_before)
{ {
@@ -188,11 +176,8 @@ static bool get_validity(private_x509_pkcs10_t *this, time_t *when,
return TRUE; return TRUE;
} }
/** METHOD(certificate_t, get_encoding, bool,
* Implementation of certificate_t.get_encoding. private_x509_pkcs10_t *this, cred_encoding_type_t type, chunk_t *encoding)
*/
static bool get_encoding(private_x509_pkcs10_t *this, cred_encoding_type_t type,
chunk_t *encoding)
{ {
if (type == CERT_ASN1_DER) if (type == CERT_ASN1_DER)
{ {
@@ -203,10 +188,8 @@ static bool get_encoding(private_x509_pkcs10_t *this, cred_encoding_type_t type,
CRED_PART_PKCS10_ASN1_DER, this->encoding, CRED_PART_END); CRED_PART_PKCS10_ASN1_DER, this->encoding, CRED_PART_END);
} }
/** METHOD(certificate_t, equals, bool,
* Implementation of certificate_t.equals. private_x509_pkcs10_t *this, certificate_t *other)
*/
static bool equals(private_x509_pkcs10_t *this, certificate_t *other)
{ {
chunk_t encoding; chunk_t encoding;
bool equal; bool equal;
@@ -232,27 +215,21 @@ static bool equals(private_x509_pkcs10_t *this, certificate_t *other)
return equal; return equal;
} }
/** METHOD(certificate_t, get_ref, certificate_t*,
* Implementation of certificate_t.get_ref private_x509_pkcs10_t *this)
*/
static private_x509_pkcs10_t* get_ref(private_x509_pkcs10_t *this)
{ {
ref_get(&this->ref); ref_get(&this->ref);
return this; return &this->public.interface.interface;
} }
/** METHOD(pkcs10_t, get_challengePassword, chunk_t,
* Implementation of certificate_t.get_challengePassword. private_x509_pkcs10_t *this)
*/
static chunk_t get_challengePassword(private_x509_pkcs10_t *this)
{ {
return this->challengePassword; return this->challengePassword;
} }
/** METHOD(pkcs10_t, create_subjectAltName_enumerator, enumerator_t*,
* Implementation of pkcs10_t.create_subjectAltName_enumerator. private_x509_pkcs10_t *this)
*/
static enumerator_t* create_subjectAltName_enumerator(private_x509_pkcs10_t *this)
{ {
return this->subjectAltNames->create_enumerator(this->subjectAltNames); return this->subjectAltNames->create_enumerator(this->subjectAltNames);
} }
@@ -477,10 +454,8 @@ end:
return success; return success;
} }
/** METHOD(certificate_t, destroy, void,
* Implementation of certificate_t.destroy private_x509_pkcs10_t *this)
*/
static void destroy(private_x509_pkcs10_t *this)
{ {
if (ref_put(&this->ref)) if (ref_put(&this->ref))
{ {
@@ -504,33 +479,32 @@ static void destroy(private_x509_pkcs10_t *this)
*/ */
static private_x509_pkcs10_t* create_empty(void) static private_x509_pkcs10_t* create_empty(void)
{ {
private_x509_pkcs10_t *this = malloc_thing(private_x509_pkcs10_t); private_x509_pkcs10_t *this;
this->public.interface.interface.get_type = (certificate_type_t (*) (certificate_t*))get_type; INIT(this,
this->public.interface.interface.get_subject = (identification_t* (*) (certificate_t*))get_subject; .public = {
this->public.interface.interface.get_issuer = (identification_t* (*) (certificate_t*))get_subject; .interface = {
this->public.interface.interface.has_subject = (id_match_t (*) (certificate_t*, identification_t*))has_subject; .interface = {
this->public.interface.interface.has_issuer = (id_match_t (*) (certificate_t*, identification_t*))has_subject; .get_type = _get_type,
this->public.interface.interface.issued_by = (bool (*) (certificate_t*, certificate_t*))issued_by; .get_subject = _get_subject,
this->public.interface.interface.get_public_key = (public_key_t* (*) (certificate_t*))get_public_key; .get_issuer = _get_subject,
this->public.interface.interface.get_validity = (bool (*) (certificate_t*, time_t*, time_t*, time_t*))get_validity; .has_subject = _has_subject,
this->public.interface.interface.get_encoding = (bool (*) (certificate_t*,cred_encoding_type_t,chunk_t*))get_encoding; .has_issuer = _has_subject,
this->public.interface.interface.equals = (bool (*)(certificate_t*, certificate_t*))equals; .issued_by = _issued_by,
this->public.interface.interface.get_ref = (certificate_t* (*)(certificate_t*))get_ref; .get_public_key = _get_public_key,
this->public.interface.interface.destroy = (void (*)(certificate_t*))destroy; .get_validity = _get_validity,
this->public.interface.get_challengePassword = (chunk_t (*)(pkcs10_t*))get_challengePassword; .get_encoding = _get_encoding,
this->public.interface.create_subjectAltName_enumerator = (enumerator_t* (*)(pkcs10_t*))create_subjectAltName_enumerator; .equals = _equals,
.get_ref = _get_ref,
this->encoding = chunk_empty; .destroy = _destroy,
this->certificationRequestInfo = chunk_empty; },
this->subject = NULL; .get_challengePassword = _get_challengePassword,
this->public_key = NULL; .create_subjectAltName_enumerator = _create_subjectAltName_enumerator,
this->subjectAltNames = linked_list_create(); },
this->challengePassword = chunk_empty; },
this->signature = chunk_empty; .subjectAltNames = linked_list_create(),
this->ref = 1; .ref = 1,
this->self_signed = FALSE; );
this->parsed = FALSE;
return this; return this;
} }