keypin.h 1.1 KB

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