Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2012-06-16 00:29:14 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2012-06-16 00:29:14 +0400
commita3d79a0b72e55ddb2d252b9e321dcf8451fdc25e (patch)
tree68f98e7fc27fb96ccaab7ea3bf58d4fdee34e091 /src/thirdparty/unrar/crypt.hpp
parent9a444c24cfea2d07fec73dd84377c36588456902 (diff)
add unrar and use it as a static lib
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@5142 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/thirdparty/unrar/crypt.hpp')
-rw-r--r--src/thirdparty/unrar/crypt.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/thirdparty/unrar/crypt.hpp b/src/thirdparty/unrar/crypt.hpp
new file mode 100644
index 000000000..96b8a27f1
--- /dev/null
+++ b/src/thirdparty/unrar/crypt.hpp
@@ -0,0 +1,62 @@
+#ifndef _RAR_CRYPT_
+#define _RAR_CRYPT_
+
+enum { OLD_DECODE=0,OLD_ENCODE=1,NEW_CRYPT=2 };
+
+
+struct CryptKeyCacheItem
+{
+#ifndef _SFX_RTL_
+ CryptKeyCacheItem()
+ {
+ Password.Set(L"");
+ }
+
+ ~CryptKeyCacheItem()
+ {
+ memset(AESKey,0,sizeof(AESKey));
+ memset(AESInit,0,sizeof(AESInit));
+ memset(&Password,0,sizeof(Password));
+ }
+#endif
+ byte AESKey[16],AESInit[16];
+ SecPassword Password;
+ bool SaltPresent;
+ byte Salt[SALT_SIZE];
+ bool HandsOffHash;
+};
+
+class CryptData
+{
+ private:
+ void Encode13(byte *Data,uint Count);
+ void Decode13(byte *Data,uint Count);
+ void Crypt15(byte *Data,uint Count);
+ void UpdKeys(byte *Buf);
+ void Swap(byte *Ch1,byte *Ch2);
+ void SetOldKeys(const char *Password);
+
+ Rijndael rin;
+
+ byte SubstTable[256];
+ uint Key[4];
+ ushort OldKey[4];
+ byte PN1,PN2,PN3;
+
+ byte AESKey[16],AESInit[16];
+
+ static CryptKeyCacheItem Cache[4];
+ static int CachePos;
+ public:
+ void SetCryptKeys(SecPassword *Password,const byte *Salt,bool Encrypt,bool OldOnly,bool HandsOffHash);
+ void SetAV15Encryption();
+ void SetCmt13Encryption();
+ void EncryptBlock20(byte *Buf);
+ void DecryptBlock20(byte *Buf);
+ void EncryptBlock(byte *Buf,size_t Size);
+ void DecryptBlock(byte *Buf,size_t Size);
+ void Crypt(byte *Data,uint Count,int Method);
+ static void SetSalt(byte *Salt,int SaltSize);
+};
+
+#endif