1 // Crypto/MyAes.h 2 3 #ifndef __CRYPTO_MY_AES_H 4 #define __CRYPTO_MY_AES_H 5 6 #include "../../../C/Aes.h" 7 8 #include "../../Common/MyCom.h" 9 10 #include "../ICoder.h" 11 12 namespace NCrypto { 13 14 class CAesCbcCoder: 15 public ICompressFilter, 16 public ICryptoProperties, 17 public ICompressSetCoderProperties, 18 public CMyUnknownImp 19 { 20 AES_CODE_FUNC _codeFunc; 21 unsigned _offset; 22 unsigned _keySize; 23 bool _keyIsSet; 24 bool _encodeMode; 25 UInt32 _aes[AES_NUM_IVMRK_WORDS + 3]; 26 Byte _iv[AES_BLOCK_SIZE]; 27 28 bool SetFunctions(UInt32 algo); 29 30 public: 31 CAesCbcCoder(bool encodeMode, unsigned keySize); 32 33 MY_UNKNOWN_IMP3(ICompressFilter, ICryptoProperties, ICompressSetCoderProperties) 34 35 INTERFACE_ICompressFilter(;) 36 37 STDMETHOD(SetKey)(const Byte *data, UInt32 size); 38 STDMETHOD(SetInitVector)(const Byte *data, UInt32 size); 39 40 STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); 41 }; 42 43 struct CAesCbcEncoder: public CAesCbcCoder 44 { CAesCbcCoderCAesCbcEncoder45 CAesCbcEncoder(unsigned keySize = 0): CAesCbcCoder(true, keySize) {} 46 }; 47 48 struct CAesCbcDecoder: public CAesCbcCoder 49 { CAesCbcCoderCAesCbcDecoder50 CAesCbcDecoder(unsigned keySize = 0): CAesCbcCoder(false, keySize) {} 51 }; 52 53 } 54 55 #endif 56