Коммит aac5aea5 создал по автору Моисеенко Андрей Алексеевич's avatar Моисеенко Андрей Алексеевич
Просмотр файлов

~

владелец 71185bac
......@@ -501,7 +501,7 @@ void gost_ctx::Decrypt(const _dword* Key, const _dword* pIn, size_t Size, const
}
// high level Imito function
void gost_ctx::Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword* ImitoValue, const _dword* Salt, const void* End) const noexcept
void gost_ctx::Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword* ImitoValue, const _dword* Salt, const _dword* End) const noexcept
{
Key = Key ? Key : (const _dword*)StaticKey;
#ifdef CROSS_COMPATIBLE_ALGO
......@@ -515,7 +515,9 @@ void gost_ctx::Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword*
_dword n12[2], t[2];
if (Salt)
{
memcpy(n12, Salt, sizeof(n12));
//memcpy(n12, Salt, sizeof(n12));
n12[0] = Salt[0];
n12[1] = Salt[1];
}
else
{
......@@ -532,7 +534,9 @@ void gost_ctx::Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword*
{
if (End)
{
memcpy(t, End, sizeof(t));
//memcpy(t, End, sizeof(t));
t[0] = End[0];
t[1] = End[1];
}
else
{
......@@ -556,7 +560,7 @@ void gost_ctx::Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword*
// high level Encrypt function // gamma with feedack
// Key - 32 bytes, Salt - 8 bytes, OutSalt - 8 bytes, Size in bytes
void gost_ctx::EncryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const void* End) const noexcept
void gost_ctx::EncryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const _dword* End) const noexcept
{
Key = Key ? Key : (const _dword*)StaticKey;
#ifdef CROSS_COMPATIBLE_ALGO
......@@ -587,17 +591,19 @@ void gost_ctx::EncryptImito(const _dword* Key, const _dword* pIn, size_t Size, c
_dword t[2];
if (End)
{
memcpy(t, End, sizeof(t));
//memcpy(t, End, sizeof(t));
t[0] = End[0];
t[1] = End[1];
}
else
{
t[0] = t[1] = 0;
t[1] = t[0] = 0;
}
memcpy(t, pIn, Size & 7);
i12[0] ^= t[0];
i12[1] ^= t[1];
gostcrypt16(Key, i12);
t[0] = t[1] = 0;
t[1] = t[0] = 0;
//-----------------------
memcpy(t, pIn, Size & 7);
gostcrypt(Key, n12);
......@@ -620,7 +626,7 @@ void gost_ctx::EncryptImito(const _dword* Key, const _dword* pIn, size_t Size, c
#endif
}
void gost_ctx::DecryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const void* End) const noexcept
void gost_ctx::DecryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const _dword* End) const noexcept
{
Key = Key ? Key : (const _dword*)StaticKey;
#ifdef CROSS_COMPATIBLE_ALGO
......@@ -663,17 +669,19 @@ void gost_ctx::DecryptImito(const _dword* Key, const _dword* pIn, size_t Size, c
//-----------------------
if (End)
{
memcpy(t, End, sizeof(t));
//memcpy(t, End, sizeof(t));
t[0] = End[0];
t[1] = End[1];
}
else
{
t[0] = t[1] = 0;
t[1] = t[0] = 0;
}
memcpy(t, pOut, Size & 7);
i12[0] ^= t[0];
i12[1] ^= t[1];
gostcrypt16(Key, i12);
t[0] = t[1] = 0;
t[1] = t[0] = 0;
}
ImitoValue[0] = i12[0];
ImitoValue[1] = i12[1];
......@@ -984,7 +992,7 @@ void CGostBsMaa::Decrypt(const void * Key, const void * InData, size_t Size, con
void CGostBsMaa::Imito(const void * Key, const void * InData, size_t Size, void * ImitoValue, const void * Salt, const void * End) const noexcept
{
m_gc.Imito((const _dword*)Key, (const _dword*)InData, Size, (_dword*)ImitoValue, (const _dword*)Salt, End);
m_gc.Imito((const _dword*)Key, (const _dword*)InData, Size, (_dword*)ImitoValue, (const _dword*)Salt, (const _dword*)End);
#if 0
Key = Key ? Key : m_gc->StaticKey;
_dword n12[2], t[2];
......@@ -1027,12 +1035,12 @@ void CGostBsMaa::Imito(const void * Key, const void * InData, size_t Size, void
void CGostBsMaa::EncryptImito(const void* Key, const void* InData, size_t Size, void* ImitoValue, const void* Salt, void* OutData, void* OutSalt, const void* End) const noexcept
{
m_gc.EncryptImito((const _dword*)Key, (const _dword*)InData, Size, (const _dword*)Salt, (_dword*)OutData, (_dword*)OutSalt, (_dword*)ImitoValue, End);
m_gc.EncryptImito((const _dword*)Key, (const _dword*)InData, Size, (const _dword*)Salt, (_dword*)OutData, (_dword*)OutSalt, (_dword*)ImitoValue, (const _dword*)End);
}
void CGostBsMaa::DecryptImito(const void* Key, const void* InData, size_t Size, void* ImitoValue, const void* Salt, void* OutData, void* OutSalt, const void* End) const noexcept
{
m_gc.DecryptImito((const _dword*)Key, (const _dword*)InData, Size, (const _dword*)Salt, (_dword*)OutData, (_dword*)OutSalt, (_dword*)ImitoValue, End);
m_gc.DecryptImito((const _dword*)Key, (const _dword*)InData, Size, (const _dword*)Salt, (_dword*)OutData, (_dword*)OutSalt, (_dword*)ImitoValue, (const _dword*)End);
}
void CGostBsMaa::Hash(const void * Key, const void * InData, size_t Size, const void * Salt, void * Hash, int HashSize /* = 32*/) const noexcept
......
......@@ -97,10 +97,10 @@ struct gost_ctx
// High level functions
void Encrypt(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt) const noexcept;
void Decrypt(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt) const noexcept;
void Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword* ImitoValue, const _dword* Salt, const void* End) const noexcept;
void Imito(const _dword* Key, const _dword* pIn, size_t Size, _dword* ImitoValue, const _dword* Salt, const _dword* End) const noexcept;
// 1.12x faster
void EncryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const void* End) const noexcept;
void DecryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const void* End) const noexcept;
void EncryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const _dword* End) const noexcept;
void DecryptImito(const _dword* Key, const _dword* pIn, size_t Size, const _dword* Salt, _dword* pOut, _dword* OutSalt, _dword* ImitoValue, const _dword* End) const noexcept;
};
class CGostBsMaa
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать