2002-12-13 21:15:29 +01:00
|
|
|
/* key-chain for authentication.
|
|
|
|
* Copyright (C) 2000 Kunihiro Ishiguro
|
|
|
|
*
|
|
|
|
* This file is part of GNU Zebra.
|
|
|
|
*
|
|
|
|
* GNU Zebra is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published
|
|
|
|
* by the Free Software Foundation; either version 2, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
2017-05-13 10:25:29 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-12-13 21:15:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ZEBRA_KEYCHAIN_H
|
|
|
|
#define _ZEBRA_KEYCHAIN_H
|
|
|
|
|
2016-09-27 14:51:08 +02:00
|
|
|
#include "qobj.h"
|
|
|
|
|
2019-02-07 23:10:31 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-05-11 12:00:38 +02:00
|
|
|
enum keychain_hash_algo {
|
|
|
|
KEYCHAIN_ALGO_NULL,
|
|
|
|
KEYCHAIN_ALGO_MD5,
|
|
|
|
KEYCHAIN_ALGO_HMAC_SHA1,
|
|
|
|
KEYCHAIN_ALGO_HMAC_SHA256,
|
|
|
|
KEYCHAIN_ALGO_HMAC_SHA384,
|
|
|
|
KEYCHAIN_ALGO_HMAC_SHA512,
|
|
|
|
KEYCHAIN_ALGO_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define KEYCHAIN_MD5_HASH_SIZE 16
|
|
|
|
#define KEYCHAIN_HMAC_SHA1_HASH_SIZE 20
|
|
|
|
#define KEYCHAIN_HMAC_SHA256_HASH_SIZE 32
|
|
|
|
#define KEYCHAIN_HMAC_SHA384_HASH_SIZE 48
|
|
|
|
#define KEYCHAIN_HMAC_SHA512_HASH_SIZE 64
|
|
|
|
#define KEYCHAIN_MAX_HASH_SIZE 64
|
|
|
|
|
|
|
|
#define KEYCHAIN_ALGO_MD5_INTERNAL_BLK_SIZE 16
|
|
|
|
#define KEYCHAIN_ALGO_SHA1_INTERNAL_BLK_SIZE 64
|
|
|
|
#define KEYCHAIN_ALGO_SHA256_INTERNAL_BLK_SIZE 64
|
|
|
|
#define KEYCHAIN_ALGO_SHA384_INTERNAL_BLK_SIZE 128
|
|
|
|
#define KEYCHAIN_ALGO_SHA512_INTERNAL_BLK_SIZE 128
|
|
|
|
#define KEYCHAIN_ALGO_MAX_INTERNAL_BLK_SIZE 128
|
|
|
|
|
|
|
|
struct keychain_algo_info {
|
|
|
|
enum keychain_hash_algo key;
|
|
|
|
const char *name;
|
|
|
|
uint32_t length;
|
|
|
|
uint32_t block;
|
|
|
|
const char *desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct keychain_algo_info algo_info[];
|
|
|
|
uint32_t keychain_get_block_size(enum keychain_hash_algo key);
|
|
|
|
uint32_t keychain_get_hash_len(enum keychain_hash_algo key);
|
|
|
|
const char *keychain_get_description(enum keychain_hash_algo key);
|
|
|
|
struct keychain_algo_info
|
|
|
|
keychain_get_hash_algo_info(enum keychain_hash_algo key);
|
|
|
|
enum keychain_hash_algo keychain_get_algo_id_by_name(const char *name);
|
|
|
|
const char *keychain_get_algo_name_by_id(enum keychain_hash_algo key);
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
struct keychain {
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
struct list *key;
|
2016-09-27 14:51:08 +02:00
|
|
|
|
|
|
|
QOBJ_FIELDS;
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
2016-09-27 14:51:08 +02:00
|
|
|
DECLARE_QOBJ_TYPE(keychain);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
struct key_range {
|
|
|
|
time_t start;
|
|
|
|
time_t end;
|
|
|
|
|
2018-03-27 21:13:34 +02:00
|
|
|
uint8_t duration;
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct key {
|
2018-03-27 21:13:34 +02:00
|
|
|
uint32_t index;
|
2002-12-13 21:15:29 +01:00
|
|
|
|
|
|
|
char *string;
|
2021-05-11 12:00:38 +02:00
|
|
|
enum keychain_hash_algo hash_algo;
|
2002-12-13 21:15:29 +01:00
|
|
|
struct key_range send;
|
|
|
|
struct key_range accept;
|
2016-09-27 14:51:08 +02:00
|
|
|
|
|
|
|
QOBJ_FIELDS;
|
2002-12-13 21:15:29 +01:00
|
|
|
};
|
2016-09-27 14:51:08 +02:00
|
|
|
DECLARE_QOBJ_TYPE(key);
|
2002-12-13 21:15:29 +01:00
|
|
|
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
extern void keychain_init(void);
|
|
|
|
extern struct keychain *keychain_lookup(const char *);
|
2018-03-27 21:13:34 +02:00
|
|
|
extern struct key *key_lookup_for_accept(const struct keychain *, uint32_t);
|
2005-05-06 Paul Jakma <paul@dishone.st>
* (general) extern and static'ification of functions in code and
header.
Cleanup any definitions with unspecified arguments.
Add casts for callback assignments where the callback is defined,
typically, as passing void *, but the function being assigned has
some other pointer type defined as its argument, as gcc complains
about casts from void * to X* via function arguments.
Fix some old K&R style function argument definitions.
Add noreturn gcc attribute to some functions, as appropriate.
Add unused gcc attribute to some functions (eg ones meant to help
while debugging)
Add guard defines to headers which were missing them.
* command.c: (install_node) add const qualifier, still doesnt shut
up the warning though, because of the double pointer.
(cmp_node) ditto
* keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived
fromn vty.h ones to fix some of the (long) < 0 warnings.
* thread.c: (various) use thread_empty
(cpu_record_hash_key) should cast to uintptr_t, a stdint.h type
* vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they
removed from ospfd/ospf_vty.h
* zebra.h: Move definition of ZEBRA_PORT to here, to remove
dependence of lib on zebra/zserv.h
2005-05-06 23:25:49 +02:00
|
|
|
extern struct key *key_match_for_accept(const struct keychain *, const char *);
|
|
|
|
extern struct key *key_lookup_for_send(const struct keychain *);
|
2021-05-11 12:00:38 +02:00
|
|
|
const char *keychain_algo_str(enum keychain_hash_algo hash_algo);
|
2019-02-07 23:10:31 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-12-13 21:15:29 +01:00
|
|
|
#endif /* _ZEBRA_KEYCHAIN_H */
|