Mercurial > vba-linux
view src/win32/7zip/7z/CPP/7zip/Crypto/7zAes.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 source
1 // 7zAes.h3 #ifndef __CRYPTO_7Z_AES_H4 #define __CRYPTO_7Z_AES_H6 #include "Common/Buffer.h"7 #include "Common/MyCom.h"8 #include "Common/MyVector.h"10 #include "../ICoder.h"11 #include "../IPassword.h"13 namespace NCrypto {14 namespace NSevenZ {16 const int kKeySize = 32;18 class CKeyInfo19 {20 public:21 int NumCyclesPower;22 UInt32 SaltSize;23 Byte Salt[16];24 CByteBuffer Password;25 Byte Key[kKeySize];27 bool IsEqualTo(const CKeyInfo &a) const;28 void CalculateDigest();30 CKeyInfo() { Init(); }31 void Init()32 {33 NumCyclesPower = 0;34 SaltSize = 0;35 for (int i = 0; i < sizeof(Salt); i++)36 Salt[i] = 0;37 }38 };40 class CKeyInfoCache41 {42 int Size;43 CObjectVector<CKeyInfo> Keys;44 public:45 CKeyInfoCache(int size): Size(size) {}46 bool Find(CKeyInfo &key);47 // HRESULT Calculate(CKeyInfo &key);48 void Add(CKeyInfo &key);49 };51 class CBase52 {53 CKeyInfoCache _cachedKeys;54 protected:55 CKeyInfo _key;56 Byte _iv[16];57 UInt32 _ivSize;58 void CalculateDigest();59 CBase();60 };62 class CBaseCoder:63 public ICompressFilter,64 public ICryptoSetPassword,65 public CMyUnknownImp,66 public CBase67 {68 protected:69 CMyComPtr<ICompressFilter> _aesFilter;71 virtual HRESULT CreateFilter() = 0;72 #ifndef CRYPTO_AES73 HRESULT CreateFilterFromDLL(REFCLSID clsID);74 #endif75 public:76 STDMETHOD(Init)();77 STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);79 STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);80 };82 #ifndef EXTRACT_ONLY84 class CEncoder:85 public CBaseCoder,86 public ICompressWriteCoderProperties,87 // public ICryptoResetSalt,88 public ICryptoResetInitVector89 {90 virtual HRESULT CreateFilter();91 public:92 MY_UNKNOWN_IMP3(93 ICryptoSetPassword,94 ICompressWriteCoderProperties,95 // ICryptoResetSalt,96 ICryptoResetInitVector)97 STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);98 // STDMETHOD(ResetSalt)();99 STDMETHOD(ResetInitVector)();100 };101 #endif103 class CDecoder:104 public CBaseCoder,105 public ICompressSetDecoderProperties2106 {107 virtual HRESULT CreateFilter();108 public:109 MY_UNKNOWN_IMP2(110 ICryptoSetPassword,111 ICompressSetDecoderProperties2)112 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);113 };115 }}117 #endif