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