aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-01 11:25:29 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-01 11:25:29 -0400
commit7a61a92870df84c37bacd9d065e0c8df2b938d37 (patch)
tree444e1a8cf7e9bd1f12685d614459ce1ad122eb42 /src/lib
parentadcd1d8b9ac09f3abc11e2e3187fe363ad3df2fd (diff)
downloadtor-7a61a92870df84c37bacd9d065e0c8df2b938d37.tar.gz
tor-7a61a92870df84c37bacd9d065e0c8df2b938d37.zip
Combine DH_BYTES and DH_KEY_LEN; put them in a lib/defs header.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crypt_ops/crypto_dh.c4
-rw-r--r--src/lib/crypt_ops/crypto_dh.h4
-rw-r--r--src/lib/defs/dh_sizes.h13
-rw-r--r--src/lib/defs/include.am3
4 files changed, 18 insertions, 6 deletions
diff --git a/src/lib/crypt_ops/crypto_dh.c b/src/lib/crypt_ops/crypto_dh.c
index a2622cfc2f..c37e286daf 100644
--- a/src/lib/crypt_ops/crypto_dh.c
+++ b/src/lib/crypt_ops/crypto_dh.c
@@ -344,7 +344,7 @@ crypto_dh_generate_public(crypto_dh_t *dh)
/** Generate g^x as necessary, and write the g^x for the key exchange
* as a <b>pubkey_len</b>-byte value into <b>pubkey</b>. Return 0 on
- * success, -1 on failure. <b>pubkey_len</b> must be \>= DH_BYTES.
+ * success, -1 on failure. <b>pubkey_len</b> must be \>= DH1024_KEY_LEN.
*/
int
crypto_dh_get_public(crypto_dh_t *dh, char *pubkey, size_t pubkey_len)
@@ -378,7 +378,7 @@ crypto_dh_get_public(crypto_dh_t *dh, char *pubkey, size_t pubkey_len)
tor_assert(bytes >= 0);
if (pubkey_len < (size_t)bytes) {
log_warn(LD_CRYPTO,
- "Weird! pubkey_len (%d) was smaller than DH_BYTES (%d)",
+ "Weird! pubkey_len (%d) was smaller than DH1024_KEY_LEN (%d)",
(int) pubkey_len, bytes);
return -1;
}
diff --git a/src/lib/crypt_ops/crypto_dh.h b/src/lib/crypt_ops/crypto_dh.h
index 7b03e128a2..73a7bcb521 100644
--- a/src/lib/crypt_ops/crypto_dh.h
+++ b/src/lib/crypt_ops/crypto_dh.h
@@ -14,9 +14,7 @@
#define TOR_CRYPTO_DH_H
#include "orconfig.h"
-
-/** Length of our DH keys. */
-#define DH_BYTES (1024/8)
+#include "lib/defs/dh_sizes.h"
typedef struct crypto_dh_t crypto_dh_t;
diff --git a/src/lib/defs/dh_sizes.h b/src/lib/defs/dh_sizes.h
new file mode 100644
index 0000000000..b60957281c
--- /dev/null
+++ b/src/lib/defs/dh_sizes.h
@@ -0,0 +1,13 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_DH_SIZES_H
+#define TOR_DH_SIZES_H
+
+/** Length of our legacy DH keys. */
+#define DH1024_KEY_LEN (1024/8)
+
+#endif
diff --git a/src/lib/defs/include.am b/src/lib/defs/include.am
index ff48cff07c..b54bac555b 100644
--- a/src/lib/defs/include.am
+++ b/src/lib/defs/include.am
@@ -1,3 +1,4 @@
-noinst_HEADERS += \
+noinst_HEADERS += \
+ src/lib/defs/dh_sizes.h \
src/lib/defs/digest_sizes.h