diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2008-08-13 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:56 +0300 |
commit | 173c07e166fdf6fcd20f18ea73008f1b628945df (patch) | |
tree | 13ebea85cdc4c16ae93714ff0627ee9f91ad7e08 /CPP/7zip/Crypto/Hash | |
parent | 3901bf0ab88106a5b031cba7bc18d60cdebf7eef (diff) |
4.59 beta
Diffstat (limited to 'CPP/7zip/Crypto/Hash')
-rwxr-xr-x | CPP/7zip/Crypto/Hash/HmacSha1.cpp | 10 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp | 4 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h | 4 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/Hash/RandGen.cpp | 4 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/Hash/RandGen.h | 2 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/Hash/Sha1.cpp | 18 | ||||
-rwxr-xr-x | CPP/7zip/Crypto/Hash/Sha1.h | 8 |
7 files changed, 25 insertions, 25 deletions
diff --git a/CPP/7zip/Crypto/Hash/HmacSha1.cpp b/CPP/7zip/Crypto/Hash/HmacSha1.cpp index a5c20a75..a66d6271 100755 --- a/CPP/7zip/Crypto/Hash/HmacSha1.cpp +++ b/CPP/7zip/Crypto/Hash/HmacSha1.cpp @@ -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); diff --git a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp index b11881b7..cbbdec89 100755 --- a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp +++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp @@ -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; diff --git a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h index 00a5e009..68e85ee3 100755 --- a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h +++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h @@ -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); }} diff --git a/CPP/7zip/Crypto/Hash/RandGen.cpp b/CPP/7zip/Crypto/Hash/RandGen.cpp index 9ae36155..a030a0d2 100755 --- a/CPP/7zip/Crypto/Hash/RandGen.cpp +++ b/CPP/7zip/Crypto/Hash/RandGen.cpp @@ -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(); diff --git a/CPP/7zip/Crypto/Hash/RandGen.h b/CPP/7zip/Crypto/Hash/RandGen.h index 3b58a032..3f06b26b 100755 --- a/CPP/7zip/Crypto/Hash/RandGen.h +++ b/CPP/7zip/Crypto/Hash/RandGen.h @@ -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; diff --git a/CPP/7zip/Crypto/Hash/Sha1.cpp b/CPP/7zip/Crypto/Hash/Sha1.cpp index 8d56b3dc..2962c654 100755 --- a/CPP/7zip/Crypto/Hash/Sha1.cpp +++ b/CPP/7zip/Crypto/Hash/Sha1.cpp @@ -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); diff --git a/CPP/7zip/Crypto/Hash/Sha1.h b/CPP/7zip/Crypto/Hash/Sha1.h index ebb11142..8ad8675b 100755 --- a/CPP/7zip/Crypto/Hash/Sha1.h +++ b/CPP/7zip/Crypto/Hash/Sha1.h @@ -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: |