routerkeys.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Copyright (c) 2014, 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. struct tor_cert_st;
  17. ed25519_keypair_t *ed_key_init_from_file(const char *fname, uint32_t flags,
  18. int severity,
  19. const ed25519_keypair_t *signing_key,
  20. time_t now,
  21. time_t lifetime,
  22. uint8_t cert_type,
  23. struct tor_cert_st **cert_out);
  24. ed25519_keypair_t *ed_key_new(const ed25519_keypair_t *signing_key,
  25. uint32_t flags,
  26. time_t now,
  27. time_t lifetime,
  28. uint8_t cert_type,
  29. struct tor_cert_st **cert_out);
  30. const ed25519_public_key_t *get_master_identity_key(void);
  31. const ed25519_keypair_t *get_master_signing_keypair(void);
  32. const struct tor_cert_st *get_master_signing_key_cert(void);
  33. const ed25519_keypair_t *get_current_auth_keypair(void);
  34. const struct tor_cert_st *get_current_link_cert_cert(void);
  35. const struct tor_cert_st *get_current_auth_key_cert(void);
  36. void get_master_rsa_crosscert(const uint8_t **cert_out,
  37. size_t *size_out);
  38. struct tor_cert_st *make_ntor_onion_key_crosscert(
  39. const curve25519_keypair_t *onion_key,
  40. const ed25519_public_key_t *master_id_key,
  41. time_t now, time_t lifetime,
  42. int *sign_out);
  43. uint8_t *make_tap_onion_key_crosscert(const crypto_pk_t *onion_key,
  44. const ed25519_public_key_t *master_id_key,
  45. const crypto_pk_t *rsa_id_key,
  46. int *len_out);
  47. int check_tap_onion_key_crosscert(const uint8_t *crosscert,
  48. int crosscert_len,
  49. const crypto_pk_t *onion_pkey,
  50. const ed25519_public_key_t *master_id_pkey,
  51. const uint8_t *rsa_id_digest);
  52. int load_ed_keys(const or_options_t *options, time_t now);
  53. int should_make_new_ed_keys(const or_options_t *options, const time_t now);
  54. int generate_ed_link_cert(const or_options_t *options, time_t now);
  55. int read_encrypted_secret_key(ed25519_secret_key_t *out,
  56. const char *fname);
  57. int write_encrypted_secret_key(const ed25519_secret_key_t *out,
  58. const char *fname);
  59. void routerkeys_free_all(void);
  60. #endif