diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-10-06 17:32:18 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-10-06 17:50:46 +0200 |
commit | 4fac576c619f450da8ca09ac8790063b3dea4364 (patch) | |
tree | 36184ec8419bc1ae12a0285c58406a745e7a6d71 /src/streams.h | |
parent | b7d78fd0bd244b324ded4131c1dd0ec81a87d15d (diff) | |
parent | 42cb388167ef78f47a3a440eb651b6938c10f508 (diff) | |
download | bitcoin-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.h | 23 |
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; + } + } }; |