Cache control file
[tor/appveyor.git] / src / or / keypin.h
blobfbb77e5c35a230934c6cb33a0908ddb7321c8622
1 /* Copyright (c) 2014-2017, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #ifndef TOR_KEYPIN_H
5 #define TOR_KEYPIN_H
7 #include "testsupport.h"
9 int keypin_check_and_add(const uint8_t *rsa_id_digest,
10 const uint8_t *ed25519_id_key,
11 const int replace_existing_entry);
12 int keypin_check(const uint8_t *rsa_id_digest,
13 const uint8_t *ed25519_id_key);
15 int keypin_open_journal(const char *fname);
16 int keypin_close_journal(void);
17 int keypin_load_journal(const char *fname);
18 void keypin_clear(void);
19 int keypin_check_lone_rsa(const uint8_t *rsa_id_digest);
21 #define KEYPIN_FOUND 0
22 #define KEYPIN_ADDED 1
23 #define KEYPIN_MISMATCH -1
24 #define KEYPIN_NOT_FOUND -2
26 #ifdef KEYPIN_PRIVATE
28 /**
29 * In-memory representation of a key-pinning table entry.
31 typedef struct keypin_ent_st {
32 HT_ENTRY(keypin_ent_st) rsamap_node;
33 HT_ENTRY(keypin_ent_st) edmap_node;
34 /** SHA1 hash of the RSA key */
35 uint8_t rsa_id[DIGEST_LEN];
36 /** Ed2219 key. */
37 uint8_t ed25519_key[DIGEST256_LEN];
38 } keypin_ent_t;
40 STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp);
41 STATIC int keypin_load_journal_impl(const char *data, size_t size);
43 MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
44 #endif /* defined(KEYPIN_PRIVATE) */
46 #endif /* !defined(TOR_KEYPIN_H) */