keypin.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (c) 2014, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. #ifndef TOR_KEYPIN_H
  4. #define TOR_KEYPIN_H
  5. #include "testsupport.h"
  6. int keypin_check_and_add(const uint8_t *rsa_id_digest,
  7. const uint8_t *ed25519_id_key);
  8. int keypin_check(const uint8_t *rsa_id_digest,
  9. const uint8_t *ed25519_id_key);
  10. int keypin_open_journal(const char *fname);
  11. int keypin_close_journal(void);
  12. int keypin_load_journal(const char *fname);
  13. void keypin_clear(void);
  14. int keypin_check_lone_rsa(const uint8_t *rsa_id_digest);
  15. #define KEYPIN_FOUND 0
  16. #define KEYPIN_ADDED 1
  17. #define KEYPIN_MISMATCH -1
  18. #define KEYPIN_NOT_FOUND -2
  19. #ifdef KEYPIN_PRIVATE
  20. /**
  21. * In-memory representation of a key-pinning table entry.
  22. */
  23. typedef struct keypin_ent_st {
  24. HT_ENTRY(keypin_ent_st) rsamap_node;
  25. HT_ENTRY(keypin_ent_st) edmap_node;
  26. /** SHA1 hash of the RSA key */
  27. uint8_t rsa_id[DIGEST_LEN];
  28. /** Ed2219 key. */
  29. uint8_t ed25519_key[DIGEST256_LEN];
  30. } keypin_ent_t;
  31. STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp);
  32. STATIC int keypin_load_journal_impl(const char *data, size_t size);
  33. MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
  34. #endif
  35. #endif