summaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 0339e682a8..d86c5f3e39 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -47,28 +47,28 @@ extern long stats_n_seconds_working;
static tor_mutex_t *key_lock=NULL;
static time_t onionkey_set_at=0; /**< When was onionkey last changed? */
/** Current private onionskin decryption key: used to decode CREATE cells. */
-static crypto_pk_env_t *onionkey=NULL;
+static crypto_pk_t *onionkey=NULL;
/** Previous private onionskin decryption key: used to decode CREATE cells
* generated by clients that have an older version of our descriptor. */
-static crypto_pk_env_t *lastonionkey=NULL;
+static crypto_pk_t *lastonionkey=NULL;
/** Private server "identity key": used to sign directory info and TLS
* certificates. Never changes. */
-static crypto_pk_env_t *server_identitykey=NULL;
+static crypto_pk_t *server_identitykey=NULL;
/** Digest of server_identitykey. */
static char server_identitykey_digest[DIGEST_LEN];
/** Private client "identity key": used to sign bridges' and clients'
* outbound TLS certificates. Regenerated on startup and on IP address
* change. */
-static crypto_pk_env_t *client_identitykey=NULL;
+static crypto_pk_t *client_identitykey=NULL;
/** Signing key used for v3 directory material; only set for authorities. */
-static crypto_pk_env_t *authority_signing_key = NULL;
+static crypto_pk_t *authority_signing_key = NULL;
/** Key certificate to authenticate v3 directory material; only set for
* authorities. */
static authority_cert_t *authority_key_certificate = NULL;
/** For emergency V3 authority key migration: An extra signing key that we use
* with our old (obsolete) identity key for a while. */
-static crypto_pk_env_t *legacy_signing_key = NULL;
+static crypto_pk_t *legacy_signing_key = NULL;
/** For emergency V3 authority key migration: An extra certificate to
* authenticate legacy_signing_key with our obsolete identity key.*/
static authority_cert_t *legacy_key_certificate = NULL;
@@ -82,15 +82,15 @@ static authority_cert_t *legacy_key_certificate = NULL;
* lastonionkey; to update lastonionkey correctly, call rotate_onion_key().
*/
static void
-set_onion_key(crypto_pk_env_t *k)
+set_onion_key(crypto_pk_t *k)
{
if (onionkey && !crypto_pk_cmp_keys(onionkey, k)) {
/* k is already our onion key; free it and return */
- crypto_free_pk_env(k);
+ crypto_pk_free(k);
return;
}
tor_mutex_acquire(key_lock);
- crypto_free_pk_env(onionkey);
+ crypto_pk_free(onionkey);
onionkey = k;
tor_mutex_release(key_lock);
mark_my_descriptor_dirty("set onion key");
@@ -98,7 +98,7 @@ set_onion_key(crypto_pk_env_t *k)
/** Return the current onion key. Requires that the onion key has been
* loaded or generated. */
-crypto_pk_env_t *
+crypto_pk_t *
get_onion_key(void)
{
tor_assert(onionkey);
@@ -109,7 +109,7 @@ get_onion_key(void)
* copy of the most recent onion key into *<b>last</b>.
*/
void
-dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last)
+dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last)
{
tor_assert(key);
tor_assert(last);
@@ -136,9 +136,9 @@ get_onion_key_set_at(void)
/** Set the current server identity key to <b>k</b>.
*/
void
-set_server_identity_key(crypto_pk_env_t *k)
+set_server_identity_key(crypto_pk_t *k)
{
- crypto_free_pk_env(server_identitykey);
+ crypto_pk_free(server_identitykey);
server_identitykey = k;
crypto_pk_get_digest(server_identitykey, server_identitykey_digest);
}
@@ -164,7 +164,7 @@ assert_identity_keys_ok(void)
/** Returns the current server identity key; requires that the key has
* been set, and that we are running as a Tor server.
*/
-crypto_pk_env_t *
+crypto_pk_t *
get_server_identity_key(void)
{
tor_assert(server_identitykey);
@@ -183,16 +183,16 @@ server_identity_key_is_set(void)
/** Set the current client identity key to <b>k</b>.
*/
void
-set_client_identity_key(crypto_pk_env_t *k)
+set_client_identity_key(crypto_pk_t *k)
{
- crypto_free_pk_env(client_identitykey);
+ crypto_pk_free(client_identitykey);
client_identitykey = k;
}
/** Returns the current client identity key for use on outgoing TLS
* connections; requires that the key has been set.
*/
-crypto_pk_env_t *
+crypto_pk_t *
get_tlsclient_identity_key(void)
{
tor_assert(client_identitykey);
@@ -217,7 +217,7 @@ get_my_v3_authority_cert(void)
/** Return the v3 signing key for this v3 (voting) authority, or NULL
* if we have no such key. */
-crypto_pk_env_t *
+crypto_pk_t *
get_my_v3_authority_signing_key(void)
{
return authority_signing_key;
@@ -234,7 +234,7 @@ get_my_v3_legacy_cert(void)
/** If we're an authority, and we're using a legacy authority identity key for
* emergency migration purposes, return that key. */
-crypto_pk_env_t *
+crypto_pk_t *
get_my_v3_legacy_signing_key(void)
{
return legacy_signing_key;
@@ -251,12 +251,12 @@ void
rotate_onion_key(void)
{
char *fname, *fname_prev;
- crypto_pk_env_t *prkey;
+ crypto_pk_t *prkey;
or_state_t *state = get_or_state();
time_t now;
fname = get_datadir_fname2("keys", "secret_onion_key");
fname_prev = get_datadir_fname2("keys", "secret_onion_key.old");
- if (!(prkey = crypto_new_pk_env())) {
+ if (!(prkey = crypto_pk_new())) {
log_err(LD_GENERAL,"Error constructing rotated onion key");
goto error;
}
@@ -274,7 +274,7 @@ rotate_onion_key(void)
}
log_info(LD_GENERAL, "Rotating onion key");
tor_mutex_acquire(key_lock);
- crypto_free_pk_env(lastonionkey);
+ crypto_pk_free(lastonionkey);
lastonionkey = onionkey;
onionkey = prkey;
now = time(NULL);
@@ -286,7 +286,7 @@ rotate_onion_key(void)
error:
log_warn(LD_GENERAL, "Couldn't rotate onion key.");
if (prkey)
- crypto_free_pk_env(prkey);
+ crypto_pk_free(prkey);
done:
tor_free(fname);
tor_free(fname_prev);
@@ -297,12 +297,12 @@ rotate_onion_key(void)
* <b>fname</b>. Return the read/created key, or NULL on error. Log all
* errors at level <b>severity</b>.
*/
-crypto_pk_env_t *
+crypto_pk_t *
init_key_from_file(const char *fname, int generate, int severity)
{
- crypto_pk_env_t *prkey = NULL;
+ crypto_pk_t *prkey = NULL;
- if (!(prkey = crypto_new_pk_env())) {
+ if (!(prkey = crypto_pk_new())) {
log(severity, LD_GENERAL,"Error constructing key");
goto error;
}
@@ -357,7 +357,7 @@ init_key_from_file(const char *fname, int generate, int severity)
error:
if (prkey)
- crypto_free_pk_env(prkey);
+ crypto_pk_free(prkey);
return NULL;
}
@@ -367,13 +367,13 @@ init_key_from_file(const char *fname, int generate, int severity)
* key/cert set. On success, store them into *<b>key_out</b> and
* *<b>cert_out</b> respectively, and return 0. On failure, return -1. */
static int
-load_authority_keyset(int legacy, crypto_pk_env_t **key_out,
+load_authority_keyset(int legacy, crypto_pk_t **key_out,
authority_cert_t **cert_out)
{
int r = -1;
char *fname = NULL, *cert = NULL;
const char *eos = NULL;
- crypto_pk_env_t *signing_key = NULL;
+ crypto_pk_t *signing_key = NULL;
authority_cert_t *parsed = NULL;
fname = get_datadir_fname2("keys",
@@ -403,7 +403,7 @@ load_authority_keyset(int legacy, crypto_pk_env_t **key_out,
goto done;
}
- crypto_free_pk_env(*key_out);
+ crypto_pk_free(*key_out);
authority_cert_free(*cert_out);
*key_out = signing_key;
@@ -415,7 +415,7 @@ load_authority_keyset(int legacy, crypto_pk_env_t **key_out,
done:
tor_free(fname);
tor_free(cert);
- crypto_free_pk_env(signing_key);
+ crypto_pk_free(signing_key);
authority_cert_free(parsed);
return r;
}
@@ -506,7 +506,7 @@ init_keys(void)
/*nickname<space>fp\n\0 */
char fingerprint_line[MAX_NICKNAME_LEN+FINGERPRINT_LEN+3];
const char *mydesc;
- crypto_pk_env_t *prkey;
+ crypto_pk_t *prkey;
char digest[DIGEST_LEN];
char v3_digest[DIGEST_LEN];
char *cp;
@@ -532,10 +532,10 @@ init_keys(void)
/* OP's don't need persistent keys; just make up an identity and
* initialize the TLS context. */
if (!server_mode(options)) {
- if (!(prkey = crypto_new_pk_env()))
+ if (!(prkey = crypto_pk_new()))
return -1;
if (crypto_pk_generate_key(prkey)) {
- crypto_free_pk_env(prkey);
+ crypto_pk_free(prkey);
return -1;
}
set_client_identity_key(prkey);
@@ -589,10 +589,10 @@ init_keys(void)
if (public_server_mode(options)) {
set_client_identity_key(crypto_pk_dup_key(prkey)); /* set above */
} else {
- if (!(prkey = crypto_new_pk_env()))
+ if (!(prkey = crypto_pk_new()))
return -1;
if (crypto_pk_generate_key(prkey)) {
- crypto_free_pk_env(prkey);
+ crypto_pk_free(prkey);
return -1;
}
set_client_identity_key(prkey);
@@ -1566,9 +1566,9 @@ router_rebuild_descriptor(int force)
if (options->MyFamily) {
smartlist_t *family;
if (!warned_nonexistent_family)
- warned_nonexistent_family = smartlist_create();
- family = smartlist_create();
- ri->declared_family = smartlist_create();
+ warned_nonexistent_family = smartlist_new();
+ family = smartlist_new();
+ ri->declared_family = smartlist_new();
smartlist_split_string(family, options->MyFamily, ",",
SPLIT_SKIP_SPACE|SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
SMARTLIST_FOREACH_BEGIN(family, char *, name) {
@@ -1924,7 +1924,7 @@ get_platform_str(char *platform, size_t len)
*/
int
router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
- crypto_pk_env_t *ident_key)
+ crypto_pk_t *ident_key)
{
char *onion_pkey; /* Onion key, PEM-encoded. */
char *identity_pkey; /* Identity key, PEM-encoded. */
@@ -2238,7 +2238,7 @@ load_stats_file(const char *filename, const char *end_line, time_t now,
* success, negative on failure. */
int
extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
- crypto_pk_env_t *ident_key)
+ crypto_pk_t *ident_key)
{
const or_options_t *options = get_options();
char identity[HEX_DIGEST_LEN+1];
@@ -2250,7 +2250,7 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
char sig[DIROBJ_MAX_SIG_LEN+1];
char *s, *pre, *contents, *cp, *s_dup = NULL;
time_t now = time(NULL);
- smartlist_t *chunks = smartlist_create();
+ smartlist_t *chunks = smartlist_new();
extrainfo_t *ei_tmp = NULL;
base16_encode(identity, sizeof(identity),
@@ -2688,16 +2688,16 @@ router_purpose_from_string(const char *s)
void
router_free_all(void)
{
- crypto_free_pk_env(onionkey);
- crypto_free_pk_env(lastonionkey);
- crypto_free_pk_env(server_identitykey);
- crypto_free_pk_env(client_identitykey);
+ crypto_pk_free(onionkey);
+ crypto_pk_free(lastonionkey);
+ crypto_pk_free(server_identitykey);
+ crypto_pk_free(client_identitykey);
tor_mutex_free(key_lock);
routerinfo_free(desc_routerinfo);
extrainfo_free(desc_extrainfo);
- crypto_free_pk_env(authority_signing_key);
+ crypto_pk_free(authority_signing_key);
authority_cert_free(authority_key_certificate);
- crypto_free_pk_env(legacy_signing_key);
+ crypto_pk_free(legacy_signing_key);
authority_cert_free(legacy_key_certificate);
if (warned_nonexistent_family) {