]> git.proxmox.com Git - mirror_frr.git/blame - lib/keychain.h
Merge pull request #10583 from donaldsharp/pim_upstream_timers
[mirror_frr.git] / lib / keychain.h
CommitLineData
718e3744 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 *
896014f4
DL
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
718e3744 19 */
20
21#ifndef _ZEBRA_KEYCHAIN_H
22#define _ZEBRA_KEYCHAIN_H
23
e80e7cce
DL
24#include "qobj.h"
25
5e244469
RW
26#ifdef __cplusplus
27extern "C" {
28#endif
29
72000880
AR
30enum 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
54struct keychain_algo_info {
55 enum keychain_hash_algo key;
56 const char *name;
42bfee18
AR
57 uint16_t length;
58 uint16_t block;
72000880
AR
59 const char *desc;
60};
61
62extern const struct keychain_algo_info algo_info[];
42bfee18
AR
63uint16_t keychain_get_block_size(enum keychain_hash_algo key);
64uint16_t keychain_get_hash_len(enum keychain_hash_algo key);
72000880
AR
65const char *keychain_get_description(enum keychain_hash_algo key);
66struct keychain_algo_info
67keychain_get_hash_algo_info(enum keychain_hash_algo key);
68enum keychain_hash_algo keychain_get_algo_id_by_name(const char *name);
69const char *keychain_get_algo_name_by_id(enum keychain_hash_algo key);
70
d62a17ae 71struct keychain {
72 char *name;
718e3744 73
d62a17ae 74 struct list *key;
e80e7cce 75
96244aca 76 QOBJ_FIELDS;
718e3744 77};
96244aca 78DECLARE_QOBJ_TYPE(keychain);
718e3744 79
d62a17ae 80struct key_range {
81 time_t start;
82 time_t end;
718e3744 83
d7c0a89a 84 uint8_t duration;
718e3744 85};
86
d62a17ae 87struct key {
d7c0a89a 88 uint32_t index;
718e3744 89
d62a17ae 90 char *string;
72000880 91 enum keychain_hash_algo hash_algo;
d62a17ae 92 struct key_range send;
93 struct key_range accept;
e80e7cce 94
96244aca 95 QOBJ_FIELDS;
718e3744 96};
96244aca 97DECLARE_QOBJ_TYPE(key);
718e3744 98
d62a17ae 99extern void keychain_init(void);
100extern struct keychain *keychain_lookup(const char *);
d7c0a89a 101extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t);
d62a17ae 102extern struct key *key_match_for_accept(const struct keychain *, const char *);
103extern struct key *key_lookup_for_send(const struct keychain *);
72000880 104const char *keychain_algo_str(enum keychain_hash_algo hash_algo);
5e244469
RW
105#ifdef __cplusplus
106}
107#endif
108
718e3744 109#endif /* _ZEBRA_KEYCHAIN_H */