keypin.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright (c) 2014-2016, 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. const int replace_existing_entry);
  9. int keypin_check(const uint8_t *rsa_id_digest,
  10. const uint8_t *ed25519_id_key);
  11. int keypin_open_journal(const char *fname);
  12. int keypin_close_journal(void);
  13. int keypin_load_journal(const char *fname);
  14. void keypin_clear(void);
  15. int keypin_check_lone_rsa(const uint8_t *rsa_id_digest);
  16. #define KEYPIN_FOUND 0
  17. #define KEYPIN_ADDED 1
  18. #define KEYPIN_MISMATCH -1
  19. #define KEYPIN_NOT_FOUND -2
  20. #ifdef KEYPIN_PRIVATE
  21. /**
  22. * In-memory representation of a key-pinning table entry.
  23. */
  24. typedef struct keypin_ent_st {
  25. HT_ENTRY(keypin_ent_st) rsamap_node;
  26. HT_ENTRY(keypin_ent_st) edmap_node;
  27. /** SHA1 hash of the RSA key */
  28. uint8_t rsa_id[DIGEST_LEN];
  29. /** Ed2219 key. */
  30. uint8_t ed25519_key[DIGEST256_LEN];
  31. } keypin_ent_t;
  32. STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp);
  33. STATIC int keypin_load_journal_impl(const char *data, size_t size);
  34. MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
  35. #endif
  36. #endif