aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/lubyrack/lubyrack.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-09-13 15:21:31 +0000
committerlloyd <[email protected]>2010-09-13 15:21:31 +0000
commit4a7e9edcc92b08a285ea24549fd8c813d10b63b9 (patch)
tree569e357cbc1bd2b195c1b10b281f6c0bbf01fd33 /src/block/lubyrack/lubyrack.cpp
parent27d79c87365105d6128afe9eaf8a82383976ed44 (diff)
First set of changes for avoiding use implicit vector->pointer conversions
Diffstat (limited to 'src/block/lubyrack/lubyrack.cpp')
-rw-r--r--src/block/lubyrack/lubyrack.cpp30
1 files changed, 16 insertions, 14 deletions
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<byte> buffer(len);
+
for(u32bit i = 0; i != blocks; ++i)
{
- const u32bit len = hash->OUTPUT_LENGTH;
-
- SecureVector<byte> 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<byte> buffer(len);
+
for(u32bit i = 0; i != blocks; ++i)
{
- const u32bit len = hash->OUTPUT_LENGTH;
-
- SecureVector<byte> 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;