aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins/x509/x509_ocsp_response.c
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-09-09 16:24:06 +0200
committerMartin Willi <martin@strongswan.org>2009-09-10 16:20:21 +0200
commitd73f453c29cec10392fddfe08c899d2d5238d661 (patch)
treef9f16536ea93c2bd69944f786223e64d24ea00b3 /src/libstrongswan/plugins/x509/x509_ocsp_response.c
parent91ef5c66ab82e3694f18a3a91b8b199a180e171c (diff)
downloadstrongswan-d73f453c29cec10392fddfe08c899d2d5238d661.tar.bz2
strongswan-d73f453c29cec10392fddfe08c899d2d5238d661.tar.xz
Updated x509 plugin to the new builder API
Diffstat (limited to 'src/libstrongswan/plugins/x509/x509_ocsp_response.c')
-rw-r--r--src/libstrongswan/plugins/x509/x509_ocsp_response.c82
1 files changed, 18 insertions, 64 deletions
diff --git a/src/libstrongswan/plugins/x509/x509_ocsp_response.c b/src/libstrongswan/plugins/x509/x509_ocsp_response.c
index f3ee5c82c..2b60df323 100644
--- a/src/libstrongswan/plugins/x509/x509_ocsp_response.c
+++ b/src/libstrongswan/plugins/x509/x509_ocsp_response.c
@@ -1,5 +1,5 @@
/**
- * Copyright (C) 2008 Martin Willi
+ * Copyright (C) 2008-2009 Martin Willi
* Copyright (C) 2007 Andreas Steffen
* Hochschule fuer Technik Rapperswil
* Copyright (C) 2003 Christoph Gysin, Simon Zwahlen
@@ -853,7 +853,7 @@ static void destroy(private_x509_ocsp_response_t *this)
/**
* load an OCSP response
*/
-static x509_ocsp_response_t *load(chunk_t data)
+static x509_ocsp_response_t *load(chunk_t blob)
{
private_x509_ocsp_response_t *this;
@@ -876,7 +876,7 @@ static x509_ocsp_response_t *load(chunk_t data)
this->public.interface.create_cert_enumerator = (enumerator_t*(*)(ocsp_response_t*))create_cert_enumerator;
this->ref = 1;
- this->encoding = data;
+ this->encoding = chunk_clone(blob);
this->tbsResponseData = chunk_empty;
this->responderId = NULL;
this->producedAt = UNDEFINED_TIME;
@@ -895,78 +895,32 @@ static x509_ocsp_response_t *load(chunk_t data)
return &this->public;
}
-
-typedef struct private_builder_t private_builder_t;
-/**
- * Builder implementation for certificate loading
- */
-struct private_builder_t {
- /** implements the builder interface */
- builder_t public;
- /** loaded response */
- x509_ocsp_response_t *res;
-};
-
/**
- * Implementation of builder_t.build
+ * See header.
*/
-static x509_ocsp_response_t *build(private_builder_t *this)
+x509_ocsp_response_t *x509_ocsp_response_load(certificate_type_t type,
+ va_list args)
{
- x509_ocsp_response_t *res = this->res;
-
- free(this);
- return res;
-}
+ chunk_t blob = chunk_empty;
-/**
- * Implementation of builder_t.add
- */
-static void add(private_builder_t *this, builder_part_t part, ...)
-{
- if (!this->res)
+ while (TRUE)
{
- va_list args;
- chunk_t chunk;
-
- switch (part)
+ switch (va_arg(args, builder_part_t))
{
case BUILD_BLOB_ASN1_DER:
- {
- va_start(args, part);
- chunk = va_arg(args, chunk_t);
- this->res = load(chunk_clone(chunk));
- va_end(args);
- return;
- }
- default:
+ blob = va_arg(args, chunk_t);
+ continue;
+ case BUILD_END:
break;
+ default:
+ return NULL;
}
+ break;
}
- if (this->res)
+ if (blob.ptr)
{
- destroy((private_x509_ocsp_response_t*)this->res);
+ return load(blob);
}
- builder_cancel(&this->public);
-}
-
-/**
- * Builder construction function
- */
-builder_t *x509_ocsp_response_builder(certificate_type_t type)
-{
- private_builder_t *this;
-
- if (type != CERT_X509_OCSP_RESPONSE)
- {
- return NULL;
- }
-
- this = malloc_thing(private_builder_t);
-
- this->res = NULL;
- this->public.add = (void(*)(builder_t *this, builder_part_t part, ...))add;
- this->public.build = (void*(*)(builder_t *this))build;
-
- return &this->public;
+ return NULL;
}