diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Crypto/Rar20Crypto.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,50 @@
     1.4 +// Crypto/Rar20Crypto.h
     1.5 +
     1.6 +#ifndef __CRYPTO_RAR20_CRYPTO_H
     1.7 +#define __CRYPTO_RAR20_CRYPTO_H
     1.8 +
     1.9 +#include "Common/MyCom.h"
    1.10 +
    1.11 +#include "../ICoder.h"
    1.12 +#include "../IPassword.h"
    1.13 +
    1.14 +namespace NCrypto {
    1.15 +namespace NRar20 {
    1.16 +
    1.17 +class CData
    1.18 +{
    1.19 +  Byte SubstTable[256];
    1.20 +  UInt32 Keys[4];
    1.21 +  
    1.22 +  UInt32 SubstLong(UInt32 t)
    1.23 +  {
    1.24 +    return (UInt32)SubstTable[(int)t & 255] |
    1.25 +           ((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) |
    1.26 +           ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
    1.27 +           ((UInt32)SubstTable[(int)(t >> 24) & 255] << 24);
    1.28 +  }
    1.29 +  void UpdateKeys(const Byte *data);
    1.30 +  void CryptBlock(Byte *buf, bool encrypt);
    1.31 +public:
    1.32 +  void EncryptBlock(Byte *buf) { CryptBlock(buf, true); }
    1.33 +  void DecryptBlock(Byte *buf) { CryptBlock(buf, false); }
    1.34 +  void SetPassword(const Byte *password, UInt32 passwordLen);
    1.35 +};
    1.36 +
    1.37 +class CDecoder:
    1.38 +  public ICompressFilter,
    1.39 +  public ICryptoSetPassword,
    1.40 +  public CMyUnknownImp
    1.41 +{
    1.42 +  CData _cipher;
    1.43 +public:
    1.44 +  MY_UNKNOWN_IMP1(ICryptoSetPassword)
    1.45 +
    1.46 +  STDMETHOD(Init)();
    1.47 +  STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
    1.48 +  STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
    1.49 +};
    1.50 +
    1.51 +}}
    1.52 +
    1.53 +#endif