linked_list_t *dhs;
/**
- * mutex to lock access to modules
+ * rwlock to lock access to modules
*/
- mutex_t *mutex;
+ rwlock_t *lock;
};
/**
entry_t *entry;
crypter_t *crypter = NULL;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
enumerator = this->crypters->create_enumerator(this->crypters);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return crypter;
}
entry_t *entry;
signer_t *signer = NULL;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
enumerator = this->signers->create_enumerator(this->signers);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return signer;
}
entry_t *entry;
hasher_t *hasher = NULL;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
enumerator = this->hashers->create_enumerator(this->hashers);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return hasher;
}
entry_t *entry;
prf_t *prf = NULL;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
enumerator = this->prfs->create_enumerator(this->prfs);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return prf;
}
u_int diff = ~0;
rng_constructor_t constr = NULL;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
enumerator = this->rngs->create_enumerator(this->rngs);
while (enumerator->enumerate(enumerator, &entry))
{ /* find the best matching quality, but at least as good as requested */
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
if (constr)
{
return constr(quality);
entry_t *entry;
diffie_hellman_t *diffie_hellman = NULL;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
enumerator = this->dhs->create_enumerator(this->dhs);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return diffie_hellman;
}
entry->algo = algo;
entry->create_crypter = create;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->crypters->insert_last(this->crypters, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry_t *entry;
enumerator_t *enumerator;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->crypters->create_enumerator(this->crypters);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry->algo = algo;
entry->create_signer = create;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->signers->insert_last(this->signers, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry_t *entry;
enumerator_t *enumerator;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->signers->create_enumerator(this->signers);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry->algo = algo;
entry->create_hasher = create;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->hashers->insert_last(this->hashers, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry_t *entry;
enumerator_t *enumerator;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->hashers->create_enumerator(this->hashers);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry->algo = algo;
entry->create_prf = create;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->prfs->insert_last(this->prfs, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry_t *entry;
enumerator_t *enumerator;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->prfs->create_enumerator(this->prfs);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry->algo = quality;
entry->create_rng = create;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->rngs->insert_last(this->rngs, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry_t *entry;
enumerator_t *enumerator;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->rngs->create_enumerator(this->rngs);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry->algo = group;
entry->create_dh = create;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->dhs->insert_last(this->dhs, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
entry_t *entry;
enumerator_t *enumerator;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->dhs->create_enumerator(this->dhs);
while (enumerator->enumerate(enumerator, &entry))
{
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
static enumerator_t *create_enumerator(private_crypto_factory_t *this,
linked_list_t *list, void *filter)
{
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
return enumerator_create_filter(
enumerator_create_filter(
list->create_enumerator(list), (void*)unique_check,
linked_list_create(), (void*)list->destroy),
- filter, this->mutex, (void*)this->mutex->unlock);
+ filter, this->lock, (void*)this->lock->unlock);
}
/**
this->prfs->destroy_function(this->prfs, free);
this->rngs->destroy_function(this->rngs, free);
this->dhs->destroy_function(this->dhs, free);
- this->mutex->destroy(this->mutex);
+ this->lock->destroy(this->lock);
free(this);
}
this->prfs = linked_list_create();
this->rngs = linked_list_create();
this->dhs = linked_list_create();
- this->mutex = mutex_create(MUTEX_RECURSIVE);
+ this->lock = rwlock_create(RWLOCK_DEFAULT);
return &this->public;
}