diff options
author | Christian Pointner <equinox@anytun.org> | 2007-06-17 22:25:20 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2007-06-17 22:25:20 +0000 |
commit | 261c9067380c5311c98e3576540eee6015be3297 (patch) | |
tree | f384eb8edbcc4d35793071090839453bcb4418a4 /cypher.cpp | |
parent | added cypher and authalgo (diff) |
added [] - operator to Buffer
const Buffers are now possible
Diffstat (limited to 'cypher.cpp')
-rw-r--r-- | cypher.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -28,6 +28,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <stdexcept> + #include "datatypes.h" #include "cypher.h" @@ -35,16 +37,19 @@ void Cypher::cypher(Buffer& buf) { Buffer stream = getBitStream(buf.getLength()); - calc(buf, stream, buf.getLength()); + exor(buf, stream); } -void Cypher::calc(u_int8_t* buf, u_int8_t* bit_stream, u_int32_t length) +void Cypher::exor(Buffer& buf, const Buffer& bit_stream) { - for(u_int32_t i; i<length; ++i) - buf[i] ^= bit_stream[i]; + try + { + for(u_int32_t i; i<buf.getLength(); ++i) + buf[i] ^= bit_stream[i]; + } + catch(std::out_of_range& o) {} } - Buffer NullCypher::getBitStream(u_int32_t length) { Buffer buf(length); |