aboutsummaryrefslogtreecommitdiffstats
path: root/src/block/cast
diff options
context:
space:
mode:
Diffstat (limited to 'src/block/cast')
-rw-r--r--src/block/cast/cast128.cpp4
-rw-r--r--src/block/cast/cast128.h4
-rw-r--r--src/block/cast/cast256.cpp9
-rw-r--r--src/block/cast/cast256.h6
4 files changed, 12 insertions, 11 deletions
diff --git a/src/block/cast/cast128.cpp b/src/block/cast/cast128.cpp
index b68b7abd7..48eb910ce 100644
--- a/src/block/cast/cast128.cpp
+++ b/src/block/cast/cast128.cpp
@@ -119,7 +119,7 @@ void CAST_128::decrypt_n(const byte in[], byte out[], u32bit blocks) const
void CAST_128::key_schedule(const byte key[], u32bit length)
{
clear();
- SecureVector<u32bit, 4> X;
+ SecureVector<u32bit> X(4);
for(u32bit j = 0; j != length; ++j)
X[j/4] = (X[j/4] << 8) + key[j];
@@ -145,7 +145,7 @@ void CAST_128::cast_ks(MemoryRegion<u32bit>& K,
const u32bit* X;
};
- SecureVector<u32bit, 4> Z;
+ SecureVector<u32bit> Z(4);
ByteReader x(&X[0]), z(&Z[0]);
Z[0] = X[0] ^ S5[x(13)] ^ S6[x(15)] ^ S7[x(12)] ^ S8[x(14)] ^ S7[x( 8)];
diff --git a/src/block/cast/cast128.h b/src/block/cast/cast128.h
index 425eb46cc..bb8332aca 100644
--- a/src/block/cast/cast128.h
+++ b/src/block/cast/cast128.h
@@ -25,7 +25,7 @@ class BOTAN_DLL CAST_128 : public BlockCipher
std::string name() const { return "CAST-128"; }
BlockCipher* clone() const { return new CAST_128; }
- CAST_128() : BlockCipher(8, 11, 16) {}
+ CAST_128() : BlockCipher(8, 11, 16), MK(16), RK(16) {}
private:
void key_schedule(const byte[], u32bit);
@@ -37,7 +37,7 @@ class BOTAN_DLL CAST_128 : public BlockCipher
static const u32bit S7[256];
static const u32bit S8[256];
- SecureVector<u32bit, 16> MK, RK;
+ SecureVector<u32bit> MK, RK;
};
extern const u32bit CAST_SBOX1[256];
diff --git a/src/block/cast/cast256.cpp b/src/block/cast/cast256.cpp
index 8aaf8009f..551d4e387 100644
--- a/src/block/cast/cast256.cpp
+++ b/src/block/cast/cast256.cpp
@@ -138,12 +138,13 @@ void CAST_256::decrypt_n(const byte in[], byte out[], u32bit blocks) const
*/
void CAST_256::key_schedule(const byte key[], u32bit length)
{
- SecureVector<u32bit, 8> TMP;
+ SecureVector<u32bit> K(8);
for(u32bit j = 0; j != length; ++j)
- TMP[j/4] = (TMP[j/4] << 8) + key[j];
+ K[j/4] = (K[j/4] << 8) + key[j];
+
+ u32bit A = K[0], B = K[1], C = K[2], D = K[3],
+ E = K[4], F = K[5], G = K[6], H = K[7];
- u32bit A = TMP[0], B = TMP[1], C = TMP[2], D = TMP[3],
- E = TMP[4], F = TMP[5], G = TMP[6], H = TMP[7];
for(u32bit j = 0; j != 48; j += 4)
{
round1(G, H, KEY_MASK[4*j+ 0], KEY_ROT[(4*j+ 0) % 32]);
diff --git a/src/block/cast/cast256.h b/src/block/cast/cast256.h
index c9820c1ab..533f57ac1 100644
--- a/src/block/cast/cast256.h
+++ b/src/block/cast/cast256.h
@@ -25,15 +25,15 @@ class BOTAN_DLL CAST_256 : public BlockCipher
std::string name() const { return "CAST-256"; }
BlockCipher* clone() const { return new CAST_256; }
- CAST_256() : BlockCipher(16, 4, 32, 4) {}
+ CAST_256() : BlockCipher(16, 4, 32, 4), MK(48), RK(48) {}
private:
void key_schedule(const byte[], u32bit);
static const u32bit KEY_MASK[192];
static const byte KEY_ROT[32];
- SecureVector<u32bit, 48> MK;
- SecureVector<byte, 48> RK;
+ SecureVector<u32bit> MK;
+ SecureVector<byte> RK;
};
extern const u32bit CAST_SBOX1[256];