Use SecBlock for keys and IVs
parent
320c68ecbf
commit
97a1e8cae2
|
|
@ -193,7 +193,7 @@ void HC128Policy::CipherSetKey(const NameValuePairs ¶ms, const byte *userKey
|
||||||
{
|
{
|
||||||
CRYPTOPP_UNUSED(params);
|
CRYPTOPP_UNUSED(params);
|
||||||
|
|
||||||
GetUserKey(LITTLE_ENDIAN_ORDER, m_key, 4, userKey, keylen);
|
GetUserKey(LITTLE_ENDIAN_ORDER, m_key.begin(), 4, userKey, keylen);
|
||||||
for (unsigned int i = 4; i < 8; i++)
|
for (unsigned int i = 4; i < 8; i++)
|
||||||
m_key[i] = m_key[i - 4];
|
m_key[i] = m_key[i - 4];
|
||||||
}
|
}
|
||||||
|
|
@ -238,7 +238,7 @@ void HC128Policy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, siz
|
||||||
{
|
{
|
||||||
CRYPTOPP_UNUSED(keystreamBuffer);
|
CRYPTOPP_UNUSED(keystreamBuffer);
|
||||||
|
|
||||||
GetUserKey(LITTLE_ENDIAN_ORDER, m_iv, 4, iv, length);
|
GetUserKey(LITTLE_ENDIAN_ORDER, m_iv.begin(), 4, iv, length);
|
||||||
for (unsigned int i = 4; i < 8; i++)
|
for (unsigned int i = 4; i < 8; i++)
|
||||||
m_iv[i] = m_iv[i - 4];
|
m_iv[i] = m_iv[i - 4];
|
||||||
|
|
||||||
|
|
|
||||||
12
hc128.h
12
hc128.h
|
|
@ -41,12 +41,12 @@ protected:
|
||||||
void SetupUpdate();
|
void SetupUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
word32 m_T[1024]; /* P[i] = T[i]; Q[i] = T[1024+i];*/
|
FixedSizeSecBlock<word32, 16> m_X;
|
||||||
word32 m_X[16];
|
FixedSizeSecBlock<word32, 16> m_Y;
|
||||||
word32 m_Y[16];
|
FixedSizeSecBlock<word32, 8> m_key;
|
||||||
word32 m_key[8];
|
FixedSizeSecBlock<word32, 8> m_iv;
|
||||||
word32 m_iv[8];
|
word32 m_T[1024];
|
||||||
word32 m_ctr; /*counter1024 = i mod 1024 at the i-th step */
|
word32 m_ctr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief HC-128 stream cipher
|
/// \brief HC-128 stream cipher
|
||||||
|
|
|
||||||
4
hc256.h
4
hc256.h
|
|
@ -42,10 +42,10 @@ protected:
|
||||||
word32 Generate();
|
word32 Generate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FixedSizeSecBlock<word32, 8> m_key;
|
||||||
|
FixedSizeSecBlock<word32, 8> m_iv;
|
||||||
word32 m_P[1024];
|
word32 m_P[1024];
|
||||||
word32 m_Q[1024];
|
word32 m_Q[1024];
|
||||||
word32 m_key[8];
|
|
||||||
word32 m_iv[8];
|
|
||||||
word32 m_ctr;
|
word32 m_ctr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue