tor  0.4.1.0-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 
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);
20 
21 #define KEYPIN_FOUND 0
22 #define KEYPIN_ADDED 1
23 #define KEYPIN_MISMATCH -1
24 #define KEYPIN_NOT_FOUND -2
25 
26 #ifdef KEYPIN_PRIVATE
27 
31 typedef struct keypin_ent_st {
32  HT_ENTRY(keypin_ent_st) rsamap_node;
33  HT_ENTRY(keypin_ent_st) edmap_node;
35  uint8_t rsa_id[DIGEST_LEN];
37  uint8_t ed25519_key[DIGEST256_LEN];
38 } keypin_ent_t;
39 
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);
42 
43 MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
44 #endif /* defined(KEYPIN_PRIVATE) */
45 
46 #endif /* !defined(TOR_KEYPIN_H) */
47 
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