xref: /haiku/headers/os/app/KeyStore.h (revision 3b3884d9eec9b931efab12d5b2b47d7e33827a65)
1*3b3884d9SMichael Lotz /*
2*3b3884d9SMichael Lotz  * Copyright 2011, Haiku, Inc.
3*3b3884d9SMichael Lotz  * Distributed under the terms of the MIT License.
4*3b3884d9SMichael Lotz  */
5*3b3884d9SMichael Lotz #ifndef _KEY_STORE_H
6*3b3884d9SMichael Lotz #define _KEY_STORE_H
7*3b3884d9SMichael Lotz 
8*3b3884d9SMichael Lotz 
9*3b3884d9SMichael Lotz #include <Key.h>
10*3b3884d9SMichael Lotz 
11*3b3884d9SMichael Lotz 
12*3b3884d9SMichael Lotz class BKeyStore {
13*3b3884d9SMichael Lotz public:
14*3b3884d9SMichael Lotz 								BKeyStore();
15*3b3884d9SMichael Lotz 	virtual						~BKeyStore();
16*3b3884d9SMichael Lotz 
17*3b3884d9SMichael Lotz // TODO: -> GetNextPassword() - there can always be more than one key
18*3b3884d9SMichael Lotz // with the same identifier/secondaryIdentifier (ie. different username)
19*3b3884d9SMichael Lotz 			status_t			GetPassword(BPasswordType type,
20*3b3884d9SMichael Lotz 									const char* identifier, BKey& key);
21*3b3884d9SMichael Lotz 			status_t			GetPassword(BPasswordType type,
22*3b3884d9SMichael Lotz 									const char* identifier,
23*3b3884d9SMichael Lotz 									const char* secondaryIdentifier, BKey& key);
24*3b3884d9SMichael Lotz 			status_t			GetPassword(BPasswordType type,
25*3b3884d9SMichael Lotz 									const char* identifier,
26*3b3884d9SMichael Lotz 									const char* secondaryIdentifier,
27*3b3884d9SMichael Lotz 									bool secondaryIdentifierOptional,
28*3b3884d9SMichael Lotz 									BKey& key);
29*3b3884d9SMichael Lotz 
30*3b3884d9SMichael Lotz 			status_t			GetPassword(const char* keyring,
31*3b3884d9SMichael Lotz 									BPasswordType type,
32*3b3884d9SMichael Lotz 									const char* identifier, BKey& key);
33*3b3884d9SMichael Lotz 			status_t			GetPassword(const char* keyring,
34*3b3884d9SMichael Lotz 									BPasswordType type,
35*3b3884d9SMichael Lotz 									const char* identifier,
36*3b3884d9SMichael Lotz 									const char* secondaryIdentifier, BKey& key);
37*3b3884d9SMichael Lotz 			status_t			GetPassword(const char* keyring,
38*3b3884d9SMichael Lotz 									BPasswordType type,
39*3b3884d9SMichael Lotz 									const char* identifier,
40*3b3884d9SMichael Lotz 									const char* secondaryIdentifier,
41*3b3884d9SMichael Lotz 									bool secondaryIdentifierOptional,
42*3b3884d9SMichael Lotz 									BKey& key);
43*3b3884d9SMichael Lotz 
44*3b3884d9SMichael Lotz 			status_t			RegisterPassword(const BKey& key);
45*3b3884d9SMichael Lotz 			status_t			RegisterPassword(const char* keyring,
46*3b3884d9SMichael Lotz 									const BKey& key);
47*3b3884d9SMichael Lotz 			status_t			UnregisterPassword(const BKey& key);
48*3b3884d9SMichael Lotz 			status_t			UnregisterPassword(const char* keyring,
49*3b3884d9SMichael Lotz 									const BKey& key);
50*3b3884d9SMichael Lotz 
51*3b3884d9SMichael Lotz 			status_t			GetNextPassword(uint32& cookie, BKey& key);
52*3b3884d9SMichael Lotz 			status_t			GetNextPassword(BPasswordType type,
53*3b3884d9SMichael Lotz 									uint32& cookie, BKey& key);
54*3b3884d9SMichael Lotz 			status_t			GetNextPassword(const char* keyring,
55*3b3884d9SMichael Lotz 									uint32& cookie, BKey& key);
56*3b3884d9SMichael Lotz 			status_t			GetNextPassword(const char* keyring,
57*3b3884d9SMichael Lotz 									BPasswordType type, uint32& cookie,
58*3b3884d9SMichael Lotz 									BKey& key);
59*3b3884d9SMichael Lotz 
60*3b3884d9SMichael Lotz 			// Keyrings
61*3b3884d9SMichael Lotz 
62*3b3884d9SMichael Lotz 			status_t			RegisterKeyring(const char* keyring,
63*3b3884d9SMichael Lotz 									const BKey& key);
64*3b3884d9SMichael Lotz 			status_t			UnregisterKeyring(const char* keyring);
65*3b3884d9SMichael Lotz 
66*3b3884d9SMichael Lotz 			status_t			GetNextKeyring(uint32& cookie,
67*3b3884d9SMichael Lotz 									BString& keyring);
68*3b3884d9SMichael Lotz 
69*3b3884d9SMichael Lotz 			// Master key
70*3b3884d9SMichael Lotz 
71*3b3884d9SMichael Lotz 			status_t			SetMasterPassword(const BKey& key);
72*3b3884d9SMichael Lotz 			status_t			RemoveMasterPassword();
73*3b3884d9SMichael Lotz 
74*3b3884d9SMichael Lotz 			status_t			AddKeyringToMaster(const char* keyring);
75*3b3884d9SMichael Lotz 			status_t			RemoveKeyringFromMaster(const char* keyring);
76*3b3884d9SMichael Lotz 
77*3b3884d9SMichael Lotz 			status_t			GetNextMasterKeyring(uint32& cookie,
78*3b3884d9SMichael Lotz 									BString& keyring);
79*3b3884d9SMichael Lotz 
80*3b3884d9SMichael Lotz 			// Access
81*3b3884d9SMichael Lotz 
82*3b3884d9SMichael Lotz 			bool				IsKeyringAccessible(const char* keyring);
83*3b3884d9SMichael Lotz 			status_t			RevokeAccess(const char* keyring);
84*3b3884d9SMichael Lotz 			status_t			RevokeMasterAccess();
85*3b3884d9SMichael Lotz 
86*3b3884d9SMichael Lotz 			// Service functions
87*3b3884d9SMichael Lotz 
88*3b3884d9SMichael Lotz 			status_t			GeneratePassword(BKey& key, size_t length,
89*3b3884d9SMichael Lotz 									uint32 flags);
90*3b3884d9SMichael Lotz 			float				PasswordStrength(const char* key);
91*3b3884d9SMichael Lotz };
92*3b3884d9SMichael Lotz 
93*3b3884d9SMichael Lotz 
94*3b3884d9SMichael Lotz #endif	// _KEY_STORE_H
95