tor-commits
Threads by month
- ----- 2025 -----
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
October 2016
- 18 participants
- 868 discussions
commit cb63919b6b19d83c686f5df8b550ed2acf1b2143
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sat Oct 22 11:59:30 2016 -0700
Allow the data directory to be set
Our 'startup.data_directory' nyxrc option was no longer wired up. Allowing
users to set it. Presently this is only used for the manual info cache but
we'll likely cache more there later.
---
nyx/__init__.py | 2 +-
nyx/arguments.py | 4 ++--
nyx/panel/config.py | 5 +++--
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/nyx/__init__.py b/nyx/__init__.py
index 740685d..75dde99 100644
--- a/nyx/__init__.py
+++ b/nyx/__init__.py
@@ -85,7 +85,7 @@ CONFIG = stem.util.conf.config_dict('nyx', {
NYX_INTERFACE = None
TOR_CONTROLLER = None
BASE_DIR = os.path.sep.join(__file__.split(os.path.sep)[:-1])
-DATA_DIR = os.path.expanduser('~/.nyx')
+DEFAULT_DATA_DIR = os.path.expanduser('~/.nyx')
TESTING = False
# technically can change but we use this query a *lot* so needs to be cached
diff --git a/nyx/arguments.py b/nyx/arguments.py
index bb0939e..9b53e35 100644
--- a/nyx/arguments.py
+++ b/nyx/arguments.py
@@ -14,7 +14,7 @@ import nyx.log
import stem.util.connection
-from nyx import DATA_DIR, msg
+from nyx import DEFAULT_DATA_DIR, msg
DEFAULT_ARGS = {
'control_address': '127.0.0.1',
@@ -22,7 +22,7 @@ DEFAULT_ARGS = {
'user_provided_port': False,
'control_socket': '/var/run/tor/control',
'user_provided_socket': False,
- 'config': os.path.join(DATA_DIR, 'nyxrc'),
+ 'config': os.path.join(DEFAULT_DATA_DIR, 'nyxrc'),
'debug_path': None,
'logged_events': 'NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR',
'print_version': False,
diff --git a/nyx/panel/config.py b/nyx/panel/config.py
index 3c0cc18..8390ac5 100644
--- a/nyx/panel/config.py
+++ b/nyx/panel/config.py
@@ -19,7 +19,7 @@ import stem.util.connection
from nyx.curses import WHITE, NORMAL, BOLD, HIGHLIGHT
from nyx.menu import MenuItem, Submenu
-from nyx import DATA_DIR, tor_controller, input_prompt, show_message
+from nyx import DEFAULT_DATA_DIR, tor_controller, input_prompt, show_message
from stem.util import conf, enum, log, str_tools
@@ -41,6 +41,7 @@ CONFIG = conf.config_dict('nyx', {
'features.config.order': [SortAttr.MAN_PAGE_ENTRY, SortAttr.NAME, SortAttr.IS_SET],
'features.config.state.showPrivateOptions': False,
'features.config.state.showVirtualOptions': False,
+ 'startup.data_directory': DEFAULT_DATA_DIR,
}, conf_handler)
@@ -130,7 +131,7 @@ class ConfigPanel(nyx.panel.Panel):
self._sort_order = CONFIG['features.config.order']
self._show_all = False # show all options, or just the important ones
- cached_manual_path = os.path.join(DATA_DIR, 'manual')
+ cached_manual_path = os.path.join(CONFIG['startup.data_directory'], 'manual')
if os.path.exists(cached_manual_path):
manual = stem.manual.Manual.from_cache(cached_manual_path)
1
0
commit 774ed43694a0130c55b750fad581532c55d44364
Author: Damian Johnson <atagar(a)torproject.org>
Date: Sat Oct 22 12:16:15 2016 -0700
Let users disable on-disk caching
Some users may not want us to cache information to disk. Including a nyxrc
option to disable this.
Also shortening these option names. Plan is for user-facing nyxrc options to be
short, while internal options use namespacing.
---
nyx/__init__.py | 7 ++++++-
nyx/arguments.py | 4 ++--
nyx/panel/config.py | 28 +++++++++++++++-------------
nyx/panel/log.py | 4 ++--
nyx/starter.py | 2 +-
nyxrc.sample | 12 +++++++++---
6 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/nyx/__init__.py b/nyx/__init__.py
index 75dde99..a66c95b 100644
--- a/nyx/__init__.py
+++ b/nyx/__init__.py
@@ -85,7 +85,6 @@ CONFIG = stem.util.conf.config_dict('nyx', {
NYX_INTERFACE = None
TOR_CONTROLLER = None
BASE_DIR = os.path.sep.join(__file__.split(os.path.sep)[:-1])
-DEFAULT_DATA_DIR = os.path.expanduser('~/.nyx')
TESTING = False
# technically can change but we use this query a *lot* so needs to be cached
@@ -238,6 +237,12 @@ def init_controller(*args, **kwargs):
@uses_settings
+def data_directory(config):
+ path = config.get('data_directory', '~/.nyx')
+ return None if path == 'disabled' else os.path.expanduser(path)
+
+
+@uses_settings
def expand_path(path, config):
"""
Expands relative paths and include our chroot if one was set.
diff --git a/nyx/arguments.py b/nyx/arguments.py
index 9b53e35..efb95ee 100644
--- a/nyx/arguments.py
+++ b/nyx/arguments.py
@@ -14,7 +14,7 @@ import nyx.log
import stem.util.connection
-from nyx import DEFAULT_DATA_DIR, msg
+from nyx import msg
DEFAULT_ARGS = {
'control_address': '127.0.0.1',
@@ -22,7 +22,7 @@ DEFAULT_ARGS = {
'user_provided_port': False,
'control_socket': '/var/run/tor/control',
'user_provided_socket': False,
- 'config': os.path.join(DEFAULT_DATA_DIR, 'nyxrc'),
+ 'config': os.path.join(os.path.expanduser('~/.nyx'), 'nyxrc'),
'debug_path': None,
'logged_events': 'NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR',
'print_version': False,
diff --git a/nyx/panel/config.py b/nyx/panel/config.py
index 8390ac5..0f454f3 100644
--- a/nyx/panel/config.py
+++ b/nyx/panel/config.py
@@ -19,7 +19,7 @@ import stem.util.connection
from nyx.curses import WHITE, NORMAL, BOLD, HIGHLIGHT
from nyx.menu import MenuItem, Submenu
-from nyx import DEFAULT_DATA_DIR, tor_controller, input_prompt, show_message
+from nyx import tor_controller, data_directory, input_prompt, show_message
from stem.util import conf, enum, log, str_tools
@@ -41,7 +41,6 @@ CONFIG = conf.config_dict('nyx', {
'features.config.order': [SortAttr.MAN_PAGE_ENTRY, SortAttr.NAME, SortAttr.IS_SET],
'features.config.state.showPrivateOptions': False,
'features.config.state.showVirtualOptions': False,
- 'startup.data_directory': DEFAULT_DATA_DIR,
}, conf_handler)
@@ -131,21 +130,24 @@ class ConfigPanel(nyx.panel.Panel):
self._sort_order = CONFIG['features.config.order']
self._show_all = False # show all options, or just the important ones
- cached_manual_path = os.path.join(CONFIG['startup.data_directory'], 'manual')
+ data_dir = data_directory()
- if os.path.exists(cached_manual_path):
- manual = stem.manual.Manual.from_cache(cached_manual_path)
- else:
- try:
- manual = stem.manual.Manual.from_man()
+ if data_dir:
+ cached_manual_path = os.path.join(data_dir, 'manual')
+ if os.path.exists(cached_manual_path):
+ manual = stem.manual.Manual.from_cache(cached_manual_path)
+ else:
try:
- manual.save(cached_manual_path)
+ manual = stem.manual.Manual.from_man()
+
+ try:
+ manual.save(cached_manual_path)
+ except IOError as exc:
+ log.debug("Unable to cache manual information to '%s'. This is fine, but means starting Nyx takes a little longer than usual: " % (cached_manual_path, exc))
except IOError as exc:
- log.debug("Unable to cache manual information to '%s'. This is fine, but means starting Nyx takes a little longer than usual: " % (cached_manual_path, exc))
- except IOError as exc:
- log.debug("Unable to use 'man tor' to get information about config options (%s), using bundled information instead" % exc)
- manual = stem.manual.Manual.from_cache()
+ log.debug("Unable to use 'man tor' to get information about config options (%s), using bundled information instead" % exc)
+ manual = stem.manual.Manual.from_cache()
try:
for line in tor_controller().get_info('config/names').splitlines():
diff --git a/nyx/panel/log.py b/nyx/panel/log.py
index 10e2645..6e1d14d 100644
--- a/nyx/panel/log.py
+++ b/nyx/panel/log.py
@@ -40,7 +40,7 @@ CONFIG = conf.config_dict('nyx', {
'features.log.prepopulate': True,
'features.log.prepopulateReadLimit': 5000,
'features.log.regex': [],
- 'startup.events': 'NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR',
+ 'logged_events': 'NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR',
}, conf_handler)
UPDATE_RATE = 0.3
@@ -69,7 +69,7 @@ class LogPanel(nyx.panel.DaemonPanel):
def __init__(self):
nyx.panel.DaemonPanel.__init__(self, UPDATE_RATE)
- logged_events = CONFIG['startup.events'].split(',')
+ logged_events = CONFIG['logged_events'].split(',')
tor_events = tor_controller().get_info('events/names', '').split()
invalid_events = list(filter(lambda event: not event.startswith('NYX_') and event not in tor_events, logged_events))
diff --git a/nyx/starter.py b/nyx/starter.py
index dbb6d8c..d23e157 100644
--- a/nyx/starter.py
+++ b/nyx/starter.py
@@ -32,7 +32,7 @@ def main(config):
try:
args = nyx.arguments.parse(sys.argv[1:])
- config.set('startup.events', args.logged_events)
+ config.set('logged_events', args.logged_events)
except ValueError as exc:
print(exc)
sys.exit(1)
diff --git a/nyxrc.sample b/nyxrc.sample
index c9ff604..bbce437 100644
--- a/nyxrc.sample
+++ b/nyxrc.sample
@@ -1,6 +1,12 @@
-# Startup options
-startup.events N3
-startup.dataDirectory ~/.nyx
+# Events that are shown by default in the log. You can also set these with
+# 'nyx --log <events>'.
+
+logged_events NOTICE,WARN,ERR,NYX_NOTICE,NYX_WARNING,NYX_ERROR
+
+# Location where information is cached. You can disable caching by setting this
+# to 'disabled'.
+
+data_directory ~/.nyx
# Seconds between querying information
1
0
commit 206a9726b112d674b712949fadc653def57f427b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Oct 26 11:06:45 2016 -0400
Regenerate trunnel code with trunnel 1.5
---
src/ext/trunnel/trunnel-impl.h | 3 +-
src/ext/trunnel/trunnel.c | 2 +-
src/ext/trunnel/trunnel.h | 2 +-
src/trunnel/ed25519_cert.c | 58 +++++++++++-
src/trunnel/ed25519_cert.h | 44 ++++++++-
src/trunnel/link_handshake.c | 196 ++++++++++++++++++++++++++++++++++++++---
src/trunnel/link_handshake.h | 134 +++++++++++++++++++++++++---
src/trunnel/pwbox.c | 46 +++++++++-
src/trunnel/pwbox.h | 32 ++++++-
9 files changed, 474 insertions(+), 43 deletions(-)
diff --git a/src/ext/trunnel/trunnel-impl.h b/src/ext/trunnel/trunnel-impl.h
index 3ffde6e..0cbd4f5 100644
--- a/src/ext/trunnel/trunnel-impl.h
+++ b/src/ext/trunnel/trunnel-impl.h
@@ -1,4 +1,4 @@
-/* trunnel-impl.h -- copied from Trunnel v1.4.6
+/* trunnel-impl.h -- copied from Trunnel v1.5
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -17,6 +17,7 @@
#include "trunnel.h"
#include <assert.h>
#include <string.h>
+#include <stdlib.h>
#if defined(_MSC_VER) && (_MSC_VER < 1600)
#define uint8_t unsigned char
diff --git a/src/ext/trunnel/trunnel.c b/src/ext/trunnel/trunnel.c
index 3994422..f80a587 100644
--- a/src/ext/trunnel/trunnel.c
+++ b/src/ext/trunnel/trunnel.c
@@ -1,4 +1,4 @@
-/* trunnel.c -- copied from Trunnel v1.4.6
+/* trunnel.c -- copied from Trunnel v1.5
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
diff --git a/src/ext/trunnel/trunnel.h b/src/ext/trunnel/trunnel.h
index 41068b8..afd404d 100644
--- a/src/ext/trunnel/trunnel.h
+++ b/src/ext/trunnel/trunnel.h
@@ -1,4 +1,4 @@
-/* trunnel.h -- copied from Trunnel v1.4.6
+/* trunnel.h -- copied from Trunnel v1.5
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
diff --git a/src/trunnel/ed25519_cert.c b/src/trunnel/ed25519_cert.c
index 24988d5..a492ada 100644
--- a/src/trunnel/ed25519_cert.c
+++ b/src/trunnel/ed25519_cert.c
@@ -1,4 +1,4 @@
-/* ed25519_cert.c -- generated by Trunnel v1.4.6.
+/* ed25519_cert.c -- generated by Trunnel v1.5.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -97,12 +97,17 @@ ed25519_cert_extension_getlen_un_signing_key(const ed25519_cert_extension_t *inp
}
uint8_t
-ed25519_cert_extension_get_un_signing_key(const ed25519_cert_extension_t *inp, size_t idx)
+ed25519_cert_extension_get_un_signing_key(ed25519_cert_extension_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->un_signing_key[idx];
}
+uint8_t
+ed25519_cert_extension_getconst_un_signing_key(const ed25519_cert_extension_t *inp, size_t idx)
+{
+ return ed25519_cert_extension_get_un_signing_key((ed25519_cert_extension_t*)inp, idx);
+}
int
ed25519_cert_extension_set_un_signing_key(ed25519_cert_extension_t *inp, size_t idx, uint8_t elt)
{
@@ -116,6 +121,11 @@ ed25519_cert_extension_getarray_un_signing_key(ed25519_cert_extension_t *inp)
{
return inp->un_signing_key;
}
+const uint8_t *
+ed25519_cert_extension_getconstarray_un_signing_key(const ed25519_cert_extension_t *inp)
+{
+ return (const uint8_t *)ed25519_cert_extension_getarray_un_signing_key((ed25519_cert_extension_t*)inp);
+}
size_t
ed25519_cert_extension_getlen_un_unparsed(const ed25519_cert_extension_t *inp)
{
@@ -128,6 +138,11 @@ ed25519_cert_extension_get_un_unparsed(ed25519_cert_extension_t *inp, size_t idx
return TRUNNEL_DYNARRAY_GET(&inp->un_unparsed, idx);
}
+uint8_t
+ed25519_cert_extension_getconst_un_unparsed(const ed25519_cert_extension_t *inp, size_t idx)
+{
+ return ed25519_cert_extension_get_un_unparsed((ed25519_cert_extension_t*)inp, idx);
+}
int
ed25519_cert_extension_set_un_unparsed(ed25519_cert_extension_t *inp, size_t idx, uint8_t elt)
{
@@ -149,6 +164,11 @@ ed25519_cert_extension_getarray_un_unparsed(ed25519_cert_extension_t *inp)
{
return inp->un_unparsed.elts_;
}
+const uint8_t *
+ed25519_cert_extension_getconstarray_un_unparsed(const ed25519_cert_extension_t *inp)
+{
+ return (const uint8_t *)ed25519_cert_extension_getarray_un_unparsed((ed25519_cert_extension_t*)inp);
+}
int
ed25519_cert_extension_setlen_un_unparsed(ed25519_cert_extension_t *inp, size_t newlen)
{
@@ -502,12 +522,17 @@ ed25519_cert_getlen_certified_key(const ed25519_cert_t *inp)
}
uint8_t
-ed25519_cert_get_certified_key(const ed25519_cert_t *inp, size_t idx)
+ed25519_cert_get_certified_key(ed25519_cert_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->certified_key[idx];
}
+uint8_t
+ed25519_cert_getconst_certified_key(const ed25519_cert_t *inp, size_t idx)
+{
+ return ed25519_cert_get_certified_key((ed25519_cert_t*)inp, idx);
+}
int
ed25519_cert_set_certified_key(ed25519_cert_t *inp, size_t idx, uint8_t elt)
{
@@ -521,6 +546,11 @@ ed25519_cert_getarray_certified_key(ed25519_cert_t *inp)
{
return inp->certified_key;
}
+const uint8_t *
+ed25519_cert_getconstarray_certified_key(const ed25519_cert_t *inp)
+{
+ return (const uint8_t *)ed25519_cert_getarray_certified_key((ed25519_cert_t*)inp);
+}
uint8_t
ed25519_cert_get_n_extensions(ed25519_cert_t *inp)
{
@@ -544,6 +574,11 @@ ed25519_cert_get_ext(ed25519_cert_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->ext, idx);
}
+ const struct ed25519_cert_extension_st *
+ed25519_cert_getconst_ext(const ed25519_cert_t *inp, size_t idx)
+{
+ return ed25519_cert_get_ext((ed25519_cert_t*)inp, idx);
+}
int
ed25519_cert_set_ext(ed25519_cert_t *inp, size_t idx, struct ed25519_cert_extension_st * elt)
{
@@ -577,6 +612,11 @@ ed25519_cert_getarray_ext(ed25519_cert_t *inp)
{
return inp->ext.elts_;
}
+const struct ed25519_cert_extension_st * const *
+ed25519_cert_getconstarray_ext(const ed25519_cert_t *inp)
+{
+ return (const struct ed25519_cert_extension_st * const *)ed25519_cert_getarray_ext((ed25519_cert_t*)inp);
+}
int
ed25519_cert_setlen_ext(ed25519_cert_t *inp, size_t newlen)
{
@@ -604,12 +644,17 @@ ed25519_cert_getlen_signature(const ed25519_cert_t *inp)
}
uint8_t
-ed25519_cert_get_signature(const ed25519_cert_t *inp, size_t idx)
+ed25519_cert_get_signature(ed25519_cert_t *inp, size_t idx)
{
trunnel_assert(idx < 64);
return inp->signature[idx];
}
+uint8_t
+ed25519_cert_getconst_signature(const ed25519_cert_t *inp, size_t idx)
+{
+ return ed25519_cert_get_signature((ed25519_cert_t*)inp, idx);
+}
int
ed25519_cert_set_signature(ed25519_cert_t *inp, size_t idx, uint8_t elt)
{
@@ -623,6 +668,11 @@ ed25519_cert_getarray_signature(ed25519_cert_t *inp)
{
return inp->signature;
}
+const uint8_t *
+ed25519_cert_getconstarray_signature(const ed25519_cert_t *inp)
+{
+ return (const uint8_t *)ed25519_cert_getarray_signature((ed25519_cert_t*)inp);
+}
const char *
ed25519_cert_check(const ed25519_cert_t *obj)
{
diff --git a/src/trunnel/ed25519_cert.h b/src/trunnel/ed25519_cert.h
index 28f6fee..9804d84 100644
--- a/src/trunnel/ed25519_cert.h
+++ b/src/trunnel/ed25519_cert.h
@@ -1,4 +1,4 @@
-/* ed25519_cert.h -- generated by by Trunnel v1.4.6.
+/* ed25519_cert.h -- generated by by Trunnel v1.5.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -105,7 +105,11 @@ size_t ed25519_cert_extension_getlen_un_signing_key(const ed25519_cert_extension
/** Return the element at position 'idx' of the fixed array field
* un_signing_key of the ed25519_cert_extension_t in 'inp'.
*/
-uint8_t ed25519_cert_extension_get_un_signing_key(const ed25519_cert_extension_t *inp, size_t idx);
+uint8_t ed25519_cert_extension_get_un_signing_key(ed25519_cert_extension_t *inp, size_t idx);
+/** As ed25519_cert_extension_get_un_signing_key, but take and return
+ * a const pointer
+ */
+uint8_t ed25519_cert_extension_getconst_un_signing_key(const ed25519_cert_extension_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* un_signing_key of the ed25519_cert_extension_t in 'inp', so that it
* will hold the value 'elt'.
@@ -115,6 +119,10 @@ int ed25519_cert_extension_set_un_signing_key(ed25519_cert_extension_t *inp, siz
* 'inp'.
*/
uint8_t * ed25519_cert_extension_getarray_un_signing_key(ed25519_cert_extension_t *inp);
+/** As ed25519_cert_extension_get_un_signing_key, but take and return
+ * a const pointer
+ */
+const uint8_t * ed25519_cert_extension_getconstarray_un_signing_key(const ed25519_cert_extension_t *inp);
/** Return the length of the dynamic array holding the un_unparsed
* field of the ed25519_cert_extension_t in 'inp'.
*/
@@ -123,6 +131,10 @@ size_t ed25519_cert_extension_getlen_un_unparsed(const ed25519_cert_extension_t
* un_unparsed of the ed25519_cert_extension_t in 'inp'.
*/
uint8_t ed25519_cert_extension_get_un_unparsed(ed25519_cert_extension_t *inp, size_t idx);
+/** As ed25519_cert_extension_get_un_unparsed, but take and return a
+ * const pointer
+ */
+uint8_t ed25519_cert_extension_getconst_un_unparsed(const ed25519_cert_extension_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* un_unparsed of the ed25519_cert_extension_t in 'inp', so that it
* will hold the value 'elt'.
@@ -136,6 +148,10 @@ int ed25519_cert_extension_add_un_unparsed(ed25519_cert_extension_t *inp, uint8_
* 'inp'.
*/
uint8_t * ed25519_cert_extension_getarray_un_unparsed(ed25519_cert_extension_t *inp);
+/** As ed25519_cert_extension_get_un_unparsed, but take and return a
+ * const pointer
+ */
+const uint8_t * ed25519_cert_extension_getconstarray_un_unparsed(const ed25519_cert_extension_t *inp);
/** Change the length of the variable-length array field un_unparsed
* of 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on
* success; return -1 and set the error code on 'inp' on failure.
@@ -219,7 +235,11 @@ size_t ed25519_cert_getlen_certified_key(const ed25519_cert_t *inp);
/** Return the element at position 'idx' of the fixed array field
* certified_key of the ed25519_cert_t in 'inp'.
*/
-uint8_t ed25519_cert_get_certified_key(const ed25519_cert_t *inp, size_t idx);
+uint8_t ed25519_cert_get_certified_key(ed25519_cert_t *inp, size_t idx);
+/** As ed25519_cert_get_certified_key, but take and return a const
+ * pointer
+ */
+uint8_t ed25519_cert_getconst_certified_key(const ed25519_cert_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* certified_key of the ed25519_cert_t in 'inp', so that it will hold
* the value 'elt'.
@@ -229,6 +249,10 @@ int ed25519_cert_set_certified_key(ed25519_cert_t *inp, size_t idx, uint8_t elt)
* 'inp'.
*/
uint8_t * ed25519_cert_getarray_certified_key(ed25519_cert_t *inp);
+/** As ed25519_cert_get_certified_key, but take and return a const
+ * pointer
+ */
+const uint8_t * ed25519_cert_getconstarray_certified_key(const ed25519_cert_t *inp);
/** Return the value of the n_extensions field of the ed25519_cert_t
* in 'inp'
*/
@@ -246,6 +270,9 @@ size_t ed25519_cert_getlen_ext(const ed25519_cert_t *inp);
* ext of the ed25519_cert_t in 'inp'.
*/
struct ed25519_cert_extension_st * ed25519_cert_get_ext(ed25519_cert_t *inp, size_t idx);
+/** As ed25519_cert_get_ext, but take and return a const pointer
+ */
+ const struct ed25519_cert_extension_st * ed25519_cert_getconst_ext(const ed25519_cert_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* ext of the ed25519_cert_t in 'inp', so that it will hold the value
* 'elt'. Free the previous value, if any.
@@ -261,6 +288,9 @@ int ed25519_cert_add_ext(ed25519_cert_t *inp, struct ed25519_cert_extension_st *
/** Return a pointer to the variable-length array field ext of 'inp'.
*/
struct ed25519_cert_extension_st * * ed25519_cert_getarray_ext(ed25519_cert_t *inp);
+/** As ed25519_cert_get_ext, but take and return a const pointer
+ */
+const struct ed25519_cert_extension_st * const * ed25519_cert_getconstarray_ext(const ed25519_cert_t *inp);
/** Change the length of the variable-length array field ext of 'inp'
* to 'newlen'.Fill extra elements with NULL; free removed elements.
* Return 0 on success; return -1 and set the error code on 'inp' on
@@ -274,7 +304,10 @@ size_t ed25519_cert_getlen_signature(const ed25519_cert_t *inp);
/** Return the element at position 'idx' of the fixed array field
* signature of the ed25519_cert_t in 'inp'.
*/
-uint8_t ed25519_cert_get_signature(const ed25519_cert_t *inp, size_t idx);
+uint8_t ed25519_cert_get_signature(ed25519_cert_t *inp, size_t idx);
+/** As ed25519_cert_get_signature, but take and return a const pointer
+ */
+uint8_t ed25519_cert_getconst_signature(const ed25519_cert_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* signature of the ed25519_cert_t in 'inp', so that it will hold the
* value 'elt'.
@@ -283,6 +316,9 @@ int ed25519_cert_set_signature(ed25519_cert_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 64-element array field signature of 'inp'.
*/
uint8_t * ed25519_cert_getarray_signature(ed25519_cert_t *inp);
+/** As ed25519_cert_get_signature, but take and return a const pointer
+ */
+const uint8_t * ed25519_cert_getconstarray_signature(const ed25519_cert_t *inp);
#endif
diff --git a/src/trunnel/link_handshake.c b/src/trunnel/link_handshake.c
index c2717f3..a4b1fe0 100644
--- a/src/trunnel/link_handshake.c
+++ b/src/trunnel/link_handshake.c
@@ -1,4 +1,4 @@
-/* link_handshake.c -- generated by Trunnel v1.4.6.
+/* link_handshake.c -- generated by Trunnel v1.5.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -64,12 +64,17 @@ auth_challenge_cell_getlen_challenge(const auth_challenge_cell_t *inp)
}
uint8_t
-auth_challenge_cell_get_challenge(const auth_challenge_cell_t *inp, size_t idx)
+auth_challenge_cell_get_challenge(auth_challenge_cell_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->challenge[idx];
}
+uint8_t
+auth_challenge_cell_getconst_challenge(const auth_challenge_cell_t *inp, size_t idx)
+{
+ return auth_challenge_cell_get_challenge((auth_challenge_cell_t*)inp, idx);
+}
int
auth_challenge_cell_set_challenge(auth_challenge_cell_t *inp, size_t idx, uint8_t elt)
{
@@ -83,6 +88,11 @@ auth_challenge_cell_getarray_challenge(auth_challenge_cell_t *inp)
{
return inp->challenge;
}
+const uint8_t *
+auth_challenge_cell_getconstarray_challenge(const auth_challenge_cell_t *inp)
+{
+ return (const uint8_t *)auth_challenge_cell_getarray_challenge((auth_challenge_cell_t*)inp);
+}
uint16_t
auth_challenge_cell_get_n_methods(auth_challenge_cell_t *inp)
{
@@ -106,6 +116,11 @@ auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->methods, idx);
}
+uint16_t
+auth_challenge_cell_getconst_methods(const auth_challenge_cell_t *inp, size_t idx)
+{
+ return auth_challenge_cell_get_methods((auth_challenge_cell_t*)inp, idx);
+}
int
auth_challenge_cell_set_methods(auth_challenge_cell_t *inp, size_t idx, uint16_t elt)
{
@@ -131,6 +146,11 @@ auth_challenge_cell_getarray_methods(auth_challenge_cell_t *inp)
{
return inp->methods.elts_;
}
+const uint16_t *
+auth_challenge_cell_getconstarray_methods(const auth_challenge_cell_t *inp)
+{
+ return (const uint16_t *)auth_challenge_cell_getarray_methods((auth_challenge_cell_t*)inp);
+}
int
auth_challenge_cell_setlen_methods(auth_challenge_cell_t *inp, size_t newlen)
{
@@ -415,6 +435,11 @@ certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->body, idx);
}
+uint8_t
+certs_cell_cert_getconst_body(const certs_cell_cert_t *inp, size_t idx)
+{
+ return certs_cell_cert_get_body((certs_cell_cert_t*)inp, idx);
+}
int
certs_cell_cert_set_body(certs_cell_cert_t *inp, size_t idx, uint8_t elt)
{
@@ -440,6 +465,11 @@ certs_cell_cert_getarray_body(certs_cell_cert_t *inp)
{
return inp->body.elts_;
}
+const uint8_t *
+certs_cell_cert_getconstarray_body(const certs_cell_cert_t *inp)
+{
+ return (const uint8_t *)certs_cell_cert_getarray_body((certs_cell_cert_t*)inp);
+}
int
certs_cell_cert_setlen_body(certs_cell_cert_t *inp, size_t newlen)
{
@@ -652,12 +682,17 @@ rsa_ed_crosscert_getlen_ed_key(const rsa_ed_crosscert_t *inp)
}
uint8_t
-rsa_ed_crosscert_get_ed_key(const rsa_ed_crosscert_t *inp, size_t idx)
+rsa_ed_crosscert_get_ed_key(rsa_ed_crosscert_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->ed_key[idx];
}
+uint8_t
+rsa_ed_crosscert_getconst_ed_key(const rsa_ed_crosscert_t *inp, size_t idx)
+{
+ return rsa_ed_crosscert_get_ed_key((rsa_ed_crosscert_t*)inp, idx);
+}
int
rsa_ed_crosscert_set_ed_key(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt)
{
@@ -671,6 +706,11 @@ rsa_ed_crosscert_getarray_ed_key(rsa_ed_crosscert_t *inp)
{
return inp->ed_key;
}
+const uint8_t *
+rsa_ed_crosscert_getconstarray_ed_key(const rsa_ed_crosscert_t *inp)
+{
+ return (const uint8_t *)rsa_ed_crosscert_getarray_ed_key((rsa_ed_crosscert_t*)inp);
+}
uint32_t
rsa_ed_crosscert_get_expiration(rsa_ed_crosscert_t *inp)
{
@@ -710,6 +750,11 @@ rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->sig, idx);
}
+uint8_t
+rsa_ed_crosscert_getconst_sig(const rsa_ed_crosscert_t *inp, size_t idx)
+{
+ return rsa_ed_crosscert_get_sig((rsa_ed_crosscert_t*)inp, idx);
+}
int
rsa_ed_crosscert_set_sig(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt)
{
@@ -735,6 +780,11 @@ rsa_ed_crosscert_getarray_sig(rsa_ed_crosscert_t *inp)
{
return inp->sig.elts_;
}
+const uint8_t *
+rsa_ed_crosscert_getconstarray_sig(const rsa_ed_crosscert_t *inp)
+{
+ return (const uint8_t *)rsa_ed_crosscert_getarray_sig((rsa_ed_crosscert_t*)inp);
+}
int
rsa_ed_crosscert_setlen_sig(rsa_ed_crosscert_t *inp, size_t newlen)
{
@@ -964,12 +1014,17 @@ auth1_getlen_type(const auth1_t *inp)
}
uint8_t
-auth1_get_type(const auth1_t *inp, size_t idx)
+auth1_get_type(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 8);
return inp->type[idx];
}
+uint8_t
+auth1_getconst_type(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_type((auth1_t*)inp, idx);
+}
int
auth1_set_type(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -983,6 +1038,11 @@ auth1_getarray_type(auth1_t *inp)
{
return inp->type;
}
+const uint8_t *
+auth1_getconstarray_type(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_type((auth1_t*)inp);
+}
size_t
auth1_getlen_cid(const auth1_t *inp)
{
@@ -990,12 +1050,17 @@ auth1_getlen_cid(const auth1_t *inp)
}
uint8_t
-auth1_get_cid(const auth1_t *inp, size_t idx)
+auth1_get_cid(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->cid[idx];
}
+uint8_t
+auth1_getconst_cid(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_cid((auth1_t*)inp, idx);
+}
int
auth1_set_cid(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1009,6 +1074,11 @@ auth1_getarray_cid(auth1_t *inp)
{
return inp->cid;
}
+const uint8_t *
+auth1_getconstarray_cid(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_cid((auth1_t*)inp);
+}
size_t
auth1_getlen_sid(const auth1_t *inp)
{
@@ -1016,12 +1086,17 @@ auth1_getlen_sid(const auth1_t *inp)
}
uint8_t
-auth1_get_sid(const auth1_t *inp, size_t idx)
+auth1_get_sid(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->sid[idx];
}
+uint8_t
+auth1_getconst_sid(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_sid((auth1_t*)inp, idx);
+}
int
auth1_set_sid(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1035,6 +1110,11 @@ auth1_getarray_sid(auth1_t *inp)
{
return inp->sid;
}
+const uint8_t *
+auth1_getconstarray_sid(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_sid((auth1_t*)inp);
+}
size_t
auth1_getlen_u1_cid_ed(const auth1_t *inp)
{
@@ -1042,12 +1122,17 @@ auth1_getlen_u1_cid_ed(const auth1_t *inp)
}
uint8_t
-auth1_get_u1_cid_ed(const auth1_t *inp, size_t idx)
+auth1_get_u1_cid_ed(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->u1_cid_ed[idx];
}
+uint8_t
+auth1_getconst_u1_cid_ed(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_u1_cid_ed((auth1_t*)inp, idx);
+}
int
auth1_set_u1_cid_ed(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1061,6 +1146,11 @@ auth1_getarray_u1_cid_ed(auth1_t *inp)
{
return inp->u1_cid_ed;
}
+const uint8_t *
+auth1_getconstarray_u1_cid_ed(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_u1_cid_ed((auth1_t*)inp);
+}
size_t
auth1_getlen_u1_sid_ed(const auth1_t *inp)
{
@@ -1068,12 +1158,17 @@ auth1_getlen_u1_sid_ed(const auth1_t *inp)
}
uint8_t
-auth1_get_u1_sid_ed(const auth1_t *inp, size_t idx)
+auth1_get_u1_sid_ed(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->u1_sid_ed[idx];
}
+uint8_t
+auth1_getconst_u1_sid_ed(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_u1_sid_ed((auth1_t*)inp, idx);
+}
int
auth1_set_u1_sid_ed(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1087,6 +1182,11 @@ auth1_getarray_u1_sid_ed(auth1_t *inp)
{
return inp->u1_sid_ed;
}
+const uint8_t *
+auth1_getconstarray_u1_sid_ed(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_u1_sid_ed((auth1_t*)inp);
+}
size_t
auth1_getlen_slog(const auth1_t *inp)
{
@@ -1094,12 +1194,17 @@ auth1_getlen_slog(const auth1_t *inp)
}
uint8_t
-auth1_get_slog(const auth1_t *inp, size_t idx)
+auth1_get_slog(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->slog[idx];
}
+uint8_t
+auth1_getconst_slog(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_slog((auth1_t*)inp, idx);
+}
int
auth1_set_slog(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1113,6 +1218,11 @@ auth1_getarray_slog(auth1_t *inp)
{
return inp->slog;
}
+const uint8_t *
+auth1_getconstarray_slog(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_slog((auth1_t*)inp);
+}
size_t
auth1_getlen_clog(const auth1_t *inp)
{
@@ -1120,12 +1230,17 @@ auth1_getlen_clog(const auth1_t *inp)
}
uint8_t
-auth1_get_clog(const auth1_t *inp, size_t idx)
+auth1_get_clog(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->clog[idx];
}
+uint8_t
+auth1_getconst_clog(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_clog((auth1_t*)inp, idx);
+}
int
auth1_set_clog(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1139,6 +1254,11 @@ auth1_getarray_clog(auth1_t *inp)
{
return inp->clog;
}
+const uint8_t *
+auth1_getconstarray_clog(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_clog((auth1_t*)inp);
+}
size_t
auth1_getlen_scert(const auth1_t *inp)
{
@@ -1146,12 +1266,17 @@ auth1_getlen_scert(const auth1_t *inp)
}
uint8_t
-auth1_get_scert(const auth1_t *inp, size_t idx)
+auth1_get_scert(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->scert[idx];
}
+uint8_t
+auth1_getconst_scert(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_scert((auth1_t*)inp, idx);
+}
int
auth1_set_scert(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1165,6 +1290,11 @@ auth1_getarray_scert(auth1_t *inp)
{
return inp->scert;
}
+const uint8_t *
+auth1_getconstarray_scert(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_scert((auth1_t*)inp);
+}
size_t
auth1_getlen_tlssecrets(const auth1_t *inp)
{
@@ -1172,12 +1302,17 @@ auth1_getlen_tlssecrets(const auth1_t *inp)
}
uint8_t
-auth1_get_tlssecrets(const auth1_t *inp, size_t idx)
+auth1_get_tlssecrets(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->tlssecrets[idx];
}
+uint8_t
+auth1_getconst_tlssecrets(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_tlssecrets((auth1_t*)inp, idx);
+}
int
auth1_set_tlssecrets(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1191,6 +1326,11 @@ auth1_getarray_tlssecrets(auth1_t *inp)
{
return inp->tlssecrets;
}
+const uint8_t *
+auth1_getconstarray_tlssecrets(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_tlssecrets((auth1_t*)inp);
+}
const uint8_t *
auth1_get_end_of_fixed_part(const auth1_t *inp)
{
@@ -1203,12 +1343,17 @@ auth1_getlen_rand(const auth1_t *inp)
}
uint8_t
-auth1_get_rand(const auth1_t *inp, size_t idx)
+auth1_get_rand(auth1_t *inp, size_t idx)
{
trunnel_assert(idx < 24);
return inp->rand[idx];
}
+uint8_t
+auth1_getconst_rand(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_rand((auth1_t*)inp, idx);
+}
int
auth1_set_rand(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1222,6 +1367,11 @@ auth1_getarray_rand(auth1_t *inp)
{
return inp->rand;
}
+const uint8_t *
+auth1_getconstarray_rand(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_rand((auth1_t*)inp);
+}
const uint8_t *
auth1_get_end_of_signed(const auth1_t *inp)
{
@@ -1239,6 +1389,11 @@ auth1_get_sig(auth1_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->sig, idx);
}
+uint8_t
+auth1_getconst_sig(const auth1_t *inp, size_t idx)
+{
+ return auth1_get_sig((auth1_t*)inp, idx);
+}
int
auth1_set_sig(auth1_t *inp, size_t idx, uint8_t elt)
{
@@ -1260,6 +1415,11 @@ auth1_getarray_sig(auth1_t *inp)
{
return inp->sig.elts_;
}
+const uint8_t *
+auth1_getconstarray_sig(const auth1_t *inp)
+{
+ return (const uint8_t *)auth1_getarray_sig((auth1_t*)inp);
+}
int
auth1_setlen_sig(auth1_t *inp, size_t newlen)
{
@@ -1669,6 +1829,11 @@ certs_cell_get_certs(certs_cell_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->certs, idx);
}
+ const struct certs_cell_cert_st *
+certs_cell_getconst_certs(const certs_cell_t *inp, size_t idx)
+{
+ return certs_cell_get_certs((certs_cell_t*)inp, idx);
+}
int
certs_cell_set_certs(certs_cell_t *inp, size_t idx, struct certs_cell_cert_st * elt)
{
@@ -1702,6 +1867,11 @@ certs_cell_getarray_certs(certs_cell_t *inp)
{
return inp->certs.elts_;
}
+const struct certs_cell_cert_st * const *
+certs_cell_getconstarray_certs(const certs_cell_t *inp)
+{
+ return (const struct certs_cell_cert_st * const *)certs_cell_getarray_certs((certs_cell_t*)inp);
+}
int
certs_cell_setlen_certs(certs_cell_t *inp, size_t newlen)
{
diff --git a/src/trunnel/link_handshake.h b/src/trunnel/link_handshake.h
index 54611b9..0b2ad34 100644
--- a/src/trunnel/link_handshake.h
+++ b/src/trunnel/link_handshake.h
@@ -1,4 +1,4 @@
-/* link_handshake.h -- generated by by Trunnel v1.4.6.
+/* link_handshake.h -- generated by by Trunnel v1.5.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -121,7 +121,11 @@ size_t auth_challenge_cell_getlen_challenge(const auth_challenge_cell_t *inp);
/** Return the element at position 'idx' of the fixed array field
* challenge of the auth_challenge_cell_t in 'inp'.
*/
-uint8_t auth_challenge_cell_get_challenge(const auth_challenge_cell_t *inp, size_t idx);
+uint8_t auth_challenge_cell_get_challenge(auth_challenge_cell_t *inp, size_t idx);
+/** As auth_challenge_cell_get_challenge, but take and return a const
+ * pointer
+ */
+uint8_t auth_challenge_cell_getconst_challenge(const auth_challenge_cell_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* challenge of the auth_challenge_cell_t in 'inp', so that it will
* hold the value 'elt'.
@@ -130,6 +134,10 @@ int auth_challenge_cell_set_challenge(auth_challenge_cell_t *inp, size_t idx, ui
/** Return a pointer to the 32-element array field challenge of 'inp'.
*/
uint8_t * auth_challenge_cell_getarray_challenge(auth_challenge_cell_t *inp);
+/** As auth_challenge_cell_get_challenge, but take and return a const
+ * pointer
+ */
+const uint8_t * auth_challenge_cell_getconstarray_challenge(const auth_challenge_cell_t *inp);
/** Return the value of the n_methods field of the
* auth_challenge_cell_t in 'inp'
*/
@@ -147,6 +155,10 @@ size_t auth_challenge_cell_getlen_methods(const auth_challenge_cell_t *inp);
* methods of the auth_challenge_cell_t in 'inp'.
*/
uint16_t auth_challenge_cell_get_methods(auth_challenge_cell_t *inp, size_t idx);
+/** As auth_challenge_cell_get_methods, but take and return a const
+ * pointer
+ */
+uint16_t auth_challenge_cell_getconst_methods(const auth_challenge_cell_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* methods of the auth_challenge_cell_t in 'inp', so that it will hold
* the value 'elt'.
@@ -160,6 +172,10 @@ int auth_challenge_cell_add_methods(auth_challenge_cell_t *inp, uint16_t elt);
* 'inp'.
*/
uint16_t * auth_challenge_cell_getarray_methods(auth_challenge_cell_t *inp);
+/** As auth_challenge_cell_get_methods, but take and return a const
+ * pointer
+ */
+const uint16_t * auth_challenge_cell_getconstarray_methods(const auth_challenge_cell_t *inp);
/** Change the length of the variable-length array field methods of
* 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on success;
* return -1 and set the error code on 'inp' on failure.
@@ -242,6 +258,9 @@ size_t certs_cell_cert_getlen_body(const certs_cell_cert_t *inp);
* body of the certs_cell_cert_t in 'inp'.
*/
uint8_t certs_cell_cert_get_body(certs_cell_cert_t *inp, size_t idx);
+/** As certs_cell_cert_get_body, but take and return a const pointer
+ */
+uint8_t certs_cell_cert_getconst_body(const certs_cell_cert_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* body of the certs_cell_cert_t in 'inp', so that it will hold the
* value 'elt'.
@@ -254,6 +273,9 @@ int certs_cell_cert_add_body(certs_cell_cert_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field body of 'inp'.
*/
uint8_t * certs_cell_cert_getarray_body(certs_cell_cert_t *inp);
+/** As certs_cell_cert_get_body, but take and return a const pointer
+ */
+const uint8_t * certs_cell_cert_getconstarray_body(const certs_cell_cert_t *inp);
/** Change the length of the variable-length array field body of 'inp'
* to 'newlen'.Fill extra elements with 0. Return 0 on success; return
* -1 and set the error code on 'inp' on failure.
@@ -302,7 +324,11 @@ size_t rsa_ed_crosscert_getlen_ed_key(const rsa_ed_crosscert_t *inp);
/** Return the element at position 'idx' of the fixed array field
* ed_key of the rsa_ed_crosscert_t in 'inp'.
*/
-uint8_t rsa_ed_crosscert_get_ed_key(const rsa_ed_crosscert_t *inp, size_t idx);
+uint8_t rsa_ed_crosscert_get_ed_key(rsa_ed_crosscert_t *inp, size_t idx);
+/** As rsa_ed_crosscert_get_ed_key, but take and return a const
+ * pointer
+ */
+uint8_t rsa_ed_crosscert_getconst_ed_key(const rsa_ed_crosscert_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* ed_key of the rsa_ed_crosscert_t in 'inp', so that it will hold the
* value 'elt'.
@@ -311,6 +337,10 @@ int rsa_ed_crosscert_set_ed_key(rsa_ed_crosscert_t *inp, size_t idx, uint8_t elt
/** Return a pointer to the 32-element array field ed_key of 'inp'.
*/
uint8_t * rsa_ed_crosscert_getarray_ed_key(rsa_ed_crosscert_t *inp);
+/** As rsa_ed_crosscert_get_ed_key, but take and return a const
+ * pointer
+ */
+const uint8_t * rsa_ed_crosscert_getconstarray_ed_key(const rsa_ed_crosscert_t *inp);
/** Return the value of the expiration field of the rsa_ed_crosscert_t
* in 'inp'
*/
@@ -340,6 +370,9 @@ size_t rsa_ed_crosscert_getlen_sig(const rsa_ed_crosscert_t *inp);
* sig of the rsa_ed_crosscert_t in 'inp'.
*/
uint8_t rsa_ed_crosscert_get_sig(rsa_ed_crosscert_t *inp, size_t idx);
+/** As rsa_ed_crosscert_get_sig, but take and return a const pointer
+ */
+uint8_t rsa_ed_crosscert_getconst_sig(const rsa_ed_crosscert_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* sig of the rsa_ed_crosscert_t in 'inp', so that it will hold the
* value 'elt'.
@@ -352,6 +385,9 @@ int rsa_ed_crosscert_add_sig(rsa_ed_crosscert_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field sig of 'inp'.
*/
uint8_t * rsa_ed_crosscert_getarray_sig(rsa_ed_crosscert_t *inp);
+/** As rsa_ed_crosscert_get_sig, but take and return a const pointer
+ */
+const uint8_t * rsa_ed_crosscert_getconstarray_sig(const rsa_ed_crosscert_t *inp);
/** Change the length of the variable-length array field sig of 'inp'
* to 'newlen'.Fill extra elements with 0. Return 0 on success; return
* -1 and set the error code on 'inp' on failure.
@@ -398,7 +434,10 @@ size_t auth1_getlen_type(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field type
* of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_type(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_type(auth1_t *inp, size_t idx);
+/** As auth1_get_type, but take and return a const pointer
+ */
+uint8_t auth1_getconst_type(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field type
* of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -406,6 +445,9 @@ int auth1_set_type(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 8-element array field type of 'inp'.
*/
uint8_t * auth1_getarray_type(auth1_t *inp);
+/** As auth1_get_type, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_type(const auth1_t *inp);
/** Return the (constant) length of the array holding the cid field of
* the auth1_t in 'inp'.
*/
@@ -413,7 +455,10 @@ size_t auth1_getlen_cid(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field cid
* of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_cid(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_cid(auth1_t *inp, size_t idx);
+/** As auth1_get_cid, but take and return a const pointer
+ */
+uint8_t auth1_getconst_cid(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field cid
* of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -421,6 +466,9 @@ int auth1_set_cid(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field cid of 'inp'.
*/
uint8_t * auth1_getarray_cid(auth1_t *inp);
+/** As auth1_get_cid, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_cid(const auth1_t *inp);
/** Return the (constant) length of the array holding the sid field of
* the auth1_t in 'inp'.
*/
@@ -428,7 +476,10 @@ size_t auth1_getlen_sid(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field sid
* of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_sid(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_sid(auth1_t *inp, size_t idx);
+/** As auth1_get_sid, but take and return a const pointer
+ */
+uint8_t auth1_getconst_sid(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field sid
* of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -436,6 +487,9 @@ int auth1_set_sid(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field sid of 'inp'.
*/
uint8_t * auth1_getarray_sid(auth1_t *inp);
+/** As auth1_get_sid, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_sid(const auth1_t *inp);
/** Return the (constant) length of the array holding the u1_cid_ed
* field of the auth1_t in 'inp'.
*/
@@ -443,7 +497,10 @@ size_t auth1_getlen_u1_cid_ed(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
* u1_cid_ed of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_u1_cid_ed(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_u1_cid_ed(auth1_t *inp, size_t idx);
+/** As auth1_get_u1_cid_ed, but take and return a const pointer
+ */
+uint8_t auth1_getconst_u1_cid_ed(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* u1_cid_ed of the auth1_t in 'inp', so that it will hold the value
* 'elt'.
@@ -452,6 +509,9 @@ int auth1_set_u1_cid_ed(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field u1_cid_ed of 'inp'.
*/
uint8_t * auth1_getarray_u1_cid_ed(auth1_t *inp);
+/** As auth1_get_u1_cid_ed, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_u1_cid_ed(const auth1_t *inp);
/** Return the (constant) length of the array holding the u1_sid_ed
* field of the auth1_t in 'inp'.
*/
@@ -459,7 +519,10 @@ size_t auth1_getlen_u1_sid_ed(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
* u1_sid_ed of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_u1_sid_ed(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_u1_sid_ed(auth1_t *inp, size_t idx);
+/** As auth1_get_u1_sid_ed, but take and return a const pointer
+ */
+uint8_t auth1_getconst_u1_sid_ed(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* u1_sid_ed of the auth1_t in 'inp', so that it will hold the value
* 'elt'.
@@ -468,6 +531,9 @@ int auth1_set_u1_sid_ed(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field u1_sid_ed of 'inp'.
*/
uint8_t * auth1_getarray_u1_sid_ed(auth1_t *inp);
+/** As auth1_get_u1_sid_ed, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_u1_sid_ed(const auth1_t *inp);
/** Return the (constant) length of the array holding the slog field
* of the auth1_t in 'inp'.
*/
@@ -475,7 +541,10 @@ size_t auth1_getlen_slog(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field slog
* of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_slog(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_slog(auth1_t *inp, size_t idx);
+/** As auth1_get_slog, but take and return a const pointer
+ */
+uint8_t auth1_getconst_slog(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field slog
* of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -483,6 +552,9 @@ int auth1_set_slog(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field slog of 'inp'.
*/
uint8_t * auth1_getarray_slog(auth1_t *inp);
+/** As auth1_get_slog, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_slog(const auth1_t *inp);
/** Return the (constant) length of the array holding the clog field
* of the auth1_t in 'inp'.
*/
@@ -490,7 +562,10 @@ size_t auth1_getlen_clog(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field clog
* of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_clog(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_clog(auth1_t *inp, size_t idx);
+/** As auth1_get_clog, but take and return a const pointer
+ */
+uint8_t auth1_getconst_clog(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field clog
* of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -498,6 +573,9 @@ int auth1_set_clog(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field clog of 'inp'.
*/
uint8_t * auth1_getarray_clog(auth1_t *inp);
+/** As auth1_get_clog, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_clog(const auth1_t *inp);
/** Return the (constant) length of the array holding the scert field
* of the auth1_t in 'inp'.
*/
@@ -505,7 +583,10 @@ size_t auth1_getlen_scert(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
* scert of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_scert(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_scert(auth1_t *inp, size_t idx);
+/** As auth1_get_scert, but take and return a const pointer
+ */
+uint8_t auth1_getconst_scert(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* scert of the auth1_t in 'inp', so that it will hold the value
* 'elt'.
@@ -514,6 +595,9 @@ int auth1_set_scert(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field scert of 'inp'.
*/
uint8_t * auth1_getarray_scert(auth1_t *inp);
+/** As auth1_get_scert, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_scert(const auth1_t *inp);
/** Return the (constant) length of the array holding the tlssecrets
* field of the auth1_t in 'inp'.
*/
@@ -521,7 +605,10 @@ size_t auth1_getlen_tlssecrets(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field
* tlssecrets of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_tlssecrets(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_tlssecrets(auth1_t *inp, size_t idx);
+/** As auth1_get_tlssecrets, but take and return a const pointer
+ */
+uint8_t auth1_getconst_tlssecrets(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field
* tlssecrets of the auth1_t in 'inp', so that it will hold the value
* 'elt'.
@@ -531,6 +618,9 @@ int auth1_set_tlssecrets(auth1_t *inp, size_t idx, uint8_t elt);
* 'inp'.
*/
uint8_t * auth1_getarray_tlssecrets(auth1_t *inp);
+/** As auth1_get_tlssecrets, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_tlssecrets(const auth1_t *inp);
/** Return the position for end_of_fixed_part when we parsed this
* object
*/
@@ -542,7 +632,10 @@ size_t auth1_getlen_rand(const auth1_t *inp);
/** Return the element at position 'idx' of the fixed array field rand
* of the auth1_t in 'inp'.
*/
-uint8_t auth1_get_rand(const auth1_t *inp, size_t idx);
+uint8_t auth1_get_rand(auth1_t *inp, size_t idx);
+/** As auth1_get_rand, but take and return a const pointer
+ */
+uint8_t auth1_getconst_rand(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field rand
* of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -550,6 +643,9 @@ int auth1_set_rand(auth1_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 24-element array field rand of 'inp'.
*/
uint8_t * auth1_getarray_rand(auth1_t *inp);
+/** As auth1_get_rand, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_rand(const auth1_t *inp);
/** Return the position for end_of_signed when we parsed this object
*/
const uint8_t * auth1_get_end_of_signed(const auth1_t *inp);
@@ -561,6 +657,9 @@ size_t auth1_getlen_sig(const auth1_t *inp);
* sig of the auth1_t in 'inp'.
*/
uint8_t auth1_get_sig(auth1_t *inp, size_t idx);
+/** As auth1_get_sig, but take and return a const pointer
+ */
+uint8_t auth1_getconst_sig(const auth1_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* sig of the auth1_t in 'inp', so that it will hold the value 'elt'.
*/
@@ -572,6 +671,9 @@ int auth1_add_sig(auth1_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field sig of 'inp'.
*/
uint8_t * auth1_getarray_sig(auth1_t *inp);
+/** As auth1_get_sig, but take and return a const pointer
+ */
+const uint8_t * auth1_getconstarray_sig(const auth1_t *inp);
/** Change the length of the variable-length array field sig of 'inp'
* to 'newlen'.Fill extra elements with 0. Return 0 on success; return
* -1 and set the error code on 'inp' on failure.
@@ -627,6 +729,9 @@ size_t certs_cell_getlen_certs(const certs_cell_t *inp);
* certs of the certs_cell_t in 'inp'.
*/
struct certs_cell_cert_st * certs_cell_get_certs(certs_cell_t *inp, size_t idx);
+/** As certs_cell_get_certs, but take and return a const pointer
+ */
+ const struct certs_cell_cert_st * certs_cell_getconst_certs(const certs_cell_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* certs of the certs_cell_t in 'inp', so that it will hold the value
* 'elt'. Free the previous value, if any.
@@ -643,6 +748,9 @@ int certs_cell_add_certs(certs_cell_t *inp, struct certs_cell_cert_st * elt);
* 'inp'.
*/
struct certs_cell_cert_st * * certs_cell_getarray_certs(certs_cell_t *inp);
+/** As certs_cell_get_certs, but take and return a const pointer
+ */
+const struct certs_cell_cert_st * const * certs_cell_getconstarray_certs(const certs_cell_t *inp);
/** Change the length of the variable-length array field certs of
* 'inp' to 'newlen'.Fill extra elements with NULL; free removed
* elements. Return 0 on success; return -1 and set the error code on
diff --git a/src/trunnel/pwbox.c b/src/trunnel/pwbox.c
index 62662a9..059fcfd 100644
--- a/src/trunnel/pwbox.c
+++ b/src/trunnel/pwbox.c
@@ -1,4 +1,4 @@
-/* pwbox.c -- generated by Trunnel v1.4.6.
+/* pwbox.c -- generated by Trunnel v1.5.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -114,6 +114,11 @@ pwbox_encoded_get_skey_header(pwbox_encoded_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->skey_header, idx);
}
+uint8_t
+pwbox_encoded_getconst_skey_header(const pwbox_encoded_t *inp, size_t idx)
+{
+ return pwbox_encoded_get_skey_header((pwbox_encoded_t*)inp, idx);
+}
int
pwbox_encoded_set_skey_header(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
{
@@ -139,6 +144,11 @@ pwbox_encoded_getarray_skey_header(pwbox_encoded_t *inp)
{
return inp->skey_header.elts_;
}
+const uint8_t *
+pwbox_encoded_getconstarray_skey_header(const pwbox_encoded_t *inp)
+{
+ return (const uint8_t *)pwbox_encoded_getarray_skey_header((pwbox_encoded_t*)inp);
+}
int
pwbox_encoded_setlen_skey_header(pwbox_encoded_t *inp, size_t newlen)
{
@@ -166,12 +176,17 @@ pwbox_encoded_getlen_iv(const pwbox_encoded_t *inp)
}
uint8_t
-pwbox_encoded_get_iv(const pwbox_encoded_t *inp, size_t idx)
+pwbox_encoded_get_iv(pwbox_encoded_t *inp, size_t idx)
{
trunnel_assert(idx < 16);
return inp->iv[idx];
}
+uint8_t
+pwbox_encoded_getconst_iv(const pwbox_encoded_t *inp, size_t idx)
+{
+ return pwbox_encoded_get_iv((pwbox_encoded_t*)inp, idx);
+}
int
pwbox_encoded_set_iv(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
{
@@ -185,6 +200,11 @@ pwbox_encoded_getarray_iv(pwbox_encoded_t *inp)
{
return inp->iv;
}
+const uint8_t *
+pwbox_encoded_getconstarray_iv(const pwbox_encoded_t *inp)
+{
+ return (const uint8_t *)pwbox_encoded_getarray_iv((pwbox_encoded_t*)inp);
+}
size_t
pwbox_encoded_getlen_data(const pwbox_encoded_t *inp)
{
@@ -197,6 +217,11 @@ pwbox_encoded_get_data(pwbox_encoded_t *inp, size_t idx)
return TRUNNEL_DYNARRAY_GET(&inp->data, idx);
}
+uint8_t
+pwbox_encoded_getconst_data(const pwbox_encoded_t *inp, size_t idx)
+{
+ return pwbox_encoded_get_data((pwbox_encoded_t*)inp, idx);
+}
int
pwbox_encoded_set_data(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
{
@@ -218,6 +243,11 @@ pwbox_encoded_getarray_data(pwbox_encoded_t *inp)
{
return inp->data.elts_;
}
+const uint8_t *
+pwbox_encoded_getconstarray_data(const pwbox_encoded_t *inp)
+{
+ return (const uint8_t *)pwbox_encoded_getarray_data((pwbox_encoded_t*)inp);
+}
int
pwbox_encoded_setlen_data(pwbox_encoded_t *inp, size_t newlen)
{
@@ -241,12 +271,17 @@ pwbox_encoded_getlen_hmac(const pwbox_encoded_t *inp)
}
uint8_t
-pwbox_encoded_get_hmac(const pwbox_encoded_t *inp, size_t idx)
+pwbox_encoded_get_hmac(pwbox_encoded_t *inp, size_t idx)
{
trunnel_assert(idx < 32);
return inp->hmac[idx];
}
+uint8_t
+pwbox_encoded_getconst_hmac(const pwbox_encoded_t *inp, size_t idx)
+{
+ return pwbox_encoded_get_hmac((pwbox_encoded_t*)inp, idx);
+}
int
pwbox_encoded_set_hmac(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
{
@@ -260,6 +295,11 @@ pwbox_encoded_getarray_hmac(pwbox_encoded_t *inp)
{
return inp->hmac;
}
+const uint8_t *
+pwbox_encoded_getconstarray_hmac(const pwbox_encoded_t *inp)
+{
+ return (const uint8_t *)pwbox_encoded_getarray_hmac((pwbox_encoded_t*)inp);
+}
const char *
pwbox_encoded_check(const pwbox_encoded_t *obj)
{
diff --git a/src/trunnel/pwbox.h b/src/trunnel/pwbox.h
index 77a813d..9376a7c 100644
--- a/src/trunnel/pwbox.h
+++ b/src/trunnel/pwbox.h
@@ -1,4 +1,4 @@
-/* pwbox.h -- generated by by Trunnel v1.4.6.
+/* pwbox.h -- generated by by Trunnel v1.5.
* https://gitweb.torproject.org/trunnel.git
* You probably shouldn't edit this file.
*/
@@ -93,6 +93,10 @@ size_t pwbox_encoded_getlen_skey_header(const pwbox_encoded_t *inp);
* skey_header of the pwbox_encoded_t in 'inp'.
*/
uint8_t pwbox_encoded_get_skey_header(pwbox_encoded_t *inp, size_t idx);
+/** As pwbox_encoded_get_skey_header, but take and return a const
+ * pointer
+ */
+uint8_t pwbox_encoded_getconst_skey_header(const pwbox_encoded_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* skey_header of the pwbox_encoded_t in 'inp', so that it will hold
* the value 'elt'.
@@ -106,6 +110,10 @@ int pwbox_encoded_add_skey_header(pwbox_encoded_t *inp, uint8_t elt);
* 'inp'.
*/
uint8_t * pwbox_encoded_getarray_skey_header(pwbox_encoded_t *inp);
+/** As pwbox_encoded_get_skey_header, but take and return a const
+ * pointer
+ */
+const uint8_t * pwbox_encoded_getconstarray_skey_header(const pwbox_encoded_t *inp);
/** Change the length of the variable-length array field skey_header
* of 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on
* success; return -1 and set the error code on 'inp' on failure.
@@ -118,7 +126,10 @@ size_t pwbox_encoded_getlen_iv(const pwbox_encoded_t *inp);
/** Return the element at position 'idx' of the fixed array field iv
* of the pwbox_encoded_t in 'inp'.
*/
-uint8_t pwbox_encoded_get_iv(const pwbox_encoded_t *inp, size_t idx);
+uint8_t pwbox_encoded_get_iv(pwbox_encoded_t *inp, size_t idx);
+/** As pwbox_encoded_get_iv, but take and return a const pointer
+ */
+uint8_t pwbox_encoded_getconst_iv(const pwbox_encoded_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field iv
* of the pwbox_encoded_t in 'inp', so that it will hold the value
* 'elt'.
@@ -127,6 +138,9 @@ int pwbox_encoded_set_iv(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 16-element array field iv of 'inp'.
*/
uint8_t * pwbox_encoded_getarray_iv(pwbox_encoded_t *inp);
+/** As pwbox_encoded_get_iv, but take and return a const pointer
+ */
+const uint8_t * pwbox_encoded_getconstarray_iv(const pwbox_encoded_t *inp);
/** Return the length of the dynamic array holding the data field of
* the pwbox_encoded_t in 'inp'.
*/
@@ -135,6 +149,9 @@ size_t pwbox_encoded_getlen_data(const pwbox_encoded_t *inp);
* data of the pwbox_encoded_t in 'inp'.
*/
uint8_t pwbox_encoded_get_data(pwbox_encoded_t *inp, size_t idx);
+/** As pwbox_encoded_get_data, but take and return a const pointer
+ */
+uint8_t pwbox_encoded_getconst_data(const pwbox_encoded_t *inp, size_t idx);
/** Change the element at position 'idx' of the dynamic array field
* data of the pwbox_encoded_t in 'inp', so that it will hold the
* value 'elt'.
@@ -147,6 +164,9 @@ int pwbox_encoded_add_data(pwbox_encoded_t *inp, uint8_t elt);
/** Return a pointer to the variable-length array field data of 'inp'.
*/
uint8_t * pwbox_encoded_getarray_data(pwbox_encoded_t *inp);
+/** As pwbox_encoded_get_data, but take and return a const pointer
+ */
+const uint8_t * pwbox_encoded_getconstarray_data(const pwbox_encoded_t *inp);
/** Change the length of the variable-length array field data of 'inp'
* to 'newlen'.Fill extra elements with 0. Return 0 on success; return
* -1 and set the error code on 'inp' on failure.
@@ -159,7 +179,10 @@ size_t pwbox_encoded_getlen_hmac(const pwbox_encoded_t *inp);
/** Return the element at position 'idx' of the fixed array field hmac
* of the pwbox_encoded_t in 'inp'.
*/
-uint8_t pwbox_encoded_get_hmac(const pwbox_encoded_t *inp, size_t idx);
+uint8_t pwbox_encoded_get_hmac(pwbox_encoded_t *inp, size_t idx);
+/** As pwbox_encoded_get_hmac, but take and return a const pointer
+ */
+uint8_t pwbox_encoded_getconst_hmac(const pwbox_encoded_t *inp, size_t idx);
/** Change the element at position 'idx' of the fixed array field hmac
* of the pwbox_encoded_t in 'inp', so that it will hold the value
* 'elt'.
@@ -168,6 +191,9 @@ int pwbox_encoded_set_hmac(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
/** Return a pointer to the 32-element array field hmac of 'inp'.
*/
uint8_t * pwbox_encoded_getarray_hmac(pwbox_encoded_t *inp);
+/** As pwbox_encoded_get_hmac, but take and return a const pointer
+ */
+const uint8_t * pwbox_encoded_getconstarray_hmac(const pwbox_encoded_t *inp);
#endif
1
0
commit a5f07a6c2a2b937f58548680f9b87b1e75b3c8f8
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Oct 26 11:02:57 2016 -0400
More module-level documentation.
---
src/or/directory.c | 35 ++++++++++++++++++++++++++++++++---
src/or/networkstatus.c | 30 ++++++++++++++++++++++++++++--
src/or/nodelist.c | 26 ++++++++++++++++++++++++++
src/or/relay.c | 35 +++++++++++++++++++++++++++++++++++
src/or/torcert.c | 17 +++++++++++++++++
5 files changed, 138 insertions(+), 5 deletions(-)
diff --git a/src/or/directory.c b/src/or/directory.c
index a73680a..fdfb339 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -40,9 +40,38 @@
/**
* \file directory.c
- * \brief Code to send and fetch directories and router
- * descriptors via HTTP. Directories use dirserv.c to generate the
- * results; clients use routers.c to parse them.
+ * \brief Code to send and fetch information from directory authorities and
+ * caches via HTTP.
+ *
+ * Directory caches and authorities use dirserv.c to generate the results of a
+ * query and stream them to the connection; clients use routerparse.c to parse
+ * them.
+ *
+ * Every directory request has a dir_connection_t on the client side and on
+ * the server side. In most cases, the dir_connection_t object is a linked
+ * connection, tunneled through an edge_connection_t so that it can be a
+ * stream on the Tor network. The only non-tunneled connections are those
+ * that are used to upload material (descriptors and votes) to authorities.
+ * Among tunneled connections, some use one-hop circuits, and others use
+ * multi-hop circuits for anonymity.
+ *
+ * Directory requests are launched by calling
+ * directory_initiate_command_rend() or one of its numerous variants. This
+ * launch the connection, will construct an HTTP request with
+ * directory_send_command(), send the and wait for a response. The client
+ * later handles the response with connection_dir_client_reached_eof(),
+ * which passes the information received to another part of Tor.
+ *
+ * On the server side, requests are read in directory_handle_command(),
+ * which dispatches first on the request type (GET or POST), and then on
+ * the URL requested. GET requests are processed with a table-based
+ * dispatcher in url_table[]. The process of handling larger GET requests
+ * is complicated because we need to avoid allocating a copy of all the
+ * data to be sent to the client in one huge buffer. Instead, we spool the
+ * data into the buffer using logic in connection_dirserv_flushed_some() in
+ * dirserv.c. (TODO: If we extended buf.c to have a zero-copy
+ * reference-based buffer type, we could remove most of that code, at the
+ * cost of a bit more reference counting.)
**/
/* In-points to directory.c:
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index f30fe16..85a73c8 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -6,8 +6,34 @@
/**
* \file networkstatus.c
- * \brief Functions and structures for handling network status documents as a
- * client or cache.
+ * \brief Functions and structures for handling networkstatus documents as a
+ * client or as a directory cache.
+ *
+ * A consensus networkstatus object is created by the directory
+ * authorities. It authenticates a set of network parameters--most
+ * importantly, the list of all the relays in the network. This list
+ * of relays is represented as an array of routerstatus_t objects.
+ *
+ * There are currently two flavors of consensus. With the older "NS"
+ * flavor, each relay is associated with a digest of its router
+ * descriptor. Tor instances that use this consensus keep the list of
+ * router descriptors as routerinfo_t objects stored and managed in
+ * routerlist.c. With the newer "microdesc" flavor, each relay is
+ * associated with a digest of the microdescriptor that the authorities
+ * made for it. These are stored and managed in microdesc.c. Information
+ * about the router is divided between the the networkstatus and the
+ * microdescriptor according to the general rule that microdescriptors
+ * should hold information that changes much less frequently than the
+ * information in the networkstatus.
+ *
+ * Modern clients use microdescriptor networkstatuses. Directory caches
+ * need to keep both kinds of networkstatus document, so they can serve them.
+ *
+ * This module manages fetching, holding, storing, updating, and
+ * validating networkstatus objects. The download-and-validate process
+ * is slightly complicated by the fact that the keys you need to
+ * validate a consensus are stored in the authority certificates, which
+ * you might not have yet when you download the consensus.
*/
#define NETWORKSTATUS_PRIVATE
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 070e2e9..2802d5b 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -10,6 +10,32 @@
* \brief Structures and functions for tracking what we know about the routers
* on the Tor network, and correlating information from networkstatus,
* routerinfo, and microdescs.
+ *
+ * The key structure here is node_t: that's the canonical way to refer
+ * to a Tor relay that we might want to build a circuit through. Every
+ * node_t has either a routerinfo_t, or a routerstatus_t from the current
+ * networkstatus consensus. If it has a routerstatus_t, it will also
+ * need to have a microdesc_t before you can use it for circuits.
+ *
+ * The nodelist_t is a global singleton that maps identities to node_t
+ * objects. Access them with the node_get_*() functions. The nodelist_t
+ * is maintained by calls throughout the codebase
+ *
+ * Generally, other code should not have to reach inside a node_t to
+ * see what information it has. Instead, you should call one of the
+ * many accessor functions that works on a generic node_t. If there
+ * isn't one that does what you need, it's better to make such a function,
+ * and then use it.
+ *
+ * For historical reasons, some of the functions that select a node_t
+ * from the list of all usable node_t objects are in the routerlist.c
+ * module, since they originally selected a routerinfo_t. (TODO: They
+ * should move!)
+ *
+ * (TODO: Perhaps someday we should abstract the remaining ways of
+ * talking about a relay to also be node_t instances. Those would be
+ * routerstatus_t as used for directory requests, and dir_server_t as
+ * used for authorities and fallback directories.)
*/
#include "or.h"
diff --git a/src/or/relay.c b/src/or/relay.c
index 1794215..823e074 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -8,6 +8,41 @@
* \file relay.c
* \brief Handle relay cell encryption/decryption, plus packaging and
* receiving from circuits, plus queuing on circuits.
+ *
+ * This is a core modules that makes Tor work. It's responsible for
+ * dealing with RELAY cells (the ones that travel more than one hop along a
+ * circuit), by:
+ * <ul>
+ * <li>constructing relays cells,
+ * <li>encrypting relay cells,
+ * <li>decrypting relay cells,
+ * <li>demultiplexing relay cells as they arrive on a connection,
+ * <li>queueing relay cells for retransmission,
+ * <li>or handling relay cells that are for us to receive (as an exit or a
+ * client).
+ * </ul>
+ *
+ * RELAY cells are generated throughout the code at the client or relay side,
+ * using relay_send_command_from_edge() or one of the functions like
+ * connection_edge_send_command() that calls it. Of particular interest is
+ * connection_edge_package_raw_inbuf(), which takes information that has
+ * arrived on an edge connection socket, and packages it as a RELAY_DATA cell
+ * -- this is how information is actually sent across the Tor network. The
+ * cryptography for these functions is handled deep in
+ * circuit_package_relay_cell(), which either adds a single layer of
+ * encryption (if we're an exit), or multiple layers (if we're the origin of
+ * the circuit). After construction and encryption, the RELAY cells are
+ * passed to append_cell_to_circuit_queue(), which queues them for
+ * transmission and tells the circuitmux (see circuitmux.c) that the circuit
+ * is waiting to send something.
+ *
+ * Incoming RELAY cells arrive at circuit_receive_relay_cell(), called from
+ * command.c. There they are decrypted and, if they are for us, are passed to
+ * connection_edge_process_relay_cell(). If they're not for us, they're
+ * re-queued for retransmission again with append_cell_to_circuit_queue().
+ *
+ * The connection_edge_process_relay_cell() function handles all the different
+ * types of relay cells, launching requests or transmitting data as needed.
**/
#define RELAY_PRIVATE
diff --git a/src/or/torcert.c b/src/or/torcert.c
index a6a33c6..37a201e 100644
--- a/src/or/torcert.c
+++ b/src/or/torcert.c
@@ -6,6 +6,23 @@
*
* \brief Implementation for ed25519-signed certificates as used in the Tor
* protocol.
+ *
+ * This certificate format is designed to be simple and compact; it's
+ * documented in tor-spec.txt in the torspec.git repository. All of the
+ * certificates in this format are signed with an Ed25519 key; the
+ * contents themselves may be another Ed25519 key, a digest of a
+ * RSA key, or some other material.
+ *
+ * In this module there is also support for a crooss-certification of
+ * Ed25519 identities using (older) RSA1024 identities.
+ *
+ * Tor uses other types of certificate too, beyond those described in this
+ * module. Notably, our use of TLS requires us to touch X.509 certificates,
+ * even though sensible people would stay away from those. Our X.509
+ * certificates are represented with tor_x509_cert_t, and implemented in
+ * tortls.c. We also have a separate certificate type that authorities
+ * use to authenticate their RSA signing keys with their RSA identity keys:
+ * that one is authority_cert_t, and it's mostly handled in routerlist.c.
*/
#include "crypto.h"
1
0

26 Oct '16
commit a91f2dc9f51c2bd0e7c20e13a84c66dcb60ccd3d
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Wed Oct 26 15:23:25 2016 +0200
Split up clients.csv for faster graphs.
Most client graphs (except for clients by country and transport) use
the same clients.csv file as input. That file has grown to 26M by
now, and it seems wasteful to read numbers for clients connecting to
bridges (relays) when graphing clients connecting to relays (bridges).
Split up clients.csv and take out the node column.
Performance gain is 1.3 seconds for updating graphs on directly
connecting clients and 2.0 seconds for graphs showing clients
connecting via bridges.
---
modules/clients/split-clients.R | 6 ++++++
shared/bin/80-run-clients-stats.sh | 5 ++++-
shared/bin/99-copy-stats-files.sh | 2 +-
website/rserve/graphs.R | 26 ++++++++++++--------------
4 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/modules/clients/split-clients.R b/modules/clients/split-clients.R
new file mode 100644
index 0000000..5f3cb74
--- /dev/null
+++ b/modules/clients/split-clients.R
@@ -0,0 +1,6 @@
+u <- read.csv("clients.csv", stringsAsFactors = FALSE)
+write.csv(u[u$node == 'relay', names(u) != "node"], 'clients-relay.csv',
+ quote = FALSE, row.names = FALSE, na = '')
+write.csv(u[u$node == 'bridge', names(u) != "node"], 'clients-bridge.csv',
+ quote = FALSE, row.names = FALSE, na = '')
+
diff --git a/shared/bin/80-run-clients-stats.sh b/shared/bin/80-run-clients-stats.sh
index b296c37..a3efbe3 100755
--- a/shared/bin/80-run-clients-stats.sh
+++ b/shared/bin/80-run-clients-stats.sh
@@ -21,8 +21,11 @@ python detector.py
echo `date` "Merging censorship detector results."
R --slave -f merge-clients.R > /dev/null 2>&1
+
+echo `date` "Splitting results file."
+R --slave -f split-clients.R > /dev/null 2>&1
mkdir -p stats/
-cp clients.csv stats/
+cp clients*.csv stats/
cp userstats-combined.csv stats/
echo `date` "Terminating."
diff --git a/shared/bin/99-copy-stats-files.sh b/shared/bin/99-copy-stats-files.sh
index 504216a..6daf22b 100755
--- a/shared/bin/99-copy-stats-files.sh
+++ b/shared/bin/99-copy-stats-files.sh
@@ -4,6 +4,6 @@ cp -a modules/legacy/stats/*.csv shared/stats/
cp -a modules/connbidirect/stats/connbidirect2.csv shared/stats/
cp -a modules/advbwdist/stats/advbwdist.csv shared/stats/
cp -a modules/hidserv/stats/hidserv.csv shared/stats/
-cp -a modules/clients/stats/clients.csv shared/stats/
+cp -a modules/clients/stats/clients*.csv shared/stats/
cp -a modules/clients/stats/userstats-combined.csv shared/stats/
diff --git a/website/rserve/graphs.R b/website/rserve/graphs.R
index e3ccb06..6f7e119 100644
--- a/website/rserve/graphs.R
+++ b/website/rserve/graphs.R
@@ -766,21 +766,21 @@ plot_userstats <- function(start, end, node, variable, value, events,
path) {
end <- min(end, as.character(Sys.Date() - 2))
c <- read.csv(paste("/srv/metrics.torproject.org/metrics/shared/stats/",
- "clients.csv", sep = ""), stringsAsFactors = FALSE)
+ "clients-", node, ".csv", sep = ""),
+ stringsAsFactors = FALSE)
u <- c[c$date >= start & c$date <= end, ]
- u <- rbind(u, data.frame(date = start, node = node,
+ u <- rbind(u, data.frame(date = start,
country = ifelse(variable == 'country' & value != 'all', value, ''),
transport = ifelse(variable == 'transport', value, ''),
version = ifelse(variable == 'version', value, ''),
lower = 0, upper = 0, clients = 0, frac = 0))
if (node == 'relay') {
if (value != 'all') {
- u <- u[u$country == value & u$node == 'relay', ]
+ u <- u[u$country == value, ]
title <- paste("Directly connecting users from ",
countryname(value), "\n", sep = "")
} else {
- u <- u[u$country == '' & u$transport == '' & u$version == '' &
- u$node == 'relay', ]
+ u <- u[u$country == '', ]
title <- "Directly connecting users\n"
}
u <- aggregate(list(lower = u$lower, upper = u$upper,
@@ -790,20 +790,19 @@ plot_userstats <- function(start, end, node, variable, value, events,
FUN = sum)
} else if (variable == 'transport') {
if ('!<OR>' %in% value) {
- n <- u[u$transport != '' & u$transport != '<OR>' &
- u$node == 'bridge', ]
+ n <- u[u$transport != '' & u$transport != '<OR>', ]
n <- aggregate(list(lower = n$lower, upper = n$upper,
clients = n$clients),
by = list(date = n$date),
FUN = sum)
- u <- rbind(u, data.frame(date = n$date, node = 'bridge',
+ u <- rbind(u, data.frame(date = n$date,
country = '', transport = '!<OR>',
version = '', lower = n$lower,
upper = n$upper, clients = n$clients,
frac = NA))
}
if (length(value) > 1) {
- u <- u[u$transport %in% value & u$node == 'bridge', ]
+ u <- u[u$transport %in% value, ]
u <- aggregate(list(lower = u$lower, upper = u$upper,
users = u$clients),
by = list(date = as.Date(u$date, "%Y-%m-%d"),
@@ -811,7 +810,7 @@ plot_userstats <- function(start, end, node, variable, value, events,
FUN = sum)
title <- paste("Bridge users by transport\n")
} else {
- u <- u[u$transport == value & u$node == 'bridge', ]
+ u <- u[u$transport == value, ]
u <- aggregate(list(lower = u$lower, upper = u$upper,
users = u$clients),
by = list(date = as.Date(u$date, "%Y-%m-%d"),
@@ -826,7 +825,7 @@ plot_userstats <- function(start, end, node, variable, value, events,
paste('transport', value)))))), "\n", sep = "")
}
} else if (variable == 'version') {
- u <- u[u$version == value & u$node == 'bridge', ]
+ u <- u[u$version == value, ]
title <- paste("Bridge users using IP", value, "\n", sep = "")
u <- aggregate(list(lower = u$lower, upper = u$upper,
users = u$clients),
@@ -835,12 +834,11 @@ plot_userstats <- function(start, end, node, variable, value, events,
FUN = sum)
} else {
if (value != 'all') {
- u <- u[u$country == value & u$node == 'bridge', ]
+ u <- u[u$country == value, ]
title <- paste("Bridge users from ", countryname(value),
"\n", sep = "")
} else {
- u <- u[u$country == '' & u$transport == '' & u$version == '' &
- u$node == 'bridge', ]
+ u <- u[u$country == '' & u$transport == '' & u$version == '', ]
title <- "Bridge users\n"
}
u <- aggregate(list(lower = u$lower, upper = u$upper,
1
0

[metrics-web/master] Put a quote from Bruce Schneier on the home page.
by karsten@torproject.org 26 Oct '16
by karsten@torproject.org 26 Oct '16
26 Oct '16
commit eac64e3b8b5f24094f34e6f71b0c0b060e5bd2b4
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Wed Oct 26 15:34:56 2016 +0200
Put a quote from Bruce Schneier on the home page.
---
website/web/WEB-INF/index.jsp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/website/web/WEB-INF/index.jsp b/website/web/WEB-INF/index.jsp
index 6c72137..68ea0bd 100644
--- a/website/web/WEB-INF/index.jsp
+++ b/website/web/WEB-INF/index.jsp
@@ -22,6 +22,11 @@
<a href="https://www.torproject.org/about/contact.html.en">let us
know</a>.</small></p>
+<p>"Tor metrics are the ammunition that lets Tor and other security
+advocates argue for a more private and secure Internet from a position
+of data, rather than just dogma or perspective."
+<i>- Bruce Schneier (June 1, 2016)</i></p>
+
<div>
<div style="border:1px solid gray;border-radius:10px;padding:10px;float:left;overflow:hidden;margin-right:20px;">
<form action="/">
1
0

[tor-browser/tor-browser-45.4.0esr-6.5-1] fixup! Bug 1070710 - Add mozilla::ViewRegion which assembles a LayoutDeviceIntRegion as NSViews. r=spohl
by gk@torproject.org 26 Oct '16
by gk@torproject.org 26 Oct '16
26 Oct '16
commit a6b4bb9a9d2769e8be110f2f0486b9ec74882575
Author: Kathy Brade <brade(a)pearlcrescent.com>
Date: Tue Oct 25 23:01:20 2016 -0400
fixup! Bug 1070710 - Add mozilla::ViewRegion which assembles a LayoutDeviceIntRegion as NSViews. r=spohl
OSX: Fix a problem where clicking and dragging in the content area of a
window would sometimes cause the window to move. This is a fixup for an
error introduced while backporting a Mozilla patch for Tor bug 20204.
---
widget/cocoa/ViewRegion.mm | 1 -
1 file changed, 1 deletion(-)
diff --git a/widget/cocoa/ViewRegion.mm b/widget/cocoa/ViewRegion.mm
index 3459849..ee31889 100644
--- a/widget/cocoa/ViewRegion.mm
+++ b/widget/cocoa/ViewRegion.mm
@@ -56,7 +56,6 @@ ViewRegion::UpdateRegion(const LayoutDeviceIntRegion& aRegion,
}
[view setNeedsDisplay:YES];
mViews.AppendElement(view);
- iter.Next();
} else {
// Our new region is made of fewer rects than the old region, so we can
// remove this view. We only have a weak reference to it, so removing it
1
0
commit 04b8af9dc0389e8a3d1779e883b999240dec3a2b
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Wed Oct 26 08:39:04 2016 -0400
Whitespace fixes
---
src/or/scheduler.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/or/scheduler.c b/src/or/scheduler.c
index ae2e950..033e6d1 100644
--- a/src/or/scheduler.c
+++ b/src/or/scheduler.c
@@ -35,8 +35,8 @@ static uint32_t sched_max_flush_cells = 16;
* This module implements a scheduler algorithm, to decide
* which channels should send/receive when.
*
- * The earliest versions of Tor approximated a kind of round-robin system among
- * active connections, but only approximated it.
+ * The earliest versions of Tor approximated a kind of round-robin system
+ * among active connections, but only approximated it.
*
* Now, write scheduling works by keeping track of which channels can
* accept cells, and have cells to write. From the scheduler's perspective,
@@ -44,9 +44,9 @@ static uint32_t sched_max_flush_cells = 16;
*
* <ol>
* <li>
- * Not open for writes, no cells to send .
- * <ul><li> Not much to do here, and the channel will have scheduler_state ==
- * SCHED_CHAN_IDLE
+ * Not open for writes, no cells to send.
+ * <ul><li> Not much to do here, and the channel will have scheduler_state
+ * == SCHED_CHAN_IDLE
* <li> Transitions from:
* <ul>
* <li>Open for writes/has cells by simultaneously draining all circuit
@@ -63,9 +63,9 @@ static uint32_t sched_max_flush_cells = 16;
*
* <li> Open for writes, no cells to send
* <ul>
- * <li>Not much here either; this will be the state an idle but open channel
- * can be expected to settle in. It will have scheduler_state ==
- * SCHED_CHAN_WAITING_FOR_CELLS
+ * <li>Not much here either; this will be the state an idle but open
+ * channel can be expected to settle in. It will have scheduler_state
+ * == SCHED_CHAN_WAITING_FOR_CELLS
* <li> Transitions from:
* <ul>
* <li>Not open for writes/no cells by flushing some of the output
1
0

[tor/master] Allow asking a bridge's own descriptor over one-hop connection
by nickm@torproject.org 26 Oct '16
by nickm@torproject.org 26 Oct '16
26 Oct '16
commit 8cc528c75067567ef32822e5bdb39535cea5d5e8
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Tue Oct 25 19:30:50 2016 -0400
Allow asking a bridge's own descriptor over one-hop connection
When we refactored purpose_needs_anonymity(), we made it so _all_
bridge requests required anonymity. But that missed the case
that we are allowed to ask a bridge for its own descriptor.
With this patch, we consider the resource, and allow "authority.z"
("your own descriptor, compressed") for a bridge's server descriptor
to be non-anonymous.
Fix for bug 20410; bug not in any released Tor.
---
src/or/connection_edge.c | 4 +++-
src/or/directory.c | 22 ++++++++++++++------
src/or/directory.h | 3 ++-
src/or/routerlist.c | 3 ++-
src/test/test_dir.c | 52 +++++++++++++++++++++++++++++++++---------------
5 files changed, 59 insertions(+), 25 deletions(-)
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 44dfcef..1ee0c0f 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2434,7 +2434,9 @@ connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
* Otherwise, directory connections are typically one-hop.
* This matches the earlier check for directory connection path anonymity
* in directory_initiate_command_rend(). */
- if (purpose_needs_anonymity(linked_dir_conn_base->purpose, 0)) {
+ if (purpose_needs_anonymity(linked_dir_conn_base->purpose,
+ TO_DIR_CONN(linked_dir_conn_base)->router_purpose,
+ TO_DIR_CONN(linked_dir_conn_base)->requested_resource)) {
assert_circ_anonymity_ok(circ, options);
}
} else {
diff --git a/src/or/directory.c b/src/or/directory.c
index facd588..a73680a 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -127,14 +127,23 @@ static void connection_dir_close_consensus_fetches(
* specifically been configured to be over an anonymous connection,
* or 3) if the router is a bridge */
int
-purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose)
+purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose,
+ const char *resource)
{
if (get_options()->AllDirActionsPrivate)
return 1;
- if (router_purpose == ROUTER_PURPOSE_BRIDGE)
+ if (router_purpose == ROUTER_PURPOSE_BRIDGE) {
+ if (dir_purpose == DIR_PURPOSE_FETCH_SERVERDESC
+ && resource && !strcmp(resource, "authority.z")) {
+ /* We are asking a bridge for its own descriptor. That doesn't need
+ anonymity. */
+ return 0;
+ }
+ /* Assume all other bridge stuff needs anonymity. */
return 1; /* if no circuits yet, this might break bootstrapping, but it's
* needed to be safe. */
+ }
switch (dir_purpose)
{
@@ -364,7 +373,7 @@ directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
log_info(LD_DIR, "Uploading an extrainfo too (length %d)",
(int) extrainfo_len);
}
- if (purpose_needs_anonymity(dir_purpose, router_purpose)) {
+ if (purpose_needs_anonymity(dir_purpose, router_purpose, NULL)) {
indirection = DIRIND_ANONYMOUS;
} else if (!fascist_firewall_allows_dir_server(ds,
FIREWALL_DIR_CONNECTION,
@@ -458,7 +467,8 @@ MOCK_IMPL(void, directory_get_from_dirserver, (
int prefer_authority = (directory_fetches_from_authorities(options)
|| want_authority == DL_WANT_AUTHORITY);
int require_authority = 0;
- int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose);
+ int get_via_tor = purpose_needs_anonymity(dir_purpose, router_purpose,
+ resource);
dirinfo_type_t type = dir_fetch_type(dir_purpose, router_purpose, resource);
time_t if_modified_since = 0;
@@ -592,7 +602,7 @@ MOCK_IMPL(void, directory_get_from_dirserver, (
"While fetching directory info, "
"no running dirservers known. Will try again later. "
"(purpose %d)", dir_purpose);
- if (!purpose_needs_anonymity(dir_purpose, router_purpose)) {
+ if (!purpose_needs_anonymity(dir_purpose, router_purpose, resource)) {
/* remember we tried them all and failed. */
directory_all_unreachable(time(NULL));
}
@@ -1142,7 +1152,7 @@ directory_initiate_command_rend(const tor_addr_port_t *or_addr_port,
log_debug(LD_DIR, "Initiating %s", dir_conn_purpose_to_string(dir_purpose));
- if (purpose_needs_anonymity(dir_purpose, router_purpose)) {
+ if (purpose_needs_anonymity(dir_purpose, router_purpose, resource)) {
tor_assert(anonymized_connection ||
rend_non_anonymous_mode_enabled(options));
}
diff --git a/src/or/directory.h b/src/or/directory.h
index f04e7ab..f1cdd9f 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -132,7 +132,8 @@ int download_status_get_n_failures(const download_status_t *dls);
int download_status_get_n_attempts(const download_status_t *dls);
time_t download_status_get_next_attempt_at(const download_status_t *dls);
-int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose);
+int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose,
+ const char *resource);
#ifdef TOR_UNIT_TESTS
/* Used only by directory.c and test_dir.c */
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 83a2587..6f182d3 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -929,7 +929,8 @@ authority_certs_fetch_resource_impl(const char *resource,
const routerstatus_t *rs)
{
const or_options_t *options = get_options();
- int get_via_tor = purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0);
+ int get_via_tor = purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0,
+ resource);
/* Make sure bridge clients never connect to anything but a bridge */
if (options->UseBridges) {
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index d9c565c..419aa24 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -3258,7 +3258,7 @@ test_dir_purpose_needs_anonymity_returns_true_by_default(void *arg)
(void)arg;
tor_capture_bugs_(1);
- tt_int_op(1, ==, purpose_needs_anonymity(0, 0));
+ tt_int_op(1, ==, purpose_needs_anonymity(0, 0, NULL));
tt_int_op(1, ==, smartlist_len(tor_get_captured_bug_log_()));
tor_end_capture_bugs_();
done: ;
@@ -3269,9 +3269,21 @@ test_dir_purpose_needs_anonymity_returns_true_for_bridges(void *arg)
{
(void)arg;
- tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE));
+ tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE, NULL));
+ tt_int_op(1, ==, purpose_needs_anonymity(0, ROUTER_PURPOSE_BRIDGE,
+ "foobar"));
tt_int_op(1, ==, purpose_needs_anonymity(DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2,
- ROUTER_PURPOSE_BRIDGE));
+ ROUTER_PURPOSE_BRIDGE, NULL));
+ done: ;
+}
+
+static void
+test_dir_purpose_needs_anonymity_returns_false_for_own_bridge_desc(void *arg)
+{
+ (void)arg;
+ tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC,
+ ROUTER_PURPOSE_BRIDGE,
+ "authority.z"));
done: ;
}
@@ -3282,11 +3294,11 @@ test_dir_purpose_needs_anonymity_returns_true_for_sensitive_purpose(void *arg)
tt_int_op(1, ==, purpose_needs_anonymity(
DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2,
- ROUTER_PURPOSE_GENERAL));
+ ROUTER_PURPOSE_GENERAL, NULL));
tt_int_op(1, ==, purpose_needs_anonymity(
- DIR_PURPOSE_UPLOAD_RENDDESC_V2, 0));
+ DIR_PURPOSE_UPLOAD_RENDDESC_V2, 0, NULL));
tt_int_op(1, ==, purpose_needs_anonymity(
- DIR_PURPOSE_FETCH_RENDDESC_V2, 0));
+ DIR_PURPOSE_FETCH_RENDDESC_V2, 0, NULL));
done: ;
}
@@ -3296,17 +3308,24 @@ test_dir_purpose_needs_anonymity_ret_false_for_non_sensitive_conn(void *arg)
(void)arg;
tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_DIR,
- ROUTER_PURPOSE_GENERAL));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_VOTE, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_SIGNATURES, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_STATUS_VOTE, 0));
+ ROUTER_PURPOSE_GENERAL, NULL));
+ tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_VOTE, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_UPLOAD_SIGNATURES, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_FETCH_STATUS_VOTE, 0, NULL));
tt_int_op(0, ==, purpose_needs_anonymity(
- DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_CONSENSUS, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_EXTRAINFO, 0));
- tt_int_op(0, ==, purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC, 0));
+ DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_FETCH_CONSENSUS, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_FETCH_CERTIFICATE, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_FETCH_SERVERDESC, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_FETCH_EXTRAINFO, 0, NULL));
+ tt_int_op(0, ==,
+ purpose_needs_anonymity(DIR_PURPOSE_FETCH_MICRODESC, 0, NULL));
done: ;
}
@@ -5512,6 +5531,7 @@ struct testcase_t dir_tests[] = {
DIR(dirserv_set_routerstatus_testing, 0),
DIR(http_handling, 0),
DIR(purpose_needs_anonymity_returns_true_for_bridges, 0),
+ DIR(purpose_needs_anonymity_returns_false_for_own_bridge_desc, 0),
DIR(purpose_needs_anonymity_returns_true_by_default, 0),
DIR(purpose_needs_anonymity_returns_true_for_sensitive_purpose, 0),
DIR(purpose_needs_anonymity_ret_false_for_non_sensitive_conn, 0),
1
0
commit 90f074af25f7f21a5cec699a65467b51622ebbde
Author: Karsten Loesing <karsten.loesing(a)gmx.net>
Date: Wed Oct 26 09:27:45 2016 +0200
Become Java 7 compliant again.
---
.../torproject/collector/persist/PersistUtilsTest.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/test/java/org/torproject/collector/persist/PersistUtilsTest.java b/src/test/java/org/torproject/collector/persist/PersistUtilsTest.java
index 0fcfe14..50ace87 100644
--- a/src/test/java/org/torproject/collector/persist/PersistUtilsTest.java
+++ b/src/test/java/org/torproject/collector/persist/PersistUtilsTest.java
@@ -11,6 +11,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -36,7 +37,7 @@ public class PersistUtilsTest {
assertFalse("Files shouldn't be created.",
PersistenceUtils.storeToFileSystem(ANNO1.getBytes(),
"some text".getBytes(), out, StandardOpenOption.CREATE_NEW, true));
- List<String> text = Files.readAllLines(out);
+ List<String> text = Files.readAllLines(out, StandardCharsets.UTF_8);
assertTrue("List should be empty: " + text, text.isEmpty());
}
@@ -48,7 +49,8 @@ public class PersistUtilsTest {
assertTrue("Files should be created.",
PersistenceUtils.storeToFileSystem(ANNO1.getBytes(),
(theText + "\n").getBytes(), pathToCreate, StandardOpenOption.CREATE));
- List<String> text = Files.readAllLines(pathToCreate);
+ List<String> text = Files.readAllLines(pathToCreate,
+ StandardCharsets.UTF_8);
assertEquals("File contained: " + text, 2, text.size());
assertEquals("File contained: " + text, theText, text.get(1));
}
@@ -61,7 +63,8 @@ public class PersistUtilsTest {
assertTrue("Files should be created.",
PersistenceUtils.storeToFileSystem(ANNO1.getBytes(),
(theText + "\n").getBytes(), pathToCreate, StandardOpenOption.CREATE));
- List<String> text = Files.readAllLines(pathToCreate);
+ List<String> text = Files.readAllLines(pathToCreate,
+ StandardCharsets.UTF_8);
assertEquals("File contained: " + text, 2, text.size());
assertEquals("File contained: " + text, theText, text.get(1));
String theText2 = "other symbols";
@@ -69,7 +72,7 @@ public class PersistUtilsTest {
PersistenceUtils.storeToFileSystem((ANNO2).getBytes(),
(theText2 + "\n").getBytes(), pathToCreate,
StandardOpenOption.TRUNCATE_EXISTING));
- text = Files.readAllLines(pathToCreate);
+ text = Files.readAllLines(pathToCreate, StandardCharsets.UTF_8);
assertEquals("File contained: " + text, 2, text.size());
assertEquals("File contained: " + text, "2@annotation", text.get(0));
assertEquals("File contained: " + text, theText2, text.get(1));
@@ -83,14 +86,15 @@ public class PersistUtilsTest {
assertTrue("Files should be created.",
PersistenceUtils.storeToFileSystem(ANNO1.getBytes(),
(theText + "\n").getBytes(), pathToCreate, StandardOpenOption.CREATE));
- List<String> text = Files.readAllLines(pathToCreate);
+ List<String> text = Files.readAllLines(pathToCreate,
+ StandardCharsets.UTF_8);
assertEquals("File contained: " + text, 2, text.size());
assertEquals("File contained: " + text, theText, text.get(1));
String theText2 = "other symbols";
assertTrue("Files should be created.",
PersistenceUtils.storeToFileSystem((ANNO2).getBytes(),
(theText2 + "\n").getBytes(), pathToCreate, StandardOpenOption.APPEND));
- text = Files.readAllLines(pathToCreate);
+ text = Files.readAllLines(pathToCreate, StandardCharsets.UTF_8);
assertEquals("File contained: " + text, 4, text.size());
assertEquals("File contained: " + text, "1@annotation", text.get(0));
assertEquals("File contained: " + text, theText, text.get(1));
1
0