4.59 beta

This commit is contained in:
Igor Pavlov
2008-08-13 00:00:00 +00:00
committed by Kornel Lesiński
parent 3901bf0ab8
commit 173c07e166
781 changed files with 22124 additions and 13650 deletions

View File

@@ -20,7 +20,7 @@ void CHmac::SetKey(const Byte *key, size_t keySize)
_sha.Final(keyTemp);
keySize = kDigestSize;
}
else
else
for (i = 0; i < keySize; i++)
keyTemp[i] = key[i];
for (i = 0; i < kBlockSize; i++)
@@ -34,7 +34,7 @@ void CHmac::SetKey(const Byte *key, size_t keySize)
}
void CHmac::Final(Byte *mac, size_t macSize)
{
{
Byte digest[kDigestSize];
_sha.Final(digest);
_sha2.Update(digest, kDigestSize);
@@ -59,14 +59,14 @@ void CHmac32::SetKey(const Byte *key, size_t keySize)
sha.Final(digest);
for (int i = 0 ; i < kDigestSizeInWords; i++)
keyTemp[i] =
keyTemp[i] =
((UInt32)(digest[i * 4 + 0]) << 24) |
((UInt32)(digest[i * 4 + 1]) << 16) |
((UInt32)(digest[i * 4 + 2]) << 8) |
((UInt32)(digest[i * 4 + 3]));
keySize = kDigestSizeInWords;
}
else
else
for (size_t i = 0; i < keySize; i++)
keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3)));
for (i = 0; i < kBlockSizeInWords; i++)
@@ -80,7 +80,7 @@ void CHmac32::SetKey(const Byte *key, size_t keySize)
}
void CHmac32::Final(UInt32 *mac, size_t macSize)
{
{
UInt32 digest[kDigestSizeInWords];
_sha.Final(digest);
_sha2.Update(digest, kDigestSizeInWords);

View File

@@ -7,7 +7,7 @@
namespace NCrypto {
namespace NSha1 {
void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
UInt32 numIterations, Byte *key, size_t keySize)
{
CHmac baseCtx;
@@ -39,7 +39,7 @@ void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSi
}
}
void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
UInt32 numIterations, UInt32 *key, size_t keySize)
{
CHmac32 baseCtx;

View File

@@ -10,10 +10,10 @@
namespace NCrypto {
namespace NSha1 {
void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
UInt32 numIterations, Byte *key, size_t keySize);
void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
UInt32 numIterations, UInt32 *key, size_t keySize);
}}

View File

@@ -28,7 +28,7 @@
// Maybe it's possible to restore original timer value from generated value.
void CRandomGenerator::Init()
{
{
NCrypto::NSha1::CContext hash;
hash.Init();
@@ -82,7 +82,7 @@ void CRandomGenerator::Init()
static NWindows::NSynchronization::CCriticalSection g_CriticalSection;
void CRandomGenerator::Generate(Byte *data, unsigned int size)
{
{
g_CriticalSection.Enter();
if (_needInit)
Init();

View File

@@ -13,7 +13,7 @@ class CRandomGenerator
void Init();
public:
CRandomGenerator(): _needInit(true) {};
void Generate(Byte *data, unsigned int size);
void Generate(Byte *data, unsigned size);
};
extern CRandomGenerator g_RandomGenerator;

View File

@@ -1,12 +1,12 @@
// Sha1.cpp
// This file is based on public domain
// This file is based on public domain
// Steve Reid and Wei Dai's code from Crypto++
#include "StdAfx.h"
#include "Sha1.h"
extern "C"
{
extern "C"
{
#include "../../../../C/RotateDefs.h"
}
@@ -16,7 +16,7 @@ namespace NSha1 {
// define it for speed optimization
// #define _SHA1_UNROLL
static const unsigned int kNumW =
static const unsigned int kNumW =
#ifdef _SHA1_UNROLL
16;
#else
@@ -79,9 +79,9 @@ void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnR
#ifdef _SHA1_UNROLL
RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35);
RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55);
RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75);
RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35);
RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55);
RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75);
#else
i = 20;
for (; i < 40; i += 5) { RX_5(R2, i); }
@@ -101,7 +101,7 @@ void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnR
// Wipe variables
// a = b = c = d = e = 0;
}
}
void CContextBase::PrepareBlock(UInt32 *block, unsigned int size) const
{
@@ -165,7 +165,7 @@ void CContext::Final(Byte *digest)
UpdateBlock();
int i;
for (i = 0; i < kDigestSizeInWords; i++)
for (i = 0; i < kDigestSizeInWords; i++)
{
UInt32 state = _state[i] & 0xFFFFFFFF;
*digest++ = (Byte)(state >> 24);

View File

@@ -1,5 +1,5 @@
// Sha1.h
// This file is based on public domain
// This file is based on public domain
// Steve Reid and Wei Dai's code from Crypto++
#ifndef __SHA1_H
@@ -26,9 +26,9 @@ class CContextBase
protected:
UInt32 _state[5];
UInt64 _count;
void UpdateBlock(UInt32 *data, bool returnRes = false)
{
GetBlockDigest(data, _state, returnRes);
void UpdateBlock(UInt32 *data, bool returnRes = false)
{
GetBlockDigest(data, _state, returnRes);
_count++;
}
public: