aboutsummaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-03-10 12:56:36 +0100
committerNick Mathewson <nickm@torproject.org>2017-03-17 11:15:43 -0400
commitd88f10cdf2cc0682e607de5f63ebae9370c5fe55 (patch)
treef250fb219a10a4a546892e991444e4ddb3e435eb /src/or/router.c
parent23ae5b655b9d94d62c6c9296cb8cc2b33ae345d7 (diff)
downloadtor-d88f10cdf2cc0682e607de5f63ebae9370c5fe55.tar.gz
tor-d88f10cdf2cc0682e607de5f63ebae9370c5fe55.zip
Add API to query the current onion key grace period.
This patch adds an API to get the current grace period, in days, defined as the consensus parameter "onion-key-grace-period-days". As per proposal #274 the values for "onion-key-grace-period-days" is a default value of 7 days, a minimum value of 1 day, and a maximum value defined by other consensus parameter "onion-key-rotation-days" also defined in days. See: https://bugs.torproject.org/21641
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 1fa0f10b7e..2985753226 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -708,6 +708,22 @@ get_onion_key_lifetime(void)
return get_onion_key_rotation_days_()*24*60*60;
}
+/** Get the grace period of an onion key in seconds. This value is defined by
+ * the network consesus parameter "onion-key-grace-period-days", but the value
+ * is converted to seconds.
+ */
+int
+get_onion_key_grace_period(void)
+{
+ int grace_period;
+ grace_period = networkstatus_get_param(NULL,
+ "onion-key-grace-period-days",
+ DEFAULT_ONION_KEY_GRACE_PERIOD_DAYS,
+ MIN_ONION_KEY_GRACE_PERIOD_DAYS,
+ get_onion_key_rotation_days_());
+ return grace_period*24*60*60;
+}
+
/** Set up Tor's TLS contexts, based on our configuration and keys. Return 0
* on success, and -1 on failure. */
int