]> git.proxmox.com Git - mirror_frr.git/blob - lib/keychain.h
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
[mirror_frr.git] / lib / keychain.h
1 /* key-chain for authentication.
2 * Copyright (C) 2000 Kunihiro Ishiguro
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2, or (at your
9 * option) any later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef _ZEBRA_KEYCHAIN_H
22 #define _ZEBRA_KEYCHAIN_H
23
24 #include "qobj.h"
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 enum keychain_hash_algo {
31 KEYCHAIN_ALGO_NULL,
32 KEYCHAIN_ALGO_MD5,
33 KEYCHAIN_ALGO_HMAC_SHA1,
34 KEYCHAIN_ALGO_HMAC_SHA256,
35 KEYCHAIN_ALGO_HMAC_SHA384,
36 KEYCHAIN_ALGO_HMAC_SHA512,
37 KEYCHAIN_ALGO_MAX
38 };
39
40 #define KEYCHAIN_MD5_HASH_SIZE 16
41 #define KEYCHAIN_HMAC_SHA1_HASH_SIZE 20
42 #define KEYCHAIN_HMAC_SHA256_HASH_SIZE 32
43 #define KEYCHAIN_HMAC_SHA384_HASH_SIZE 48
44 #define KEYCHAIN_HMAC_SHA512_HASH_SIZE 64
45 #define KEYCHAIN_MAX_HASH_SIZE 64
46
47 #define KEYCHAIN_ALGO_MD5_INTERNAL_BLK_SIZE 16
48 #define KEYCHAIN_ALGO_SHA1_INTERNAL_BLK_SIZE 64
49 #define KEYCHAIN_ALGO_SHA256_INTERNAL_BLK_SIZE 64
50 #define KEYCHAIN_ALGO_SHA384_INTERNAL_BLK_SIZE 128
51 #define KEYCHAIN_ALGO_SHA512_INTERNAL_BLK_SIZE 128
52 #define KEYCHAIN_ALGO_MAX_INTERNAL_BLK_SIZE 128
53
54 struct keychain_algo_info {
55 enum keychain_hash_algo key;
56 const char *name;
57 uint16_t length;
58 uint16_t block;
59 const char *desc;
60 };
61
62 extern const struct keychain_algo_info algo_info[];
63 uint16_t keychain_get_block_size(enum keychain_hash_algo key);
64 uint16_t keychain_get_hash_len(enum keychain_hash_algo key);
65 const char *keychain_get_description(enum keychain_hash_algo key);
66 struct keychain_algo_info
67 keychain_get_hash_algo_info(enum keychain_hash_algo key);
68 enum keychain_hash_algo keychain_get_algo_id_by_name(const char *name);
69 const char *keychain_get_algo_name_by_id(enum keychain_hash_algo key);
70
71 struct keychain {
72 char *name;
73
74 struct list *key;
75
76 QOBJ_FIELDS;
77 };
78 DECLARE_QOBJ_TYPE(keychain);
79
80 struct key_range {
81 time_t start;
82 time_t end;
83
84 uint8_t duration;
85 };
86
87 struct key {
88 uint32_t index;
89
90 char *string;
91 enum keychain_hash_algo hash_algo;
92 struct key_range send;
93 struct key_range accept;
94
95 QOBJ_FIELDS;
96 };
97 DECLARE_QOBJ_TYPE(key);
98
99 extern void keychain_init(void);
100 extern struct keychain *keychain_lookup(const char *);
101 extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t);
102 extern struct key *key_match_for_accept(const struct keychain *, const char *);
103 extern struct key *key_lookup_for_send(const struct keychain *);
104 const char *keychain_algo_str(enum keychain_hash_algo hash_algo);
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif /* _ZEBRA_KEYCHAIN_H */