summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-27 15:59:07 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-27 16:18:42 -0400
commit235ddb15a0f9fc322002ba39e8900634316dc333 (patch)
tree8b18c9ff270a8f2413cab4fa9408b60dade0baf0
parent3cff3e825a1478fc3350bbca16f091b8f635f921 (diff)
downloadtor-235ddb15a0f9fc322002ba39e8900634316dc333.tar.gz
tor-235ddb15a0f9fc322002ba39e8900634316dc333.zip
Move util_format into a new libtor-encoding library
libtor-encoding is about various ways to transform data to and from character sequences.
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am2
-rw-r--r--src/common/include.am2
-rw-r--r--src/common/util.c2
-rw-r--r--src/include.am1
-rw-r--r--src/lib/crypt_ops/.may_include1
-rw-r--r--src/lib/crypt_ops/crypto.c2
-rw-r--r--src/lib/crypt_ops/crypto_ed25519.c2
-rw-r--r--src/lib/crypt_ops/crypto_format.c2
-rw-r--r--src/lib/crypt_ops/crypto_rand.c2
-rw-r--r--src/lib/crypt_ops/crypto_rsa.c2
-rw-r--r--src/lib/encoding/.may_include8
-rw-r--r--src/lib/encoding/binascii.c (renamed from src/common/util_format.c)11
-rw-r--r--src/lib/encoding/binascii.h (renamed from src/common/util_format.h)6
-rw-r--r--src/lib/encoding/include.am16
-rw-r--r--src/or/keypin.c2
-rw-r--r--src/or/or.h2
-rw-r--r--src/or/parsecommon.c2
-rw-r--r--src/or/shared_random_client.c2
-rw-r--r--src/rust/build.rs1
-rw-r--r--src/test/test_crypto_openssl.c2
-rw-r--r--src/test/test_util_format.c2
-rw-r--r--src/tools/tor-gencert.c2
23 files changed, 55 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore
index 02e8bb77c0..5198daf4f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,6 +171,8 @@ uptime-*.json
/src/lib/libtor-crypt-ops-testing.a
/src/lib/libtor-ctime.a
/src/lib/libtor-ctime-testing.a
+/src/lib/libtor-encoding.a
+/src/lib/libtor-encoding-testing.a
/src/lib/libtor-err.a
/src/lib/libtor-err-testing.a
/src/lib/libtor-fdio.a
diff --git a/Makefile.am b/Makefile.am
index ef727e01f5..c016310a68 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,6 +41,7 @@ endif
TOR_UTIL_LIBS = \
src/common/libor.a \
src/lib/libtor-fs.a \
+ src/lib/libtor-encoding.a \
src/lib/libtor-sandbox.a \
src/lib/libtor-container.a \
src/lib/libtor-net.a \
@@ -60,6 +61,7 @@ TOR_UTIL_LIBS = \
TOR_UTIL_TESTING_LIBS = \
src/common/libor-testing.a \
src/lib/libtor-fs-testing.a \
+ src/lib/libtor-encoding-testing.a \
src/lib/libtor-sandbox-testing.a \
src/lib/libtor-container-testing.a \
src/lib/libtor-net-testing.a \
diff --git a/src/common/include.am b/src/common/include.am
index c8be3658e9..2360c7f775 100644
--- a/src/common/include.am
+++ b/src/common/include.am
@@ -39,7 +39,6 @@ LIBOR_A_SRC = \
src/common/confline.c \
src/common/memarea.c \
src/common/util.c \
- src/common/util_format.c \
src/common/util_process.c \
src/common/storagedir.c \
src/common/token_bucket.c \
@@ -88,7 +87,6 @@ COMMONHEADERS = \
src/common/timers.h \
src/common/token_bucket.h \
src/common/util.h \
- src/common/util_format.h \
src/common/util_process.h \
src/common/workqueue.h
diff --git a/src/common/util.c b/src/common/util.c
index 497f549727..92742a8147 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -24,7 +24,7 @@
#include "lib/sandbox/sandbox.h"
#include "lib/err/backtrace.h"
#include "common/util_process.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#ifdef _WIN32
#include <io.h>
diff --git a/src/include.am b/src/include.am
index 62234d4682..c83ec0d579 100644
--- a/src/include.am
+++ b/src/include.am
@@ -7,6 +7,7 @@ include src/lib/compress/include.am
include src/lib/container/include.am
include src/lib/crypt_ops/include.am
include src/lib/defs/include.am
+include src/lib/encoding/include.am
include src/lib/fdio/include.am
include src/lib/fs/include.am
include src/lib/include.libdonna.am
diff --git a/src/lib/crypt_ops/.may_include b/src/lib/crypt_ops/.may_include
index d05e86f720..dad6d5fc6a 100644
--- a/src/lib/crypt_ops/.may_include
+++ b/src/lib/crypt_ops/.may_include
@@ -4,6 +4,7 @@ lib/container/*.h
lib/crypt_ops/*.h
lib/ctime/*.h
lib/defs/*.h
+lib/encoding/*.h
lib/malloc/*.h
lib/err/*.h
lib/intmath/*.h
diff --git a/src/lib/crypt_ops/crypto.c b/src/lib/crypt_ops/crypto.c
index 1935803979..efd355928f 100644
--- a/src/lib/crypt_ops/crypto.c
+++ b/src/lib/crypt_ops/crypto.c
@@ -67,7 +67,7 @@ ENABLE_GCC_WARNING(redundant-decls)
#include "lib/crypt_ops/aes.h"
#include "common/util.h"
#include "common/compat.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "keccak-tiny/keccak-tiny.h"
diff --git a/src/lib/crypt_ops/crypto_ed25519.c b/src/lib/crypt_ops/crypto_ed25519.c
index 5655fbf508..b0e23e29c6 100644
--- a/src/lib/crypt_ops/crypto_ed25519.c
+++ b/src/lib/crypt_ops/crypto_ed25519.c
@@ -29,7 +29,7 @@
#include "lib/crypt_ops/crypto_util.h"
#include "lib/log/torlog.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "ed25519/ref10/ed25519_ref10.h"
#include "ed25519/donna/ed25519_donna_tor.h"
diff --git a/src/lib/crypt_ops/crypto_format.c b/src/lib/crypt_ops/crypto_format.c
index 888c0794ec..131aa449e0 100644
--- a/src/lib/crypt_ops/crypto_format.c
+++ b/src/lib/crypt_ops/crypto_format.c
@@ -22,7 +22,7 @@
#include "lib/crypt_ops/crypto_util.h"
#include "lib/string/util_string.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "lib/log/torlog.h"
/** Write the <b>datalen</b> bytes from <b>data</b> to the file named
diff --git a/src/lib/crypt_ops/crypto_rand.c b/src/lib/crypt_ops/crypto_rand.c
index bf6a35ddbc..247a502241 100644
--- a/src/lib/crypt_ops/crypto_rand.c
+++ b/src/lib/crypt_ops/crypto_rand.c
@@ -29,7 +29,7 @@
#include "lib/testsupport/testsupport.h"
#include "lib/log/torlog.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
DISABLE_GCC_WARNING(redundant-decls)
#include <openssl/rand.h>
diff --git a/src/lib/crypt_ops/crypto_rsa.c b/src/lib/crypt_ops/crypto_rsa.c
index 3f2f8544f7..a62c0018f9 100644
--- a/src/lib/crypt_ops/crypto_rsa.c
+++ b/src/lib/crypt_ops/crypto_rsa.c
@@ -35,7 +35,7 @@ ENABLE_GCC_WARNING(redundant-decls)
#include "lib/log/torlog.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
/** Declaration for crypto_pk_t structure. */
struct crypto_pk_t
diff --git a/src/lib/encoding/.may_include b/src/lib/encoding/.may_include
new file mode 100644
index 0000000000..299e0fc4f6
--- /dev/null
+++ b/src/lib/encoding/.may_include
@@ -0,0 +1,8 @@
+orconfig.h
+lib/cc/*.h
+lib/encoding/*.h
+lib/intmath/*.h
+lib/log/*.h
+lib/malloc/*.h
+lib/string/*.h
+lib/testsupport/*.h
diff --git a/src/common/util_format.c b/src/lib/encoding/binascii.c
index 04fd59d660..554b95016b 100644
--- a/src/common/util_format.c
+++ b/src/lib/encoding/binascii.c
@@ -5,18 +5,21 @@
/* See LICENSE for licensing information */
/**
- * \file util_format.c
+ * \file binascii.c
*
* \brief Miscellaneous functions for encoding and decoding various things
* in base{16,32,64}.
*/
#include "orconfig.h"
-#include <stddef.h>
+
+#include "lib/encoding/binascii.h"
#include "lib/log/torlog.h"
-#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/log/util_bug.h"
#include "lib/cc/torint.h"
+#include "lib/string/compat_ctype.h"
+#include "lib/intmath/muldiv.h"
+#include "lib/malloc/util_malloc.h"
#include <stddef.h>
#include <string.h>
diff --git a/src/common/util_format.h b/src/lib/encoding/binascii.h
index 713fd0d003..04310f4ed9 100644
--- a/src/common/util_format.h
+++ b/src/lib/encoding/binascii.h
@@ -4,9 +4,11 @@
* Copyright (c) 2007-2018, The Tor Project, Inc. */
/* See LICENSE for licensing information */
-#ifndef TOR_UTIL_FORMAT_H
-#define TOR_UTIL_FORMAT_H
+#ifndef TOR_BINASCII_H
+#define TOR_BINASCII_H
+#include "orconfig.h"
+#include <stddef.h>
#include "lib/testsupport/testsupport.h"
#include "lib/cc/torint.h"
diff --git a/src/lib/encoding/include.am b/src/lib/encoding/include.am
new file mode 100644
index 0000000000..fcd9baf3da
--- /dev/null
+++ b/src/lib/encoding/include.am
@@ -0,0 +1,16 @@
+noinst_LIBRARIES += src/lib/libtor-encoding.a
+
+if UNITTESTS_ENABLED
+noinst_LIBRARIES += src/lib/libtor-encoding-testing.a
+endif
+
+src_lib_libtor_encoding_a_SOURCES = \
+ src/lib/encoding/binascii.c
+
+src_lib_libtor_encoding_testing_a_SOURCES = \
+ $(src_lib_libtor_encoding_a_SOURCES)
+src_lib_libtor_encoding_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
+src_lib_libtor_encoding_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+
+noinst_HEADERS += \
+ src/lib/encoding/binascii.h
diff --git a/src/or/keypin.c b/src/or/keypin.c
index db267673f8..8e1ef099a4 100644
--- a/src/or/keypin.c
+++ b/src/or/keypin.c
@@ -22,7 +22,7 @@
#include "lib/log/torlog.h"
#include "lib/fdio/fdio.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
diff --git a/src/or/or.h b/src/or/or.h
index a71cb6b00a..df0e60c262 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -81,7 +81,7 @@
#include "lib/crypt_ops/crypto_ed25519.h"
#include "tor_queue.h"
#include "common/token_bucket.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "or/hs_circuitmap.h"
// These, more than other includes, are for keeping the other struct
diff --git a/src/or/parsecommon.c b/src/or/parsecommon.c
index 17a7c6a891..3b6e15b0f3 100644
--- a/src/or/parsecommon.c
+++ b/src/or/parsecommon.c
@@ -8,7 +8,7 @@
#include "or/parsecommon.h"
#include "lib/log/torlog.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "lib/container/smartlist.h"
#define MIN_ANNOTATION A_PURPOSE
diff --git a/src/or/shared_random_client.c b/src/or/shared_random_client.c
index f0b13a171e..9a6c0f6644 100644
--- a/src/or/shared_random_client.c
+++ b/src/or/shared_random_client.c
@@ -15,7 +15,7 @@
#include "or/voting_schedule.h"
#include "or/networkstatus.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "or/networkstatus_st.h"
diff --git a/src/rust/build.rs b/src/rust/build.rs
index 90f53bd235..36f847d2e2 100644
--- a/src/rust/build.rs
+++ b/src/rust/build.rs
@@ -152,6 +152,7 @@ pub fn main() {
cfg.component("tor-crypt-ops-testing");
cfg.component("or-testing");
cfg.component("tor-sandbox");
+ cfg.component("tor-encoding-testing");
cfg.component("tor-net");
cfg.component("tor-log");
cfg.component("tor-lock");
diff --git a/src/test/test_crypto_openssl.c b/src/test/test_crypto_openssl.c
index cc817ad702..a01de18a6e 100644
--- a/src/test/test_crypto_openssl.c
+++ b/src/test/test_crypto_openssl.c
@@ -9,7 +9,7 @@
#include "lib/crypt_ops/crypto_rand.h"
#include "common/util.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#include "common/compat.h"
#include "test/test.h"
diff --git a/src/test/test_util_format.c b/src/test/test_util_format.c
index 931a184e7a..44a00b9b77 100644
--- a/src/test/test_util_format.c
+++ b/src/test/test_util_format.c
@@ -8,7 +8,7 @@
#include "lib/crypt_ops/crypto_rand.h"
#define UTIL_FORMAT_PRIVATE
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#define NS_MODULE util_format
diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c
index f65a0e250d..2fda1cd8f8 100644
--- a/src/tools/tor-gencert.c
+++ b/src/tools/tor-gencert.c
@@ -42,7 +42,7 @@ ENABLE_GCC_WARNING(redundant-decls)
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/net/address.h"
-#include "common/util_format.h"
+#include "lib/encoding/binascii.h"
#define IDENTITY_KEY_BITS 3072
#define SIGNING_KEY_BITS 2048