Include ht.h in all headers that use HT_ENTRY()
[tor.git] / src / feature / dirauth / keypin.h
blob0042cfafc05bc3ea3ec4e524ce63baa0adbeb01b
1 /* Copyright (c) 2014-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 /**
5 * @file keypin.h
6 * @brief Header for keypin.c
7 **/
9 #ifndef TOR_KEYPIN_H
10 #define TOR_KEYPIN_H
12 #include "lib/testsupport/testsupport.h"
14 int keypin_check_and_add(const uint8_t *rsa_id_digest,
15 const uint8_t *ed25519_id_key,
16 const int replace_existing_entry);
17 int keypin_check(const uint8_t *rsa_id_digest,
18 const uint8_t *ed25519_id_key);
19 int keypin_close_journal(void);
21 #ifdef HAVE_MODULE_DIRAUTH
22 int keypin_open_journal(const char *fname);
23 int keypin_load_journal(const char *fname);
24 #else
25 static inline int
26 keypin_open_journal(const char *fname)
28 (void)fname;
29 return 0;
31 static inline int
32 keypin_load_journal(const char *fname)
34 (void)fname;
35 return 0;
37 #endif /* defined(HAVE_MODULE_DIRAUTH) */
38 void keypin_clear(void);
39 int keypin_check_lone_rsa(const uint8_t *rsa_id_digest);
41 #define KEYPIN_FOUND 0
42 #define KEYPIN_ADDED 1
43 #define KEYPIN_MISMATCH -1
44 #define KEYPIN_NOT_FOUND -2
46 #ifdef KEYPIN_PRIVATE
48 #include "ext/ht.h"
50 /**
51 * In-memory representation of a key-pinning table entry.
53 typedef struct keypin_ent_st {
54 HT_ENTRY(keypin_ent_st) rsamap_node;
55 HT_ENTRY(keypin_ent_st) edmap_node;
56 /** SHA1 hash of the RSA key */
57 uint8_t rsa_id[DIGEST_LEN];
58 /** Ed2219 key. */
59 uint8_t ed25519_key[DIGEST256_LEN];
60 } keypin_ent_t;
62 STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp);
63 STATIC int keypin_load_journal_impl(const char *data, size_t size);
65 MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
66 #endif /* defined(KEYPIN_PRIVATE) */
68 #endif /* !defined(TOR_KEYPIN_H) */