chiark / gitweb /
pubkeys: Provide parser (and spec) for peer pubkeys files
[secnet.git] / pubkeys.c
1 /*
2  * This file is part of secnet.
3  * See README for full list of copyright holders.
4  *
5  * secnet is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  * 
10  * secnet is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * version 3 along with secnet; if not, see
17  * https://www.gnu.org/licenses/gpl.html.
18  */
19
20 #include "pubkeys.h"
21 #include "pubkeys.yy.h"
22
23 void keyset_dispose(struct peer_keyset **ks_io)
24 {
25     struct peer_keyset *ks=*ks_io;
26     if (!ks) return;
27     *ks_io=0;
28     ks->refcount--;
29     assert(ks->refcount>=0);
30     if (ks->refcount) return;
31     for (int ki=0; ki<ks->nkeys; ki++) {
32         struct sigpubkey_if *pk=ks->keys[ki].pubkey;
33         pk->dispose(pk->st);
34     }
35     free(ks);
36 }
37
38 const struct sigscheme_info *sigscheme_lookup(const char *name)
39 {
40     const struct sigscheme_info *scheme;
41     for (scheme=sigschemes; scheme->name; scheme++)
42         if (!strcmp(name,scheme->name))
43             return scheme;
44     return 0;
45 }