diff options
author | lloyd <[email protected]> | 2010-09-13 15:21:31 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-13 15:21:31 +0000 |
commit | 4a7e9edcc92b08a285ea24549fd8c813d10b63b9 (patch) | |
tree | 569e357cbc1bd2b195c1b10b281f6c0bbf01fd33 /src/block/blowfish | |
parent | 27d79c87365105d6128afe9eaf8a82383976ed44 (diff) |
First set of changes for avoiding use implicit vector->pointer conversions
Diffstat (limited to 'src/block/blowfish')
-rw-r--r-- | src/block/blowfish/blowfish.cpp | 35 | ||||
-rw-r--r-- | src/block/blowfish/blowfish.h | 3 |
2 files changed, 20 insertions, 18 deletions
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<u32bit>& 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<u32bit>& box, + u32bit& L, u32bit& R) const; static const u32bit P_INIT[18]; static const u32bit S_INIT[1024]; |