1 /* vim: set tabstop=8 shiftwidth=4 softtabstop=4 expandtab smarttab colorcolumn=80: */ 2 /* 3 * Copyright 2016 Red Hat, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #include "hooks.h" 19 #include <string.h> 20 21 static const jose_hook_jwk_t *jwks; 22 static const jose_hook_alg_t *algs; 23 24 void jose_hook_jwk_push(jose_hook_jwk_t * jwk)25jose_hook_jwk_push(jose_hook_jwk_t *jwk) 26 { 27 jwk->next = jwks; 28 jwks = jwk; 29 } 30 31 const jose_hook_jwk_t * jose_hook_jwk_list(void)32jose_hook_jwk_list(void) 33 { 34 return jwks; 35 } 36 37 void jose_hook_alg_push(jose_hook_alg_t * alg)38jose_hook_alg_push(jose_hook_alg_t *alg) 39 { 40 alg->next = algs; 41 algs = alg; 42 } 43 44 const jose_hook_alg_t * jose_hook_alg_list(void)45jose_hook_alg_list(void) 46 { 47 return algs; 48 } 49 50 const jose_hook_alg_t * jose_hook_alg_find(jose_hook_alg_kind_t kind,const char * name)51jose_hook_alg_find(jose_hook_alg_kind_t kind, const char *name) 52 { 53 for (const jose_hook_alg_t *a = algs; a; a = a->next) { 54 if (a->kind != kind) 55 continue; 56 57 if (!name || strcmp(a->name, name) == 0) 58 return a; 59 } 60 61 return NULL; 62 } 63