Coverage Report

Created: 2025-04-11 06:56

/src/unrar/secpassword.hpp
Line
Count
Source (jump to first uncovered line)
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
    std::vector<wchar> Password = std::vector<wchar>(MAXPASSWORD);
12
    bool PasswordSet;
13
  public:
14
    SecPassword();
15
    ~SecPassword();
16
    void Clean();
17
    void Get(wchar *Psw,size_t MaxSize);
18
    void Get(std::wstring &Psw);
19
    void Set(const wchar *Psw);
20
11.6k
    bool IsSet() {return PasswordSet;}
21
    size_t Length();
22
    bool operator == (SecPassword &psw);
23
};
24
25
26
void cleandata(void *data,size_t size);
27
0
inline void cleandata(std::wstring &s) {cleandata(&s[0],s.size()*sizeof(s[0]));}
28
void SecHideData(void *Data,size_t DataSize,bool Encode,bool CrossProcess);
29
30
#endif