Fix Serpent VariableKeyLength information (Issue 252)

pull/131/merge
Jeffrey Walton 2016-09-05 09:50:26 -04:00
parent 88bc98fa25
commit ea02dc0b94
2 changed files with 12 additions and 12 deletions

View File

@ -52,7 +52,7 @@ typedef BlockGetAndPut<word32, LittleEndian> Block;
void Serpent::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const void Serpent::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{ {
word32 a, b, c, d, e; word32 a, b, c, d, e;
Block::Get(inBlock)(a)(b)(c)(d); Block::Get(inBlock)(a)(b)(c)(d);
const word32 *k = m_key; const word32 *k = m_key;
@ -84,14 +84,14 @@ void Serpent::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock,
while (true); while (true);
afterS7(KX); afterS7(KX);
Block::Put(xorBlock, outBlock)(d)(e)(b)(a); Block::Put(xorBlock, outBlock)(d)(e)(b)(a);
} }
void Serpent::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const void Serpent::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{ {
word32 a, b, c, d, e; word32 a, b, c, d, e;
Block::Get(inBlock)(a)(b)(c)(d); Block::Get(inBlock)(a)(b)(c)(d);
const word32 *k = m_key + 96; const word32 *k = m_key + 96;
@ -108,17 +108,17 @@ void Serpent::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock,
k -= 32; k -= 32;
beforeI7(ILT); beforeI7(ILT);
start: start:
beforeI7(I7); afterI7(KX); beforeI7(I7); afterI7(KX);
afterI7(ILT); afterI7(I6); afterI6(KX); afterI7(ILT); afterI7(I6); afterI6(KX);
afterI6(ILT); afterI6(I5); afterI5(KX); afterI6(ILT); afterI6(I5); afterI5(KX);
afterI5(ILT); afterI5(I4); afterI4(KX); afterI5(ILT); afterI5(I4); afterI4(KX);
afterI4(ILT); afterI4(I3); afterI3(KX); afterI4(ILT); afterI4(I3); afterI3(KX);
afterI3(ILT); afterI3(I2); afterI2(KX); afterI3(ILT); afterI3(I2); afterI2(KX);
afterI2(ILT); afterI2(I1); afterI1(KX); afterI2(ILT); afterI2(I1); afterI1(KX);
afterI1(ILT); afterI1(I0); afterI0(KX); afterI1(ILT); afterI1(I0); afterI0(KX);
} }
while (--i != 0); while (--i != 0);
Block::Put(xorBlock, outBlock)(a)(d)(b)(e); Block::Put(xorBlock, outBlock)(a)(d)(b)(e);
} }

View File

@ -13,7 +13,7 @@ NAMESPACE_BEGIN(CryptoPP)
//! \class Serpent_Info //! \class Serpent_Info
//! \brief Serpent block cipher information //! \brief Serpent block cipher information
struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, public FixedRounds<32> struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, public FixedRounds<32>
{ {
static const char *StaticAlgorithmName() {return "Serpent";} static const char *StaticAlgorithmName() {return "Serpent";}
}; };