diff options
author | Martin Willi <martin@strongswan.org> | 2009-08-24 11:12:07 +0200 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2009-08-26 11:23:52 +0200 |
commit | 0dd2defc5ad01b0754b1d377779ee298d5b26f3e (patch) | |
tree | 4bf52d8ba06e0900624f0abb60b2e203f26b3cb6 /src/libstrongswan/credentials/keys/key_encoding.c | |
parent | 64e77e8fbbfa9885d6fa3757a8f2b809237af63d (diff) | |
download | strongswan-0dd2defc5ad01b0754b1d377779ee298d5b26f3e.tar.bz2 strongswan-0dd2defc5ad01b0754b1d377779ee298d5b26f3e.tar.xz |
added a seperate chache lookup, as encode() requires arguments expensive to build
Diffstat (limited to 'src/libstrongswan/credentials/keys/key_encoding.c')
-rw-r--r-- | src/libstrongswan/credentials/keys/key_encoding.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libstrongswan/credentials/keys/key_encoding.c b/src/libstrongswan/credentials/keys/key_encoding.c index 15ddfffcf..1ffb4241b 100644 --- a/src/libstrongswan/credentials/keys/key_encoding.c +++ b/src/libstrongswan/credentials/keys/key_encoding.c @@ -111,6 +111,28 @@ static bool equals(void *key1, void *key2) } /** + * Implementation of key_encoding_t.get_cache + */ +static bool get_cache(private_key_encoding_t *this, key_encoding_type_t type, + void *cache, chunk_t *encoding) +{ + chunk_t *chunk; + + if (type >= KEY_ENCODING_MAX || type < 0) + { + return FALSE; + } + this->lock->read_lock(this->lock); + chunk = this->cache[type]->get(this->cache[type], cache); + if (chunk) + { + *encoding = *chunk; + } + this->lock->unlock(this->lock); + return !!chunk; +} + +/** * Implementation of key_encoding_t.encode */ static bool encode(private_key_encoding_t *this, key_encoding_type_t type, @@ -239,6 +261,7 @@ key_encoding_t *key_encoding_create() key_encoding_type_t type; this->public.encode = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding, ...))encode; + this->public.get_cache = (bool(*)(key_encoding_t*, key_encoding_type_t type, void *cache, chunk_t *encoding))get_cache; this->public.clear_cache = (void(*)(key_encoding_t*, void *cache))clear_cache; this->public.add_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))add_encoder; this->public.remove_encoder = (void(*)(key_encoding_t*, key_encoder_t encoder))remove_encoder; |