routerkeys.h 3.7 KB

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