xref: /haiku/headers/os/app/KeyStore.h (revision b73982892dde263a77608f219c3e02c48790f0c5)
13b3884d9SMichael Lotz /*
23b3884d9SMichael Lotz  * Copyright 2011, Haiku, Inc.
33b3884d9SMichael Lotz  * Distributed under the terms of the MIT License.
43b3884d9SMichael Lotz  */
53b3884d9SMichael Lotz #ifndef _KEY_STORE_H
63b3884d9SMichael Lotz #define _KEY_STORE_H
73b3884d9SMichael Lotz 
83b3884d9SMichael Lotz 
93b3884d9SMichael Lotz #include <Key.h>
103b3884d9SMichael Lotz 
113b3884d9SMichael Lotz 
123b3884d9SMichael Lotz class BKeyStore {
133b3884d9SMichael Lotz public:
143b3884d9SMichael Lotz 								BKeyStore();
153b3884d9SMichael Lotz 	virtual						~BKeyStore();
163b3884d9SMichael Lotz 
173b3884d9SMichael Lotz // TODO: -> GetNextPassword() - there can always be more than one key
183b3884d9SMichael Lotz // with the same identifier/secondaryIdentifier (ie. different username)
19dc1acef8SMichael Lotz 			status_t			GetKey(BKeyType type, BKeyPurpose purpose,
203b3884d9SMichael Lotz 									const char* identifier, BKey& key);
21dc1acef8SMichael Lotz 			status_t			GetKey(BKeyType type, BKeyPurpose purpose,
223b3884d9SMichael Lotz 									const char* identifier,
233b3884d9SMichael Lotz 									const char* secondaryIdentifier, BKey& key);
24dc1acef8SMichael Lotz 			status_t			GetKey(BKeyType type, BKeyPurpose purpose,
253b3884d9SMichael Lotz 									const char* identifier,
263b3884d9SMichael Lotz 									const char* secondaryIdentifier,
273b3884d9SMichael Lotz 									bool secondaryIdentifierOptional,
283b3884d9SMichael Lotz 									BKey& key);
293b3884d9SMichael Lotz 
30dc1acef8SMichael Lotz 			status_t			GetKey(const char* keyring,
31dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
323b3884d9SMichael Lotz 									const char* identifier, BKey& key);
33dc1acef8SMichael Lotz 			status_t			GetKey(const char* keyring,
34dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
353b3884d9SMichael Lotz 									const char* identifier,
363b3884d9SMichael Lotz 									const char* secondaryIdentifier, BKey& key);
37dc1acef8SMichael Lotz 			status_t			GetKey(const char* keyring,
38dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
393b3884d9SMichael Lotz 									const char* identifier,
403b3884d9SMichael Lotz 									const char* secondaryIdentifier,
413b3884d9SMichael Lotz 									bool secondaryIdentifierOptional,
423b3884d9SMichael Lotz 									BKey& key);
433b3884d9SMichael Lotz 
44*b7398289SMichael Lotz 			status_t			AddKey(const BKey& key);
45*b7398289SMichael Lotz 			status_t			AddKey(const char* keyring, const BKey& key);
46*b7398289SMichael Lotz 			status_t			RemoveKey(const BKey& key);
47*b7398289SMichael Lotz 			status_t			RemoveKey(const char* keyring, const BKey& key);
483b3884d9SMichael Lotz 
49dc1acef8SMichael Lotz 			status_t			GetNextKey(uint32& cookie, BKey& key);
50dc1acef8SMichael Lotz 			status_t			GetNextKey(BKeyType type, BKeyPurpose purpose,
513b3884d9SMichael Lotz 									uint32& cookie, BKey& key);
52dc1acef8SMichael Lotz 			status_t			GetNextKey(const char* keyring,
533b3884d9SMichael Lotz 									uint32& cookie, BKey& key);
54dc1acef8SMichael Lotz 			status_t			GetNextKey(const char* keyring,
55dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
56dc1acef8SMichael Lotz 									uint32& cookie, BKey& key);
573b3884d9SMichael Lotz 
583b3884d9SMichael Lotz 			// Keyrings
593b3884d9SMichael Lotz 
60*b7398289SMichael Lotz 			status_t			AddKeyring(const char* keyring,
613b3884d9SMichael Lotz 									const BKey& key);
62*b7398289SMichael Lotz 			status_t			RemoveKeyring(const char* keyring);
633b3884d9SMichael Lotz 
643b3884d9SMichael Lotz 			status_t			GetNextKeyring(uint32& cookie,
653b3884d9SMichael Lotz 									BString& keyring);
663b3884d9SMichael Lotz 
673b3884d9SMichael Lotz 			// Master key
683b3884d9SMichael Lotz 
69dc1acef8SMichael Lotz 			status_t			SetMasterKey(const BKey& key);
70dc1acef8SMichael Lotz 			status_t			RemoveMasterKey();
713b3884d9SMichael Lotz 
723b3884d9SMichael Lotz 			status_t			AddKeyringToMaster(const char* keyring);
733b3884d9SMichael Lotz 			status_t			RemoveKeyringFromMaster(const char* keyring);
743b3884d9SMichael Lotz 
753b3884d9SMichael Lotz 			status_t			GetNextMasterKeyring(uint32& cookie,
763b3884d9SMichael Lotz 									BString& keyring);
773b3884d9SMichael Lotz 
783b3884d9SMichael Lotz 			// Access
793b3884d9SMichael Lotz 
803b3884d9SMichael Lotz 			bool				IsKeyringAccessible(const char* keyring);
813b3884d9SMichael Lotz 			status_t			RevokeAccess(const char* keyring);
823b3884d9SMichael Lotz 			status_t			RevokeMasterAccess();
833b3884d9SMichael Lotz 
84dc1acef8SMichael Lotz 			// Applications
85dc1acef8SMichael Lotz 
86dc1acef8SMichael Lotz 			status_t			GetNextApplication(const BKey& key,
87dc1acef8SMichael Lotz 									uint32& cookie, BString& signature) const;
88dc1acef8SMichael Lotz 			status_t			RemoveApplication(const BKey& key,
89dc1acef8SMichael Lotz 									const char* signature);
90dc1acef8SMichael Lotz 
913b3884d9SMichael Lotz 			// Service functions
923b3884d9SMichael Lotz 
93dc1acef8SMichael Lotz 			status_t			GeneratePassword(BPasswordKey& password,
94dc1acef8SMichael Lotz 									size_t length, uint32 flags);
95dc1acef8SMichael Lotz 			float				PasswordStrength(const char* password);
963b3884d9SMichael Lotz };
973b3884d9SMichael Lotz 
983b3884d9SMichael Lotz 
993b3884d9SMichael Lotz #endif	// _KEY_STORE_H
100