diff options
Diffstat (limited to 'src/libstrongswan/plugins/x509/x509_crl.c')
-rw-r--r-- | src/libstrongswan/plugins/x509/x509_crl.c | 86 |
1 files changed, 23 insertions, 63 deletions
diff --git a/src/libstrongswan/plugins/x509/x509_crl.c b/src/libstrongswan/plugins/x509/x509_crl.c index cd1d3c6e6..643f809c7 100644 --- a/src/libstrongswan/plugins/x509/x509_crl.c +++ b/src/libstrongswan/plugins/x509/x509_crl.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Martin Willi + * Copyright (C) 2008-2009 Martin Willi * Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it @@ -593,78 +593,38 @@ static private_x509_crl_t* create_empty(void) return this; } -typedef struct private_builder_t private_builder_t; /** - * Builder implementation for certificate loading + * See header. */ -struct private_builder_t { - /** implements the builder interface */ - builder_t public; - /** CRL chunk to build from */ - chunk_t blob; -}; - -/** - * Implementation of builder_t.build - */ -static private_x509_crl_t *build(private_builder_t *this) +x509_crl_t *x509_crl_load(certificate_type_t type, va_list args) { - private_x509_crl_t *crl = NULL; + chunk_t blob = chunk_empty; - if (this->blob.len && this->blob.ptr) + while (TRUE) { - crl = create_empty(); - crl->encoding = chunk_clone(this->blob); - if (!parse(crl)) + switch (va_arg(args, builder_part_t)) { - destroy(crl); - crl = NULL; + case BUILD_BLOB_ASN1_DER: + blob = va_arg(args, chunk_t); + continue; + case BUILD_END: + break; + default: + return NULL; } + break; } - free(this); - return crl; -} - -/** - * Implementation of builder_t.add - */ -static void add(private_builder_t *this, builder_part_t part, ...) -{ - va_list args; - - switch (part) + if (blob.ptr) { - case BUILD_BLOB_ASN1_DER: + private_x509_crl_t *crl = create_empty(); + + crl->encoding = chunk_clone(blob); + if (parse(crl)) { - va_start(args, part); - this->blob = va_arg(args, chunk_t); - va_end(args); - return; + return &crl->public; } - default: - break; + destroy(crl); } - builder_cancel(&this->public); -} - -/** - * Builder construction function - */ -builder_t *x509_crl_builder(certificate_type_t type) -{ - private_builder_t *this; - - if (type != CERT_X509_CRL) - { - return NULL; - } - this = malloc_thing(private_builder_t); - - this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add; - this->public.build = (void*(*)(builder_t *this))build; - - this->blob = chunk_empty; - - return &this->public; -} + return NULL; +}; |