Make CAST temporaries class members
parent
11e076003a
commit
71e9fece87
12
cast.cpp
12
cast.cpp
|
|
@ -35,8 +35,7 @@ typedef BlockGetAndPut<word32, BigEndian> Block;
|
||||||
|
|
||||||
void CAST128::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
void CAST128::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||||
{
|
{
|
||||||
// TODO: add a SecBlock workspace to the class when the ABI can change
|
word32 &t=m_t[0], &l=m_t[1], &r=m_t[2];
|
||||||
word32 t,l,r;
|
|
||||||
|
|
||||||
/* Get inblock into l,r */
|
/* Get inblock into l,r */
|
||||||
Block::Get(inBlock)(l)(r);
|
Block::Get(inBlock)(l)(r);
|
||||||
|
|
@ -66,8 +65,7 @@ void CAST128::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock,
|
||||||
|
|
||||||
void CAST128::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
void CAST128::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
|
||||||
{
|
{
|
||||||
// TODO: add a SecBlock workspace to the class when the ABI can change
|
word32 &t=m_t[0], &l=m_t[1], &r=m_t[2];
|
||||||
word32 t,l,r;
|
|
||||||
|
|
||||||
/* Get inblock into l,r */
|
/* Get inblock into l,r */
|
||||||
Block::Get(inBlock)(r)(l);
|
Block::Get(inBlock)(r)(l);
|
||||||
|
|
@ -256,9 +254,7 @@ void CAST256::Base::UncheckedSetKey(const byte *userKey, unsigned int keylength,
|
||||||
{
|
{
|
||||||
AssertValidKeyLength(keylength);
|
AssertValidKeyLength(keylength);
|
||||||
|
|
||||||
// TODO: add a SecBlock workspace to the class when the ABI can change
|
GetUserKey(BIG_ENDIAN_ORDER, kappa.begin(), 8, userKey, keylength);
|
||||||
word32 kappa[8];
|
|
||||||
GetUserKey(BIG_ENDIAN_ORDER, kappa, 8, userKey, keylength);
|
|
||||||
|
|
||||||
for(int i=0; i<12; ++i)
|
for(int i=0; i<12; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -291,8 +287,6 @@ void CAST256::Base::UncheckedSetKey(const byte *userKey, unsigned int keylength,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureWipeBuffer(kappa, 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NAMESPACE_END
|
NAMESPACE_END
|
||||||
|
|
|
||||||
3
cast.h
3
cast.h
|
|
@ -41,6 +41,7 @@ class CAST128 : public CAST128_Info, public BlockCipherDocumentation
|
||||||
protected:
|
protected:
|
||||||
bool reduced;
|
bool reduced;
|
||||||
FixedSizeSecBlock<word32, 32> K;
|
FixedSizeSecBlock<word32, 32> K;
|
||||||
|
mutable FixedSizeSecBlock<word32, 3> m_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief CAST128 block cipher encryption operation
|
/// \brief CAST128 block cipher encryption operation
|
||||||
|
|
@ -88,6 +89,8 @@ class CAST256 : public CAST256_Info, public BlockCipherDocumentation
|
||||||
static void Omega(int i, word32 kappa[8]);
|
static void Omega(int i, word32 kappa[8]);
|
||||||
|
|
||||||
FixedSizeSecBlock<word32, 8*12> K;
|
FixedSizeSecBlock<word32, 8*12> K;
|
||||||
|
mutable FixedSizeSecBlock<word32, 8> kappa;
|
||||||
|
mutable FixedSizeSecBlock<word32, 3> m_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue