aboutsummaryrefslogtreecommitdiff
path: root/src/streams.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-10-06 17:32:18 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-10-06 17:50:46 +0200
commit4fac576c619f450da8ca09ac8790063b3dea4364 (patch)
tree36184ec8419bc1ae12a0285c58406a745e7a6d71 /src/streams.h
parentb7d78fd0bd244b324ded4131c1dd0ec81a87d15d (diff)
parent42cb388167ef78f47a3a440eb651b6938c10f508 (diff)
downloadbitcoin-4fac576c619f450da8ca09ac8790063b3dea4364.tar.xz
Merge pull request #6650
42cb388 Add chainstate obfuscation to avoid spurious antivirus detection (James O'Beirne)
Diffstat (limited to 'src/streams.h')
-rw-r--r--src/streams.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/streams.h b/src/streams.h
index fa1e18defe..8610e4d18e 100644
--- a/src/streams.h
+++ b/src/streams.h
@@ -296,6 +296,29 @@ public:
data.insert(data.end(), begin(), end());
clear();
}
+
+ /**
+ * XOR the contents of this stream with a certain key.
+ *
+ * @param[in] key The key used to XOR the data in this stream.
+ */
+ void Xor(const std::vector<unsigned char>& key)
+ {
+ if (key.size() == 0) {
+ return;
+ }
+
+ for (size_type i = 0, j = 0; i != size(); i++) {
+ vch[i] ^= key[j++];
+
+ // This potentially acts on very many bytes of data, so it's
+ // important that we calculate `j`, i.e. the `key` index in this
+ // way instead of doing a %, which would effectively be a division
+ // for each byte Xor'd -- much slower than need be.
+ if (j == key.size())
+ j = 0;
+ }
+ }
};