File: secpassword.hpp

package info (click to toggle)
unrar-nonfree 1%3A5.2.7-0.1%2Bdeb8u1
  • links: PTS
  • area: non-free
  • in suites: jessie
  • size: 1,344 kB
  • ctags: 3,512
  • sloc: cpp: 24,411; makefile: 124; sh: 10
file content (35 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _RAR_SECURE_PASSWORD_
#define _RAR_SECURE_PASSWORD_

// Store a password securely (if data encryption is provided by OS)
// or obfuscated to make search for password in memory dump less trivial.
class SecPassword
{
  private:
    void Process(const wchar *Src,size_t SrcSize,wchar *Dst,size_t DstSize,bool Encode);

    wchar Password[MAXPASSWORD];

    // It is important to have this 'bool' value, so if our object is cleaned
    // with memset as a part of larger structure, it is handled correctly.
    bool PasswordSet;
  public:
    SecPassword();
    ~SecPassword();
    void Clean();
    void Get(wchar *Psw,size_t MaxSize);
    void Set(const wchar *Psw);
    bool IsSet() {return PasswordSet;}
    size_t Length();
    bool operator == (SecPassword &psw);

    // Set to true if we need to pass a password to another process.
    // We use it when transferring parameters to UAC elevated WinRAR.
    bool CrossProcess;
};


void cleandata(void *data,size_t size);
void SecHideData(void *Data,size_t DataSize,bool Encode,bool CrossProcess);

#endif