tor/src/or/keypin.h
Nick Mathewson 592a439107 Tie key-pinning logic into directory authority operation
With this patch:
  * Authorities load the key-pinning log at startup.
  * Authorities open a key-pinning log for writing at startup.
  * Authorities reject any router with an ed25519 key where they have
    previously seen that ed25519 key with a different RSA key, or vice
    versa.
  * Authorities warn about, but *do not* reject, RSA-only descriptors
    when the RSA key has previously gone along with an Ed25519 key.
    (We should make this a 'reject' too, but we can't do that until we're
    sure there's no legit reason to downgrade to 0.2.5.)
2015-05-28 10:41:49 -04:00

47 lines
1.2 KiB
C

/* Copyright (c) 2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_KEYPIN_H
#define TOR_KEYPIN_H
#include "testsupport.h"
int keypin_check_and_add(const uint8_t *rsa_id_digest,
const uint8_t *ed25519_id_key);
int keypin_check(const uint8_t *rsa_id_digest,
const uint8_t *ed25519_id_key);
int keypin_open_journal(const char *fname);
int keypin_close_journal(void);
int keypin_load_journal(const char *fname);
void keypin_clear(void);
int keypin_check_lone_rsa(const uint8_t *rsa_id_digest);
#define KEYPIN_FOUND 0
#define KEYPIN_ADDED 1
#define KEYPIN_MISMATCH -1
#define KEYPIN_NOT_FOUND -2
#ifdef KEYPIN_PRIVATE
/**
* In-memory representation of a key-pinning table entry.
*/
typedef struct keypin_ent_st {
HT_ENTRY(keypin_ent_st) rsamap_node;
HT_ENTRY(keypin_ent_st) edmap_node;
/** SHA1 hash of the RSA key */
uint8_t rsa_id[DIGEST_LEN];
/** Ed2219 key. */
uint8_t ed25519_key[DIGEST256_LEN];
} keypin_ent_t;
STATIC keypin_ent_t * keypin_parse_journal_line(const char *cp);
STATIC int keypin_load_journal_impl(const char *data, size_t size);
MOCK_DECL(STATIC void, keypin_add_entry_to_map, (keypin_ent_t *ent));
#endif
#endif