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/blowfish/blowfish.cpp | 35 ++++++++++++++++++----------------- src/block/blowfish/blowfish.h | 3 ++- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src/block/blowfish') diff --git a/src/block/blowfish/blowfish.cpp b/src/block/blowfish/blowfish.cpp index d0b182a84..6e4ad5b28 100644 --- a/src/block/blowfish/blowfish.cpp +++ b/src/block/blowfish/blowfish.cpp @@ -15,10 +15,10 @@ namespace Botan { */ void Blowfish::encrypt_n(const byte in[], byte out[], u32bit blocks) const { - const u32bit* S1 = S + 0; - const u32bit* S2 = S + 256; - const u32bit* S3 = S + 512; - const u32bit* S4 = S + 768; + const u32bit* S1 = &S[0]; + const u32bit* S2 = &S[256]; + const u32bit* S3 = &S[512]; + const u32bit* S4 = &S[768]; for(u32bit i = 0; i != blocks; ++i) { @@ -50,10 +50,10 @@ void Blowfish::encrypt_n(const byte in[], byte out[], u32bit blocks) const */ void Blowfish::decrypt_n(const byte in[], byte out[], u32bit blocks) const { - const u32bit* S1 = S + 0; - const u32bit* S2 = S + 256; - const u32bit* S3 = S + 512; - const u32bit* S4 = S + 768; + const u32bit* S1 = &S[0]; + const u32bit* S2 = &S[256]; + const u32bit* S3 = &S[512]; + const u32bit* S4 = &S[768]; for(u32bit i = 0; i != blocks; ++i) { @@ -92,22 +92,22 @@ void Blowfish::key_schedule(const byte key[], u32bit length) key[(k+2) % length], key[(k+3) % length]); u32bit L = 0, R = 0; - generate_sbox(P, 18, L, R); - generate_sbox(S, 1024, L, R); + generate_sbox(P, L, R); + generate_sbox(S, L, R); } /* * Generate one of the Sboxes */ -void Blowfish::generate_sbox(u32bit Box[], u32bit size, +void Blowfish::generate_sbox(MemoryRegion& box, u32bit& L, u32bit& R) const { - const u32bit* S1 = S + 0; - const u32bit* S2 = S + 256; - const u32bit* S3 = S + 512; - const u32bit* S4 = S + 768; + const u32bit* S1 = &S[0]; + const u32bit* S2 = &S[256]; + const u32bit* S3 = &S[512]; + const u32bit* S4 = &S[768]; - for(u32bit j = 0; j != size; j += 2) + for(u32bit j = 0; j != box.size(); j += 2) { for(u32bit k = 0; k != 16; k += 2) { @@ -121,7 +121,8 @@ void Blowfish::generate_sbox(u32bit Box[], u32bit size, } u32bit T = R; R = L ^ P[16]; L = T ^ P[17]; - Box[j] = L; Box[j+1] = R; + box[j] = L; + box[j+1] = R; } } diff --git a/src/block/blowfish/blowfish.h b/src/block/blowfish/blowfish.h index a178ec488..88122aed8 100644 --- a/src/block/blowfish/blowfish.h +++ b/src/block/blowfish/blowfish.h @@ -28,7 +28,8 @@ class BOTAN_DLL Blowfish : public BlockCipher Blowfish() : BlockCipher(8, 1, 56) {} private: void key_schedule(const byte[], u32bit); - void generate_sbox(u32bit[], u32bit, u32bit&, u32bit&) const; + void generate_sbox(MemoryRegion& box, + u32bit& L, u32bit& R) const; static const u32bit P_INIT[18]; static const u32bit S_INIT[1024]; -- cgit v1.2.3