xref: /haiku/headers/os/app/KeyStore.h (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _KEY_STORE_H
6 #define _KEY_STORE_H
7 
8 
9 #include <Key.h>
10 
11 
12 class BKeyStore {
13 public:
14 								BKeyStore();
15 	virtual						~BKeyStore();
16 
17 			status_t			GetKey(BKeyType type, const char* identifier,
18 									BKey& key);
19 			status_t			GetKey(BKeyType type, const char* identifier,
20 									const char* secondaryIdentifier, BKey& key);
21 			status_t			GetKey(BKeyType type, const char* identifier,
22 									const char* secondaryIdentifier,
23 									bool secondaryIdentifierOptional,
24 									BKey& key);
25 
26 			status_t			GetKey(const char* keyring,
27 									BKeyType type, const char* identifier,
28 									BKey& key);
29 			status_t			GetKey(const char* keyring,
30 									BKeyType type, const char* identifier,
31 									const char* secondaryIdentifier, BKey& key);
32 			status_t			GetKey(const char* keyring,
33 									BKeyType type, const char* identifier,
34 									const char* secondaryIdentifier,
35 									bool secondaryIdentifierOptional,
36 									BKey& key);
37 
38 			status_t			AddKey(const BKey& key);
39 			status_t			AddKey(const char* keyring, const BKey& key);
40 			status_t			RemoveKey(const BKey& key);
41 			status_t			RemoveKey(const char* keyring, const BKey& key);
42 
43 			status_t			GetNextKey(uint32& cookie, BKey& key);
44 			status_t			GetNextKey(BKeyType type, BKeyPurpose purpose,
45 									uint32& cookie, BKey& key);
46 			status_t			GetNextKey(const char* keyring,
47 									uint32& cookie, BKey& key);
48 			status_t			GetNextKey(const char* keyring,
49 									BKeyType type, BKeyPurpose purpose,
50 									uint32& cookie, BKey& key);
51 
52 			// Keyrings
53 
54 			status_t			AddKeyring(const char* keyring);
55 			status_t			RemoveKeyring(const char* keyring);
56 
57 			status_t			GetNextKeyring(uint32& cookie,
58 									BString& keyring);
59 
60 			status_t			SetUnlockKey(const char* keyring,
61 									const BKey& key);
62 			status_t			RemoveUnlockKey(const char* keyring);
63 
64 			// Master keyring
65 
66 			status_t			SetMasterUnlockKey(const BKey& key);
67 			status_t			RemoveMasterUnlockKey();
68 
69 			status_t			AddKeyringToMaster(const char* keyring);
70 			status_t			RemoveKeyringFromMaster(const char* keyring);
71 
72 			status_t			GetNextMasterKeyring(uint32& cookie,
73 									BString& keyring);
74 
75 			// Locking
76 
77 			bool				IsKeyringUnlocked(const char* keyring);
78 			status_t			LockKeyring(const char* keyring);
79 			status_t			LockMasterKeyring();
80 
81 			// Applications
82 
83 			status_t			GetNextApplication(uint32& cookie,
84 									BString& signature) const;
85 			status_t			GetNextApplication(const char* keyring,
86 									uint32& cookie, BString& signature) const;
87 			status_t			RemoveApplication(const char* signature);
88 			status_t			RemoveApplication(const char* keyring,
89 									const char* signature);
90 
91 			// Service functions
92 
93 			status_t			GeneratePassword(BPasswordKey& password,
94 									size_t length, uint32 flags);
95 			float				PasswordStrength(const char* password);
96 
97 private:
98 			status_t			_SendKeyMessage(BMessage& message,
99 									BMessage* reply) const;
100 };
101 
102 
103 #endif	// _KEY_STORE_H
104