From 4a7e9edcc92b08a285ea24549fd8c813d10b63b9 Mon Sep 17 00:00:00 2001 From: lloyd Date: Mon, 13 Sep 2010 15:21:31 +0000 Subject: First set of changes for avoiding use implicit vector->pointer conversions --- src/block/lubyrack/lubyrack.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'src/block/lubyrack/lubyrack.cpp') diff --git a/src/block/lubyrack/lubyrack.cpp b/src/block/lubyrack/lubyrack.cpp index 4dd0d5c8a..99f8e6da1 100644 --- a/src/block/lubyrack/lubyrack.cpp +++ b/src/block/lubyrack/lubyrack.cpp @@ -15,29 +15,30 @@ namespace Botan { */ void LubyRackoff::encrypt_n(const byte in[], byte out[], u32bit blocks) const { + const u32bit len = hash->OUTPUT_LENGTH; + + SecureVector buffer(len); + for(u32bit i = 0; i != blocks; ++i) { - const u32bit len = hash->OUTPUT_LENGTH; - - SecureVector buffer(len); hash->update(K1); hash->update(in, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out + len, in + len, buffer, len); hash->update(K2); hash->update(out + len, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out, in, buffer, len); hash->update(K1); hash->update(out, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out + len, buffer, len); hash->update(K2); hash->update(out + len, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out, buffer, len); in += BLOCK_SIZE; @@ -50,29 +51,30 @@ void LubyRackoff::encrypt_n(const byte in[], byte out[], u32bit blocks) const */ void LubyRackoff::decrypt_n(const byte in[], byte out[], u32bit blocks) const { + const u32bit len = hash->OUTPUT_LENGTH; + + SecureVector buffer(len); + for(u32bit i = 0; i != blocks; ++i) { - const u32bit len = hash->OUTPUT_LENGTH; - - SecureVector buffer(len); hash->update(K2); hash->update(in + len, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out, in, buffer, len); hash->update(K1); hash->update(out, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out + len, in + len, buffer, len); hash->update(K2); hash->update(out + len, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out, buffer, len); hash->update(K1); hash->update(out, len); - hash->final(buffer); + hash->final(&buffer[0]); xor_buf(out + len, buffer, len); in += BLOCK_SIZE; -- cgit v1.2.3