comparison src/win32/7zip/7z/CPP/7zip/Crypto/Rar20Crypto.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
comparison
equal deleted inserted replaced
0:8ced16adf2e1 1:f9f4f1b99eed
1 // Crypto/Rar20Crypto.h
2
3 #ifndef __CRYPTO_RAR20_CRYPTO_H
4 #define __CRYPTO_RAR20_CRYPTO_H
5
6 #include "Common/MyCom.h"
7
8 #include "../ICoder.h"
9 #include "../IPassword.h"
10
11 namespace NCrypto {
12 namespace NRar20 {
13
14 class CData
15 {
16 Byte SubstTable[256];
17 UInt32 Keys[4];
18
19 UInt32 SubstLong(UInt32 t)
20 {
21 return (UInt32)SubstTable[(int)t & 255] |
22 ((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) |
23 ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
24 ((UInt32)SubstTable[(int)(t >> 24) & 255] << 24);
25 }
26 void UpdateKeys(const Byte *data);
27 void CryptBlock(Byte *buf, bool encrypt);
28 public:
29 void EncryptBlock(Byte *buf) { CryptBlock(buf, true); }
30 void DecryptBlock(Byte *buf) { CryptBlock(buf, false); }
31 void SetPassword(const Byte *password, UInt32 passwordLen);
32 };
33
34 class CDecoder:
35 public ICompressFilter,
36 public ICryptoSetPassword,
37 public CMyUnknownImp
38 {
39 CData _cipher;
40 public:
41 MY_UNKNOWN_IMP1(ICryptoSetPassword)
42
43 STDMETHOD(Init)();
44 STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
45 STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
46 };
47
48 }}
49
50 #endif