aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/crypt_burn.c2
-rw-r--r--src/conftest/hooks/custom_proposal.c2
-rw-r--r--src/libcharon/config/proposal.c47
-rw-r--r--src/libstrongswan/crypto/proposal/proposal_keywords.c4
-rw-r--r--src/libstrongswan/crypto/proposal/proposal_keywords.h3
-rw-r--r--src/scepclient/scepclient.c4
6 files changed, 30 insertions, 32 deletions
diff --git a/scripts/crypt_burn.c b/scripts/crypt_burn.c
index 1f1536ae7..c7990edc4 100644
--- a/scripts/crypt_burn.c
+++ b/scripts/crypt_burn.c
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
limit = atoi(argv[2]);
}
- token = proposal_get_token(argv[1], strlen(argv[1]));
+ token = proposal_get_token(argv[1]);
if (!token)
{
fprintf(stderr, "algorithm '%s' unknown!\n", argv[1]);
diff --git a/src/conftest/hooks/custom_proposal.c b/src/conftest/hooks/custom_proposal.c
index 958bc1052..b09fe6ee0 100644
--- a/src/conftest/hooks/custom_proposal.c
+++ b/src/conftest/hooks/custom_proposal.c
@@ -91,7 +91,7 @@ static linked_list_t* load_proposals(private_custom_proposal_t *this,
alg = strtoul(value, &end, 10);
if (end == value || errno)
{
- token = proposal_get_token(value, strlen(value));
+ token = proposal_get_token(value);
if (!token)
{
DBG1(DBG_CFG, "unknown algorithm: '%s', skipped", value);
diff --git a/src/libcharon/config/proposal.c b/src/libcharon/config/proposal.c
index 6523fd351..bf2bcd031 100644
--- a/src/libcharon/config/proposal.c
+++ b/src/libcharon/config/proposal.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009 Tobias Brunner
+ * Copyright (C) 2008-2012 Tobias Brunner
* Copyright (C) 2006-2010 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -21,7 +21,7 @@
#include <daemon.h>
#include <utils/linked_list.h>
#include <utils/identification.h>
-#include <utils/lexparser.h>
+
#include <crypto/transform.h>
#include <crypto/prfs/prf.h>
#include <crypto/crypters/crypter.h>
@@ -560,14 +560,14 @@ static void check_proposal(private_proposal_t *this)
/**
* add a algorithm identified by a string to the proposal.
*/
-static status_t add_string_algo(private_proposal_t *this, chunk_t alg)
+static bool add_string_algo(private_proposal_t *this, const char *alg)
{
- const proposal_token_t *token = proposal_get_token(alg.ptr, alg.len);
+ const proposal_token_t *token = proposal_get_token(alg);
if (token == NULL)
{
- DBG1(DBG_CFG, "algorithm '%.*s' not recognized", alg.len, alg.ptr);
- return FAILED;
+ DBG1(DBG_CFG, "algorithm '%s' not recognized", alg);
+ return FALSE;
}
add_algorithm(this, token->type, token->algorithm, token->keysize);
@@ -610,7 +610,7 @@ static status_t add_string_algo(private_proposal_t *this, chunk_t alg)
add_algorithm(this, PSEUDO_RANDOM_FUNCTION, prf, 0);
}
}
- return SUCCESS;
+ return TRUE;
}
/**
@@ -901,28 +901,27 @@ proposal_t *proposal_create_default(protocol_id_t protocol)
*/
proposal_t *proposal_create_from_string(protocol_id_t protocol, const char *algs)
{
- private_proposal_t *this = (private_proposal_t*)proposal_create(protocol, 0);
- chunk_t string = {(void*)algs, strlen(algs)};
- chunk_t alg;
- status_t status = SUCCESS;
+ private_proposal_t *this;
+ enumerator_t *enumerator;
+ bool failed = TRUE;
+ char *alg;
- eat_whitespace(&string);
- if (string.len < 1)
- {
- destroy(this);
- return NULL;
- }
+ this = (private_proposal_t*)proposal_create(protocol, 0);
/* get all tokens, separated by '-' */
- while (extract_token(&alg, '-', &string))
- {
- status |= add_string_algo(this, alg);
- }
- if (string.len)
+ enumerator = enumerator_create_token(algs, "-", " ");
+ while (enumerator->enumerate(enumerator, &alg))
{
- status |= add_string_algo(this, string);
+ if (!add_string_algo(this, alg))
+ {
+ failed = TRUE;
+ break;
+ }
+ failed = FALSE;
}
- if (status != SUCCESS)
+ enumerator->destroy(enumerator);
+
+ if (failed)
{
destroy(this);
return NULL;
diff --git a/src/libstrongswan/crypto/proposal/proposal_keywords.c b/src/libstrongswan/crypto/proposal/proposal_keywords.c
index 9e16dd281..bb6353ded 100644
--- a/src/libstrongswan/crypto/proposal/proposal_keywords.c
+++ b/src/libstrongswan/crypto/proposal/proposal_keywords.c
@@ -26,7 +26,7 @@
/*
* see header file
*/
-const proposal_token_t* proposal_get_token(const char *str, u_int len)
+const proposal_token_t* proposal_get_token(const char *str)
{
- return proposal_get_token_static(str, len);
+ return proposal_get_token_static(str, strlen(str));
}
diff --git a/src/libstrongswan/crypto/proposal/proposal_keywords.h b/src/libstrongswan/crypto/proposal/proposal_keywords.h
index 1abd10f90..ad9e82a36 100644
--- a/src/libstrongswan/crypto/proposal/proposal_keywords.h
+++ b/src/libstrongswan/crypto/proposal/proposal_keywords.h
@@ -62,9 +62,8 @@ struct proposal_token {
* Returns a proposal token for the specified string if a token exists.
*
* @param str the string containing the name of the token
- * @param len the length of the string
* @return proposal_tolen if found otherwise NULL
*/
-const proposal_token_t* proposal_get_token(const char *str, u_int len);
+const proposal_token_t* proposal_get_token(const char *str);
#endif /** PROPOSAL_KEYWORDS_H_ @}*/
diff --git a/src/scepclient/scepclient.c b/src/scepclient/scepclient.c
index 76d639a84..2444080a1 100644
--- a/src/scepclient/scepclient.c
+++ b/src/scepclient/scepclient.c
@@ -828,7 +828,7 @@ int main(int argc, char **argv)
if (strcaseeq("enc", type))
{
- token = proposal_get_token(algo, strlen(algo));
+ token = proposal_get_token(algo);
if (token == NULL || token->type != ENCRYPTION_ALGORITHM)
{
usage("invalid algorithm specified");
@@ -846,7 +846,7 @@ int main(int argc, char **argv)
{
hash_algorithm_t hash;
- token = proposal_get_token(algo, strlen(algo));
+ token = proposal_get_token(algo);
if (token == NULL || token->type != INTEGRITY_ALGORITHM)
{
usage("invalid algorithm specified");