diff options
author | Martin Willi <martin@strongswan.org> | 2008-04-24 13:26:22 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-04-24 13:26:22 +0000 |
commit | 9213ad27c27bbe19a30cf414f0b695aa6d205ff1 (patch) | |
tree | 4b1f5f6b75799056eb60d2ae0e39e7e7fcf51d3b /src/charon/plugins/stroke | |
parent | 71983b5cc917ec1bfc772c79feec9551a1705524 (diff) | |
download | strongswan-9213ad27c27bbe19a30cf414f0b695aa6d205ff1.tar.bz2 strongswan-9213ad27c27bbe19a30cf414f0b695aa6d205ff1.tar.xz |
replaced freeswan ttodata by own chunk_{to|from}_{hex|base64} functions
Diffstat (limited to 'src/charon/plugins/stroke')
-rw-r--r-- | src/charon/plugins/stroke/stroke_ca.c | 11 | ||||
-rw-r--r-- | src/charon/plugins/stroke/stroke_cred.c | 34 |
2 files changed, 21 insertions, 24 deletions
diff --git a/src/charon/plugins/stroke/stroke_ca.c b/src/charon/plugins/stroke/stroke_ca.c index c61aadba1..11de24135 100644 --- a/src/charon/plugins/stroke/stroke_ca.c +++ b/src/charon/plugins/stroke/stroke_ca.c @@ -195,12 +195,13 @@ static enumerator_t *create_inner_cdp_hashandurl(ca_section_t *section, cdp_data { if (current->matches(current, data->id)) { - chunk_t hash = current->get_encoding(current); - char *hash_str = chunk_to_hex(hash, FALSE); - char *url = malloc(strlen(section->certuribase) + 40 + 1); + char *url, *hash; + + url = malloc(strlen(section->certuribase) + 40 + 1); strcpy(url, section->certuribase); - strncat(url, hash_str, 40); - free(hash_str); + hash = chunk_to_hex(current->get_encoding(current), NULL, FALSE).ptr; + strncat(url, hash, 40); + free(hash); enumerator = enumerator_create_single(url, free); break; diff --git a/src/charon/plugins/stroke/stroke_cred.c b/src/charon/plugins/stroke/stroke_cred.c index 7d0d14699..1b8498ab5 100644 --- a/src/charon/plugins/stroke/stroke_cred.c +++ b/src/charon/plugins/stroke/stroke_cred.c @@ -26,7 +26,6 @@ #include <utils/linked_list.h> #include <utils/mutex.h> #include <utils/lexparser.h> -#include <asn1/ttodata.h> #include <asn1/pem.h> #include <daemon.h> @@ -541,15 +540,14 @@ static void cache_cert(private_stroke_cred_t *this, certificate_t *cert) if (add_crl(this, crl)) { char buf[256]; - char *hex; - chunk_t chunk; + chunk_t chunk, hex; identification_t *id; id = crl->get_authKeyIdentifier(crl); chunk = id->get_encoding(id); - hex = chunk_to_hex(chunk, FALSE); + hex = chunk_to_hex(chunk, NULL, FALSE); snprintf(buf, sizeof(buf), "%s/%s.crl", CRL_DIR, hex); - free(hex); + free(hex.ptr); chunk = cert->get_encoding(cert); if (chunk_write(chunk, buf, 022, TRUE)) @@ -615,25 +613,23 @@ static err_t extract_secret(chunk_t *secret, chunk_t *line) { /* treat as an ASCII string */ *secret = chunk_clone(raw_secret); + return NULL; } - else + /* treat 0x as hex, 0s as base64 */ + if (raw_secret.len > 2) { - size_t len; - err_t ugh; - - /* secret converted to binary form doesn't use more space than the raw_secret */ - *secret = chunk_alloc(raw_secret.len); - - /* convert from HEX or Base64 to binary */ - ugh = ttodata(raw_secret.ptr, raw_secret.len, 0, secret->ptr, secret->len, &len); - - if (ugh != NULL) + if (strncasecmp("0x", raw_secret.ptr, 2) == 0) { - chunk_clear(secret); - return ugh; + *secret = chunk_from_hex(chunk_skip(raw_secret, 2), NULL); + return NULL; + } + if (strncasecmp("0s", raw_secret.ptr, 2) == 0) + { + *secret = chunk_from_base64(chunk_skip(raw_secret, 2), NULL); + return NULL; } - secret->len = len; } + *secret = chunk_clone(raw_secret); return NULL; } |