summaryrefslogtreecommitdiff
path: root/src/libstrongswan/crypto
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2008-12-05 16:15:54 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2008-12-05 16:15:54 +0000
commitc7f1b0530b85bc7654e68992f25ed8ced5d0a80d (patch)
tree861798cd7da646014ed6919766b053099646710d /src/libstrongswan/crypto
parent8b80ab5a6950ce6515f477624794defd7531642a (diff)
downloadvyos-strongswan-c7f1b0530b85bc7654e68992f25ed8ced5d0a80d.tar.gz
vyos-strongswan-c7f1b0530b85bc7654e68992f25ed8ced5d0a80d.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.2.9)
Diffstat (limited to 'src/libstrongswan/crypto')
-rw-r--r--src/libstrongswan/crypto/crypters/crypter.h2
-rw-r--r--src/libstrongswan/crypto/crypto_factory.c86
-rw-r--r--src/libstrongswan/crypto/diffie_hellman.h12
-rw-r--r--src/libstrongswan/crypto/prf_plus.c15
4 files changed, 56 insertions, 59 deletions
diff --git a/src/libstrongswan/crypto/crypters/crypter.h b/src/libstrongswan/crypto/crypters/crypter.h
index aade888fa..fb06af97d 100644
--- a/src/libstrongswan/crypto/crypters/crypter.h
+++ b/src/libstrongswan/crypto/crypters/crypter.h
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: crypter.h 3971 2008-05-16 13:27:21Z tobias $
+ * $Id: crypter.h 4532 2008-10-30 13:21:21Z martin $
*/
/**
diff --git a/src/libstrongswan/crypto/crypto_factory.c b/src/libstrongswan/crypto/crypto_factory.c
index 9836ed468..dcc881f1d 100644
--- a/src/libstrongswan/crypto/crypto_factory.c
+++ b/src/libstrongswan/crypto/crypto_factory.c
@@ -12,7 +12,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: crypto_factory.c 4307 2008-08-28 09:24:42Z martin $
+ * $Id: crypto_factory.c 4592 2008-11-05 16:21:57Z martin $
*/
#include "crypto_factory.h"
@@ -78,9 +78,9 @@ struct private_crypto_factory_t {
linked_list_t *dhs;
/**
- * mutex to lock access to modules
+ * rwlock to lock access to modules
*/
- mutex_t *mutex;
+ rwlock_t *lock;
};
/**
@@ -93,7 +93,7 @@ static crypter_t* create_crypter(private_crypto_factory_t *this,
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))
{
@@ -107,7 +107,7 @@ static crypter_t* create_crypter(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return crypter;
}
@@ -121,7 +121,7 @@ static signer_t* create_signer(private_crypto_factory_t *this,
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))
{
@@ -135,7 +135,7 @@ static signer_t* create_signer(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return signer;
}
@@ -150,7 +150,7 @@ static hasher_t* create_hasher(private_crypto_factory_t *this,
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))
{
@@ -164,7 +164,7 @@ static hasher_t* create_hasher(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return hasher;
}
@@ -178,7 +178,7 @@ static prf_t* create_prf(private_crypto_factory_t *this,
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))
{
@@ -192,7 +192,7 @@ static prf_t* create_prf(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return prf;
}
@@ -206,7 +206,7 @@ static rng_t* create_rng(private_crypto_factory_t *this, rng_quality_t quality)
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 */
@@ -221,7 +221,7 @@ static rng_t* create_rng(private_crypto_factory_t *this, rng_quality_t quality)
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
if (constr)
{
return constr(quality);
@@ -239,7 +239,7 @@ static diffie_hellman_t* create_dh(private_crypto_factory_t *this,
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))
{
@@ -253,7 +253,7 @@ static diffie_hellman_t* create_dh(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
return diffie_hellman;
}
@@ -268,9 +268,9 @@ static void add_crypter(private_crypto_factory_t *this,
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);
}
/**
@@ -282,7 +282,7 @@ static void remove_crypter(private_crypto_factory_t *this,
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))
{
@@ -293,7 +293,7 @@ static void remove_crypter(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -306,9 +306,9 @@ static void add_signer(private_crypto_factory_t *this,
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);
}
/**
@@ -320,7 +320,7 @@ static void remove_signer(private_crypto_factory_t *this,
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))
{
@@ -331,7 +331,7 @@ static void remove_signer(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -344,9 +344,9 @@ static void add_hasher(private_crypto_factory_t *this, hash_algorithm_t algo,
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);
}
/**
@@ -358,7 +358,7 @@ static void remove_hasher(private_crypto_factory_t *this,
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))
{
@@ -369,7 +369,7 @@ static void remove_hasher(private_crypto_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -382,9 +382,9 @@ static void add_prf(private_crypto_factory_t *this,
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);
}
/**
@@ -395,7 +395,7 @@ static void remove_prf(private_crypto_factory_t *this, prf_constructor_t create)
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))
{
@@ -406,7 +406,7 @@ static void remove_prf(private_crypto_factory_t *this, prf_constructor_t create)
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -419,9 +419,9 @@ static void add_rng(private_crypto_factory_t *this, rng_quality_t quality,
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);
}
/**
@@ -432,7 +432,7 @@ static void remove_rng(private_crypto_factory_t *this, rng_constructor_t create)
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))
{
@@ -443,7 +443,7 @@ static void remove_rng(private_crypto_factory_t *this, rng_constructor_t create)
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -456,9 +456,9 @@ static void add_dh(private_crypto_factory_t *this, diffie_hellman_group_t group,
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);
}
/**
@@ -469,7 +469,7 @@ static void remove_dh(private_crypto_factory_t *this, dh_constructor_t create)
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))
{
@@ -480,7 +480,7 @@ static void remove_dh(private_crypto_factory_t *this, dh_constructor_t create)
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -511,12 +511,12 @@ static bool unique_check(linked_list_t *list, entry_t **in, entry_t **out)
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);
}
/**
@@ -615,7 +615,7 @@ static void destroy(private_crypto_factory_t *this)
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);
}
@@ -657,7 +657,7 @@ crypto_factory_t *crypto_factory_create()
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;
}
diff --git a/src/libstrongswan/crypto/diffie_hellman.h b/src/libstrongswan/crypto/diffie_hellman.h
index c66ae56c3..ce8ab8e21 100644
--- a/src/libstrongswan/crypto/diffie_hellman.h
+++ b/src/libstrongswan/crypto/diffie_hellman.h
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: diffie_hellman.h 4023 2008-05-29 06:55:03Z andreas $
+ * $Id: diffie_hellman.h 4566 2008-11-04 13:12:11Z martin $
*/
/**
@@ -85,16 +85,6 @@ struct diffie_hellman_t {
void (*set_other_public_value) (diffie_hellman_t *this, chunk_t value);
/**
- * Gets the public value of partner.
- *
- * Space for returned chunk is allocated and must be freed by the caller.
- *
- * @param value public value of partner is stored at this location
- * @return SUCCESS, FAILED if other public value not set
- */
- status_t (*get_other_public_value) (diffie_hellman_t *this, chunk_t *value);
-
- /**
* Gets the own public value to transmit.
*
* Space for returned chunk is allocated and must be freed by the caller.
diff --git a/src/libstrongswan/crypto/prf_plus.c b/src/libstrongswan/crypto/prf_plus.c
index de7dbff84..3d37d4ef7 100644
--- a/src/libstrongswan/crypto/prf_plus.c
+++ b/src/libstrongswan/crypto/prf_plus.c
@@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: prf_plus.c 3589 2008-03-13 14:14:44Z martin $
+ * $Id: prf_plus.c 4524 2008-10-29 14:12:54Z martin $
*/
#include <string.h>
@@ -96,9 +96,16 @@ static void get_bytes(private_prf_plus_t *this, size_t length, u_int8_t *buffer)
*/
static void allocate_bytes(private_prf_plus_t *this, size_t length, chunk_t *chunk)
{
- chunk->ptr = malloc(length);
- chunk->len = length;
- this->public.get_bytes(&(this->public), length, chunk->ptr);
+ if (length)
+ {
+ chunk->ptr = malloc(length);
+ chunk->len = length;
+ get_bytes(this, length, chunk->ptr);
+ }
+ else
+ {
+ *chunk = chunk_empty;
+ }
}
/**