"Fossies" - the Fresh Open Source Software Archive

Member "unrar/secpassword.hpp" (4 May 2022, 1066 Bytes) of package /linux/misc/unrarsrc-6.1.7.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. For more information about "secpassword.hpp" see the Fossies "Dox" file reference documentation.

    1 #ifndef _RAR_SECURE_PASSWORD_
    2 #define _RAR_SECURE_PASSWORD_
    3 
    4 // Store a password securely (if data encryption is provided by OS)
    5 // or obfuscated to make search for password in memory dump less trivial.
    6 class SecPassword
    7 {
    8   private:
    9     void Process(const wchar *Src,size_t SrcSize,wchar *Dst,size_t DstSize,bool Encode);
   10 
   11     wchar Password[MAXPASSWORD];
   12 
   13     // It is important to have this 'bool' value, so if our object is cleaned
   14     // with memset as a part of larger structure, it is handled correctly.
   15     bool PasswordSet;
   16   public:
   17     SecPassword();
   18     ~SecPassword();
   19     void Clean();
   20     void Get(wchar *Psw,size_t MaxSize);
   21     void Set(const wchar *Psw);
   22     bool IsSet() {return PasswordSet;}
   23     size_t Length();
   24     bool operator == (SecPassword &psw);
   25 
   26     // Set to true if we need to pass a password to another process.
   27     // We use it when transferring parameters to UAC elevated WinRAR.
   28     bool CrossProcess;
   29 };
   30 
   31 
   32 void cleandata(void *data,size_t size);
   33 void SecHideData(void *Data,size_t DataSize,bool Encode,bool CrossProcess);
   34 
   35 #endif