aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-10-24 10:20:41 -0400
committerNick Mathewson <nickm@torproject.org>2018-10-24 10:20:41 -0400
commit6851a08090325dc51b26e80350395c4a0c778cf8 (patch)
tree941e575552240b461f48c18c775864defd3d920c
parentbfab7b9d353227104c3f323c964b0e80fdf60d31 (diff)
parentd1d66866b2c5e4e7ce246008f62f74d979cd8351 (diff)
downloadtor-6851a08090325dc51b26e80350395c4a0c778cf8.tar.gz
tor-6851a08090325dc51b26e80350395c4a0c778cf8.zip
Merge branch 'ticket28115_035' into maint-0.3.5
-rw-r--r--changes/bug281153
-rw-r--r--src/lib/crypt_ops/crypto_ope.c12
2 files changed, 9 insertions, 6 deletions
diff --git a/changes/bug28115 b/changes/bug28115
new file mode 100644
index 0000000000..e3e29968eb
--- /dev/null
+++ b/changes/bug28115
@@ -0,0 +1,3 @@
+ o Minor bugfixes (portability):
+ - Make the OPE code (which is used for v3 onion services) run correctly
+ on big-endian platforms. Fixes bug 28115; bugfix on 0.3.5.1-alpha.
diff --git a/src/lib/crypt_ops/crypto_ope.c b/src/lib/crypt_ops/crypto_ope.c
index fd5d5f3770..789517eba2 100644
--- a/src/lib/crypt_ops/crypto_ope.c
+++ b/src/lib/crypt_ops/crypto_ope.c
@@ -48,17 +48,17 @@ struct crypto_ope_t {
/** The type to add up in order to produce our OPE ciphertexts */
typedef uint16_t ope_val_t;
-#ifdef WORDS_BIG_ENDIAN
-/** Convert an OPE value to little-endian */
+#ifdef WORDS_BIGENDIAN
+/** Convert an OPE value from little-endian. */
static inline ope_val_t
-ope_val_to_le(ope_val_t x)
+ope_val_from_le(ope_val_t x)
{
return
((x) >> 8) |
(((x)&0xff) << 8);
}
#else
-#define ope_val_to_le(x) (x)
+#define ope_val_from_le(x) (x)
#endif
/**
@@ -104,7 +104,7 @@ sum_values_from_cipher(crypto_cipher_t *c, size_t n)
crypto_cipher_crypt_inplace(c, (char*)buf, BUFSZ*sizeof(ope_val_t));
for (i = 0; i < BUFSZ; ++i) {
- total += ope_val_to_le(buf[i]);
+ total += ope_val_from_le(buf[i]);
total += 1;
}
n -= BUFSZ;
@@ -113,7 +113,7 @@ sum_values_from_cipher(crypto_cipher_t *c, size_t n)
memset(buf, 0, n*sizeof(ope_val_t));
crypto_cipher_crypt_inplace(c, (char*)buf, n*sizeof(ope_val_t));
for (i = 0; i < n; ++i) {
- total += ope_val_to_le(buf[i]);
+ total += ope_val_from_le(buf[i]);
total += 1;
}