tor  0.4.2.1-alpha-dev
keypin.h
1 /* Copyright (c) 2014-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
4 #ifndef TOR_KEYPIN_H
5 #define TOR_KEYPIN_H
6 
8 
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);
14 int keypin_close_journal(void);
15 
16 #ifdef HAVE_MODULE_DIRAUTH
17 int keypin_open_journal(const char *fname);
18 int keypin_load_journal(const char *fname);
19 #else
20 static inline int
21 keypin_open_journal(const char *fname)
22 {
23  (void)fname;
24  return 0;
25 }
26 static inline int
27 keypin_load_journal(const char *fname)
28 {
29  (void)fname;
30  return 0;
31 }
32 #endif /* defined(HAVE_MODULE_DIRAUTH) */
33 void keypin_clear(void);
34 int keypin_check_lone_rsa(const uint8_t *rsa_id_digest);
35 
36 #define KEYPIN_FOUND 0
37 #define KEYPIN_ADDED 1
38 #define KEYPIN_MISMATCH -1
39 #define KEYPIN_NOT_FOUND -2
40 
41 #ifdef KEYPIN_PRIVATE
42 
46 typedef struct keypin_ent_st {
47  HT_ENTRY(keypin_ent_st) rsamap_node;
48  HT_ENTRY(keypin_ent_st) edmap_node;
50  uint8_t rsa_id[DIGEST_LEN];
52  uint8_t ed25519_key[DIGEST256_LEN];
53 } keypin_ent_t;
54 
55 STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp);
56 STATIC int keypin_load_journal_impl(const char *data, size_t size);
57 
58 MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
59 #endif /* defined(KEYPIN_PRIVATE) */
60 
61 #endif /* !defined(TOR_KEYPIN_H) */
STATIC int keypin_load_journal_impl(const char *data, size_t size)
Definition: keypin.c:378
void keypin_clear(void)
Definition: keypin.c:491
int keypin_check(const uint8_t *rsa_id_digest, const uint8_t *ed25519_id_key)
Definition: keypin.c:157
int keypin_load_journal(const char *fname)
Definition: keypin.c:452
#define DIGEST256_LEN
Definition: digest_sizes.h:23
int keypin_close_journal(void)
Definition: keypin.c:339
STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp)
Definition: keypin.c:472
#define DIGEST_LEN
Definition: digest_sizes.h:20
int keypin_open_journal(const char *fname)
Definition: keypin.c:305
int keypin_check_lone_rsa(const uint8_t *rsa_id_digest)
Definition: keypin.c:284
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94