struct oauth2_key_cache_entry *prev, *next;
};
-HASH_TABLE_DEFINE_TYPE(oauth2_key_cache, const char*, struct oauth2_key_cache_entry*);
+HASH_TABLE_DEFINE_TYPE(oauth2_key_cache, const char *,
+ struct oauth2_key_cache_entry *);
struct oauth2_validation_key_cache {
pool_t pool;
struct oauth2_validation_key_cache *oauth2_validation_key_cache_init(void)
{
- pool_t pool = pool_alloconly_create(MEMPOOL_GROWING"oauth2 key cache", 128);
+ pool_t pool = pool_alloconly_create(
+ MEMPOOL_GROWING"oauth2 key cache", 128);
struct oauth2_validation_key_cache *cache =
p_new(pool, struct oauth2_validation_key_cache, 1);
+
cache->pool = pool;
hash_table_create(&cache->keys, pool, 8, str_hash, strcmp);
return cache;
}
-void oauth2_validation_key_cache_deinit(struct oauth2_validation_key_cache **_cache)
+void oauth2_validation_key_cache_deinit(
+ struct oauth2_validation_key_cache **_cache)
{
struct oauth2_validation_key_cache *cache = *_cache;
*_cache = NULL;
pool_unref(&cache->pool);
}
-int oauth2_validation_key_cache_lookup_pubkey(struct oauth2_validation_key_cache *cache,
- const char *key_id,
- struct dcrypt_public_key **pubkey_r)
+int oauth2_validation_key_cache_lookup_pubkey(
+ struct oauth2_validation_key_cache *cache, const char *key_id,
+ struct dcrypt_public_key **pubkey_r)
{
if (cache == NULL)
return -1;
- struct oauth2_key_cache_entry *entry = hash_table_lookup(cache->keys, key_id);
+
+ struct oauth2_key_cache_entry *entry =
+ hash_table_lookup(cache->keys, key_id);
if (entry == NULL || entry->pubkey == NULL)
return -1;
return 0;
}
-int oauth2_validation_key_cache_lookup_hmac_key(struct oauth2_validation_key_cache *cache,
- const char *key_id,
- const buffer_t **hmac_key_r)
+int oauth2_validation_key_cache_lookup_hmac_key(
+ struct oauth2_validation_key_cache *cache, const char *key_id,
+ const buffer_t **hmac_key_r)
{
if (cache == NULL)
return -1;
- struct oauth2_key_cache_entry *entry = hash_table_lookup(cache->keys, key_id);
+
+ struct oauth2_key_cache_entry *entry =
+ hash_table_lookup(cache->keys, key_id);
if (entry == NULL || entry->hmac_key == NULL ||
entry->hmac_key->used == 0)
return -1;
return 0;
}
-void oauth2_validation_key_cache_insert_pubkey(struct oauth2_validation_key_cache *cache,
- const char *key_id,
- struct dcrypt_public_key *pubkey)
+void oauth2_validation_key_cache_insert_pubkey(
+ struct oauth2_validation_key_cache *cache, const char *key_id,
+ struct dcrypt_public_key *pubkey)
{
if (cache == NULL)
return;
- struct oauth2_key_cache_entry *entry = hash_table_lookup(cache->keys, key_id);
+
+ struct oauth2_key_cache_entry *entry =
+ hash_table_lookup(cache->keys, key_id);
if (entry != NULL) {
dcrypt_key_unref_public(&entry->pubkey);
entry->pubkey = pubkey;
hash_table_insert(cache->keys, entry->key_id, entry);
}
-void oauth2_validation_key_cache_insert_hmac_key(struct oauth2_validation_key_cache *cache,
- const char *key_id,
- const buffer_t *hmac_key)
+void oauth2_validation_key_cache_insert_hmac_key(
+ struct oauth2_validation_key_cache *cache, const char *key_id,
+ const buffer_t *hmac_key)
{
if (cache == NULL)
return;
- struct oauth2_key_cache_entry *entry = hash_table_lookup(cache->keys, key_id);
+
+ struct oauth2_key_cache_entry *entry =
+ hash_table_lookup(cache->keys, key_id);
if (entry != NULL) {
dcrypt_key_unref_public(&entry->pubkey);
- if (entry->hmac_key == NULL)
- entry->hmac_key = buffer_create_dynamic(cache->pool, hmac_key->used);
- else
+ if (entry->hmac_key == NULL) {
+ entry->hmac_key = buffer_create_dynamic(
+ cache->pool, hmac_key->used);
+ } else {
buffer_set_used_size(entry->hmac_key, 0);
+ }
buffer_append(entry->hmac_key, hmac_key->data, hmac_key->used);
return;
}
{
if (cache == NULL)
return -1;
- struct oauth2_key_cache_entry *entry = hash_table_lookup(cache->keys, key_id);
+
+ struct oauth2_key_cache_entry *entry =
+ hash_table_lookup(cache->keys, key_id);
if (entry == NULL)
return -1;
if (entry->pubkey != NULL)