1 /* key-chain for authentication.
2 * Copyright (C) 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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.
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.
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
21 #ifndef _ZEBRA_KEYCHAIN_H
22 #define _ZEBRA_KEYCHAIN_H
30 enum keychain_hash_algo
{
33 KEYCHAIN_ALGO_HMAC_SHA1
,
34 KEYCHAIN_ALGO_HMAC_SHA256
,
35 KEYCHAIN_ALGO_HMAC_SHA384
,
36 KEYCHAIN_ALGO_HMAC_SHA512
,
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
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
54 struct keychain_algo_info
{
55 enum keychain_hash_algo key
;
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
);
78 DECLARE_QOBJ_TYPE(keychain
);
91 enum keychain_hash_algo hash_algo
;
92 struct key_range send
;
93 struct key_range accept
;
97 DECLARE_QOBJ_TYPE(key
);
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
);
109 #endif /* _ZEBRA_KEYCHAIN_H */