Cache control file
[tor/appveyor.git] / src / or / routerkeys.h
blob3e67952ea08784bc556acc83e43d31c9a0632ce6
1 /* Copyright (c) 2014-2017, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 #ifndef TOR_ROUTERKEYS_H
5 #define TOR_ROUTERKEYS_H
7 #include "crypto_ed25519.h"
9 #define INIT_ED_KEY_CREATE (1u<<0)
10 #define INIT_ED_KEY_REPLACE (1u<<1)
11 #define INIT_ED_KEY_SPLIT (1u<<2)
12 #define INIT_ED_KEY_MISSING_SECRET_OK (1u<<3)
13 #define INIT_ED_KEY_NEEDCERT (1u<<4)
14 #define INIT_ED_KEY_EXTRA_STRONG (1u<<5)
15 #define INIT_ED_KEY_INCLUDE_SIGNING_KEY_IN_CERT (1u<<6)
16 #define INIT_ED_KEY_OMIT_SECRET (1u<<7)
17 #define INIT_ED_KEY_TRY_ENCRYPTED (1u<<8)
18 #define INIT_ED_KEY_NO_REPAIR (1u<<9)
19 #define INIT_ED_KEY_SUGGEST_KEYGEN (1u<<10)
20 #define INIT_ED_KEY_OFFLINE_SECRET (1u<<11)
21 #define INIT_ED_KEY_EXPLICIT_FNAME (1u<<12)
23 struct tor_cert_st;
24 ed25519_keypair_t *ed_key_init_from_file(const char *fname, uint32_t flags,
25 int severity,
26 const ed25519_keypair_t *signing_key,
27 time_t now,
28 time_t lifetime,
29 uint8_t cert_type,
30 struct tor_cert_st **cert_out);
31 ed25519_keypair_t *ed_key_new(const ed25519_keypair_t *signing_key,
32 uint32_t flags,
33 time_t now,
34 time_t lifetime,
35 uint8_t cert_type,
36 struct tor_cert_st **cert_out);
37 const ed25519_public_key_t *get_master_identity_key(void);
38 const ed25519_keypair_t *get_master_signing_keypair(void);
39 const struct tor_cert_st *get_master_signing_key_cert(void);
41 const ed25519_keypair_t *get_current_auth_keypair(void);
42 const struct tor_cert_st *get_current_link_cert_cert(void);
43 const struct tor_cert_st *get_current_auth_key_cert(void);
45 void get_master_rsa_crosscert(const uint8_t **cert_out,
46 size_t *size_out);
48 int router_ed25519_id_is_me(const ed25519_public_key_t *id);
50 struct tor_cert_st *make_ntor_onion_key_crosscert(
51 const curve25519_keypair_t *onion_key,
52 const ed25519_public_key_t *master_id_key,
53 time_t now, time_t lifetime,
54 int *sign_out);
55 uint8_t *make_tap_onion_key_crosscert(const crypto_pk_t *onion_key,
56 const ed25519_public_key_t *master_id_key,
57 const crypto_pk_t *rsa_id_key,
58 int *len_out);
60 MOCK_DECL(int, check_tap_onion_key_crosscert,(const uint8_t *crosscert,
61 int crosscert_len,
62 const crypto_pk_t *onion_pkey,
63 const ed25519_public_key_t *master_id_pkey,
64 const uint8_t *rsa_id_digest));
66 int log_cert_expiration(void);
67 int load_ed_keys(const or_options_t *options, time_t now);
68 int should_make_new_ed_keys(const or_options_t *options, const time_t now);
70 int generate_ed_link_cert(const or_options_t *options, time_t now, int force);
72 int read_encrypted_secret_key(ed25519_secret_key_t *out,
73 const char *fname);
74 int write_encrypted_secret_key(const ed25519_secret_key_t *out,
75 const char *fname);
77 void routerkeys_free_all(void);
79 #ifdef TOR_UNIT_TESTS
80 const ed25519_keypair_t *get_master_identity_keypair(void);
81 void init_mock_ed_keys(const crypto_pk_t *rsa_identity_key);
82 #endif
84 #endif /* !defined(TOR_ROUTERKEYS_H) */