summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/coupling/coupling_validator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon/plugins/coupling/coupling_validator.c')
-rw-r--r--src/libcharon/plugins/coupling/coupling_validator.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/src/libcharon/plugins/coupling/coupling_validator.c b/src/libcharon/plugins/coupling/coupling_validator.c
index 06b6f7d86..539be7548 100644
--- a/src/libcharon/plugins/coupling/coupling_validator.c
+++ b/src/libcharon/plugins/coupling/coupling_validator.c
@@ -70,7 +70,11 @@ static bool get_cert_hash(private_coupling_validator_t *this,
{
return FALSE;
}
- this->hasher->get_hash(this->hasher, encoding, buf);
+ if (!this->hasher->get_hash(this->hasher, encoding, buf))
+ {
+ free(encoding.ptr);
+ return FALSE;
+ }
free(encoding.ptr);
chunk_to_hex(chunk_create(buf, this->hasher->get_hash_size(this->hasher)),
hex, FALSE);
@@ -195,17 +199,6 @@ coupling_validator_t *coupling_validator_create()
{
private_coupling_validator_t *this;
char *path, *hash;
- int i;
- struct {
- hash_algorithm_t alg;
- char *name;
- } hash_types[] = {
- { HASH_MD5, "md5"},
- { HASH_SHA1, "sha1"},
- { HASH_SHA256, "sha256"},
- { HASH_SHA384, "sha384"},
- { HASH_SHA512, "sha512"},
- };
INIT(this,
.public = {
@@ -216,20 +209,15 @@ coupling_validator_t *coupling_validator_create()
},
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.max_couplings = lib->settings->get_int(lib->settings,
- "charon.plugins.coupling.max", 1),
+ "%s.plugins.coupling.max", 1,
+ charon->name),
);
hash = lib->settings->get_str(lib->settings,
- "charon.plugins.coupling.hash", "sha1");
- for (i = 0; i < countof(hash_types); i++)
- {
- if (strcaseeq(hash_types[i].name, hash))
- {
- this->hasher = lib->crypto->create_hasher(lib->crypto,
- hash_types[i].alg);
- break;
- }
- }
+ "%s.plugins.coupling.hash", "sha1",
+ charon->name);
+ this->hasher = lib->crypto->create_hasher(lib->crypto,
+ enum_from_name(hash_algorithm_short_names, hash));
if (!this->hasher)
{
DBG1(DBG_CFG, "unsupported coupling hash algorithm: %s", hash);
@@ -238,7 +226,8 @@ coupling_validator_t *coupling_validator_create()
}
path = lib->settings->get_str(lib->settings,
- "charon.plugins.coupling.file", NULL);
+ "%s.plugins.coupling.file", NULL,
+ charon->name);
if (!path)
{
DBG1(DBG_CFG, "coupling file path unspecified");