From a6f902baed7abb17a1a9c014e01bb100077f8198 Mon Sep 17 00:00:00 2001
From: Rene Mayrhofer <rene@mayrhofer.eu.org>
Date: Sun, 1 Mar 2009 10:48:08 +0000
Subject: - Updated to new upstream revision.

---
 src/libstrongswan/credentials/builder.c            |  2 ++
 src/libstrongswan/credentials/builder.h            |  4 ++++
 src/libstrongswan/credentials/credential_factory.c | 24 ++++++++++++----------
 3 files changed, 19 insertions(+), 11 deletions(-)

(limited to 'src/libstrongswan/credentials')

diff --git a/src/libstrongswan/credentials/builder.c b/src/libstrongswan/credentials/builder.c
index 4295b3094..0bca198f1 100644
--- a/src/libstrongswan/credentials/builder.c
+++ b/src/libstrongswan/credentials/builder.c
@@ -35,6 +35,8 @@ ENUM(builder_part_names, BUILD_FROM_FILE, BUILD_END,
 	"BUILD_CA_CERT",
 	"BUILD_CERT",
 	"BUILD_X509_FLAG",
+	"BUILD_SMARTCARD_KEYID",
+	"BUILD_SMARTCARD_PIN",
 	"BUILD_END",
 );
 
diff --git a/src/libstrongswan/credentials/builder.h b/src/libstrongswan/credentials/builder.h
index cd75236ba..332d52d52 100644
--- a/src/libstrongswan/credentials/builder.h
+++ b/src/libstrongswan/credentials/builder.h
@@ -76,6 +76,10 @@ enum builder_part_t {
 	BUILD_CERT,
 	/** enforce an additional X509 flag, x509_flag_t */
 	BUILD_X509_FLAG,
+	/** key ID of a key on a smartcard, null terminated char* ([slot:]keyid) */
+	BUILD_SMARTCARD_KEYID,
+	/** pin to access a key on a smartcard, null terminated char* */
+	BUILD_SMARTCARD_PIN,
 	/** end of variable argument builder list */
 	BUILD_END,
 };
diff --git a/src/libstrongswan/credentials/credential_factory.c b/src/libstrongswan/credentials/credential_factory.c
index 203317fa4..5ae6980be 100644
--- a/src/libstrongswan/credentials/credential_factory.c
+++ b/src/libstrongswan/credentials/credential_factory.c
@@ -12,7 +12,7 @@
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
  *
- * $Id: credential_factory.c 4317 2008-09-02 11:00:13Z martin $
+ * $Id: credential_factory.c 4777 2008-12-09 15:57:51Z martin $
  */
 
 #include "credential_factory.h"
@@ -46,9 +46,9 @@ struct private_credential_factory_t {
 	linked_list_t *constructors;
 	
 	/**
-	 * mutex to lock access to modules
+	 * lock access to builders
 	 */
-	mutex_t *mutex;
+	rwlock_t *lock;
 };
 
 typedef struct entry_t entry_t;
@@ -86,12 +86,12 @@ static enumerator_t* create_builder_enumerator(
 	data->type = type;
 	data->subtype = subtype;
 	
-	this->mutex->lock(this->mutex);
+	this->lock->read_lock(this->lock);
 	return enumerator_create_cleaner(
 				enumerator_create_filter(
 					this->constructors->create_enumerator(this->constructors),
 					(void*)builder_filter, data, free), 
-				(void*)this->mutex->unlock, this->mutex);
+				(void*)this->lock->unlock, this->lock);
 }
 
 /**
@@ -106,9 +106,9 @@ static void add_builder(private_credential_factory_t *this,
 	entry->type = type;
 	entry->subtype = subtype;
 	entry->constructor = constructor;
-	this->mutex->lock(this->mutex);
+	this->lock->write_lock(this->lock);
 	this->constructors->insert_last(this->constructors, entry);
-	this->mutex->unlock(this->mutex);
+	this->lock->unlock(this->lock);
 }
 
 /**
@@ -120,7 +120,7 @@ static void remove_builder(private_credential_factory_t *this,
 	enumerator_t *enumerator;
 	entry_t *entry;
 	
-	this->mutex->lock(this->mutex);
+	this->lock->write_lock(this->lock);
 	enumerator = this->constructors->create_enumerator(this->constructors);
 	while (enumerator->enumerate(enumerator, &entry))
 	{
@@ -131,7 +131,7 @@ static void remove_builder(private_credential_factory_t *this,
 		}
 	}
 	enumerator->destroy(enumerator);
-	this->mutex->unlock(this->mutex);
+	this->lock->unlock(this->lock);
 }
 
 /**
@@ -184,6 +184,8 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
 				case BUILD_CA_CERT:
 				case BUILD_CERT:
 				case BUILD_IETF_GROUP_ATTR:
+				case BUILD_SMARTCARD_KEYID:
+				case BUILD_SMARTCARD_PIN:
 					builder->add(builder, part, va_arg(args, void*));
 					continue;
 				/* no default to get a compiler warning */
@@ -213,7 +215,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
 static void destroy(private_credential_factory_t *this)
 {
 	this->constructors->destroy_function(this->constructors, free);
-	this->mutex->destroy(this->mutex);
+	this->lock->destroy(this->lock);
 	free(this);
 }
 
@@ -232,7 +234,7 @@ credential_factory_t *credential_factory_create()
 	
 	this->constructors = linked_list_create();
 	
-	this->mutex = mutex_create(MUTEX_RECURSIVE);
+	this->lock = rwlock_create(RWLOCK_DEFAULT);
 	
 	return &this->public;
 }
-- 
cgit v1.2.3