From: Stephan Bosch Date: Fri, 5 Jun 2020 18:50:55 +0000 (+0200) Subject: lib-oauth2: Reformat oauth2-key-cache.c. X-Git-Tag: 2.3.14.rc1~251 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0cd5624352634bc6c703e4c72ae72423d5f40bb0;p=thirdparty%2Fdovecot%2Fcore.git lib-oauth2: Reformat oauth2-key-cache.c. --- diff --git a/src/lib-oauth2/oauth2-key-cache.c b/src/lib-oauth2/oauth2-key-cache.c index 825d8b0301..e85c210842 100644 --- a/src/lib-oauth2/oauth2-key-cache.c +++ b/src/lib-oauth2/oauth2-key-cache.c @@ -16,7 +16,8 @@ struct oauth2_key_cache_entry { 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; @@ -26,15 +27,18 @@ struct oauth2_validation_key_cache { 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; @@ -52,13 +56,15 @@ void oauth2_validation_key_cache_deinit(struct oauth2_validation_key_cache **_ca 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; @@ -66,13 +72,15 @@ int oauth2_validation_key_cache_lookup_pubkey(struct oauth2_validation_key_cache 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; @@ -81,13 +89,15 @@ int oauth2_validation_key_cache_lookup_hmac_key(struct oauth2_validation_key_cac 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; @@ -102,19 +112,23 @@ void oauth2_validation_key_cache_insert_pubkey(struct oauth2_validation_key_cach 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; } @@ -131,7 +145,9 @@ int oauth2_validation_key_cache_evict(struct oauth2_validation_key_cache *cache, { 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)