VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Token.h
blob: 959c7e2431bd8e0c3942589ff966f8ae7c8eabeb (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef TC_HEADER_Common_Token
#define TC_HEADER_Common_Token

#include "Platform/PlatformBase.h"

#if defined (TC_WINDOWS) && !defined (TC_PROTOTYPE)
#	include "Exception.h"
#else

#	include "Platform/Exception.h"

#endif

#include <string>

#define UNAVAILABLE_SLOT ~0UL

namespace VeraCrypt
{
	struct TokenKeyfilePath
	{
		virtual ~TokenKeyfilePath() {};
		TokenKeyfilePath(const wstring& path): Path(path) { }
		operator wstring () const { return Path; }

		wstring Path;	// Complete path
	};

	struct TokenInfo
	{
		TokenInfo(): SlotId(0), Label(L"") {}
		virtual ~TokenInfo() {}

		virtual BOOL isEditable() const = 0;

		unsigned long int SlotId;
		wstring Label;	// Card name
	};

	struct TokenKeyfile
	{
		virtual ~TokenKeyfile() {}
		virtual operator TokenKeyfilePath () const = 0;
		virtual void GetKeyfileData(vector <uint8>& keyfileData) const = 0;

		shared_ptr<TokenInfo> Token;
		wstring Id;
	};

	class Token
	{
	public:
		static vector< shared_ptr<TokenKeyfile> > GetAvailableKeyfiles(bool isEMVSupportEnabled);
		static bool IsKeyfilePathValid(const wstring& tokenKeyfilePath, bool isEMVSupportEnabled);
		static list < shared_ptr<TokenInfo> > GetAvailableTokens();
		static shared_ptr<TokenKeyfile> getTokenKeyfile(const TokenKeyfilePath& path);
	};
};


#endif //TC_HEADER_Common_Token