"Fossies" - the Fresh Open Source Software Archive

Member "UXP-2019.06.08/other-licenses/7zstub/src/CPP/7zip/Crypto/MyAes.h" (8 Jun 2019, 1318 Bytes) of package /linux/www/UXP-2019.06.08.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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   virtual ~CAesCbcCoder() {};   // we need virtual destructor for derived classes
   34   
   35   MY_UNKNOWN_IMP3(ICompressFilter, ICryptoProperties, ICompressSetCoderProperties)
   36   
   37   INTERFACE_ICompressFilter(;)
   38   
   39   STDMETHOD(SetKey)(const Byte *data, UInt32 size);
   40   STDMETHOD(SetInitVector)(const Byte *data, UInt32 size);
   41   
   42   STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps);
   43 };
   44 
   45 struct CAesCbcEncoder: public CAesCbcCoder
   46 {
   47   CAesCbcEncoder(unsigned keySize = 0): CAesCbcCoder(true, keySize) {}
   48 };
   49 
   50 struct CAesCbcDecoder: public CAesCbcCoder
   51 {
   52   CAesCbcDecoder(unsigned keySize = 0): CAesCbcCoder(false, keySize) {}
   53 };
   54 
   55 }
   56 
   57 #endif