xref: /haiku/headers/os/app/KeyStore.h (revision dc1acef865f290e8d565f078fc78be69991b5c10)
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)
19*dc1acef8SMichael Lotz 			status_t			GetKey(BKeyType type, BKeyPurpose purpose,
203b3884d9SMichael Lotz 									const char* identifier, BKey& key);
21*dc1acef8SMichael Lotz 			status_t			GetKey(BKeyType type, BKeyPurpose purpose,
223b3884d9SMichael Lotz 									const char* identifier,
233b3884d9SMichael Lotz 									const char* secondaryIdentifier, BKey& key);
24*dc1acef8SMichael 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 
30*dc1acef8SMichael Lotz 			status_t			GetKey(const char* keyring,
31*dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
323b3884d9SMichael Lotz 									const char* identifier, BKey& key);
33*dc1acef8SMichael Lotz 			status_t			GetKey(const char* keyring,
34*dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
353b3884d9SMichael Lotz 									const char* identifier,
363b3884d9SMichael Lotz 									const char* secondaryIdentifier, BKey& key);
37*dc1acef8SMichael Lotz 			status_t			GetKey(const char* keyring,
38*dc1acef8SMichael 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*dc1acef8SMichael Lotz 			status_t			RegisterKey(const BKey& key);
45*dc1acef8SMichael Lotz 			status_t			RegisterKey(const char* keyring,
463b3884d9SMichael Lotz 									const BKey& key);
47*dc1acef8SMichael Lotz 			status_t			UnregisterKey(const BKey& key);
48*dc1acef8SMichael Lotz 			status_t			UnregisterKey(const char* keyring,
493b3884d9SMichael Lotz 									const BKey& key);
503b3884d9SMichael Lotz 
51*dc1acef8SMichael Lotz 			status_t			GetNextKey(uint32& cookie, BKey& key);
52*dc1acef8SMichael Lotz 			status_t			GetNextKey(BKeyType type, BKeyPurpose purpose,
533b3884d9SMichael Lotz 									uint32& cookie, BKey& key);
54*dc1acef8SMichael Lotz 			status_t			GetNextKey(const char* keyring,
553b3884d9SMichael Lotz 									uint32& cookie, BKey& key);
56*dc1acef8SMichael Lotz 			status_t			GetNextKey(const char* keyring,
57*dc1acef8SMichael Lotz 									BKeyType type, BKeyPurpose purpose,
58*dc1acef8SMichael Lotz 									uint32& cookie, BKey& key);
593b3884d9SMichael Lotz 
603b3884d9SMichael Lotz 			// Keyrings
613b3884d9SMichael Lotz 
623b3884d9SMichael Lotz 			status_t			RegisterKeyring(const char* keyring,
633b3884d9SMichael Lotz 									const BKey& key);
643b3884d9SMichael Lotz 			status_t			UnregisterKeyring(const char* keyring);
653b3884d9SMichael Lotz 
663b3884d9SMichael Lotz 			status_t			GetNextKeyring(uint32& cookie,
673b3884d9SMichael Lotz 									BString& keyring);
683b3884d9SMichael Lotz 
693b3884d9SMichael Lotz 			// Master key
703b3884d9SMichael Lotz 
71*dc1acef8SMichael Lotz 			status_t			SetMasterKey(const BKey& key);
72*dc1acef8SMichael Lotz 			status_t			RemoveMasterKey();
733b3884d9SMichael Lotz 
743b3884d9SMichael Lotz 			status_t			AddKeyringToMaster(const char* keyring);
753b3884d9SMichael Lotz 			status_t			RemoveKeyringFromMaster(const char* keyring);
763b3884d9SMichael Lotz 
773b3884d9SMichael Lotz 			status_t			GetNextMasterKeyring(uint32& cookie,
783b3884d9SMichael Lotz 									BString& keyring);
793b3884d9SMichael Lotz 
803b3884d9SMichael Lotz 			// Access
813b3884d9SMichael Lotz 
823b3884d9SMichael Lotz 			bool				IsKeyringAccessible(const char* keyring);
833b3884d9SMichael Lotz 			status_t			RevokeAccess(const char* keyring);
843b3884d9SMichael Lotz 			status_t			RevokeMasterAccess();
853b3884d9SMichael Lotz 
86*dc1acef8SMichael Lotz 			// Applications
87*dc1acef8SMichael Lotz 
88*dc1acef8SMichael Lotz 			status_t			GetNextApplication(const BKey& key,
89*dc1acef8SMichael Lotz 									uint32& cookie, BString& signature) const;
90*dc1acef8SMichael Lotz 			status_t			RemoveApplication(const BKey& key,
91*dc1acef8SMichael Lotz 									const char* signature);
92*dc1acef8SMichael Lotz 
933b3884d9SMichael Lotz 			// Service functions
943b3884d9SMichael Lotz 
95*dc1acef8SMichael Lotz 			status_t			GeneratePassword(BPasswordKey& password,
96*dc1acef8SMichael Lotz 									size_t length, uint32 flags);
97*dc1acef8SMichael Lotz 			float				PasswordStrength(const char* password);
983b3884d9SMichael Lotz };
993b3884d9SMichael Lotz 
1003b3884d9SMichael Lotz 
1013b3884d9SMichael Lotz #endif	// _KEY_STORE_H
102