2011-11-16 16:53:36 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2011, Haiku, Inc.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _KEY_STORE_H
|
|
|
|
#define _KEY_STORE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <Key.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BKeyStore {
|
|
|
|
public:
|
|
|
|
BKeyStore();
|
|
|
|
virtual ~BKeyStore();
|
|
|
|
|
2012-01-08 04:43:19 +04:00
|
|
|
status_t GetKey(BKeyType type, const char* identifier,
|
|
|
|
BKey& key);
|
|
|
|
status_t GetKey(BKeyType type, const char* identifier,
|
2011-11-16 16:53:36 +04:00
|
|
|
const char* secondaryIdentifier, BKey& key);
|
2012-01-08 04:43:19 +04:00
|
|
|
status_t GetKey(BKeyType type, const char* identifier,
|
2011-11-16 16:53:36 +04:00
|
|
|
const char* secondaryIdentifier,
|
|
|
|
bool secondaryIdentifierOptional,
|
|
|
|
BKey& key);
|
|
|
|
|
2011-12-22 17:58:19 +04:00
|
|
|
status_t GetKey(const char* keyring,
|
2012-01-08 04:43:19 +04:00
|
|
|
BKeyType type, const char* identifier,
|
|
|
|
BKey& key);
|
2011-12-22 17:58:19 +04:00
|
|
|
status_t GetKey(const char* keyring,
|
2012-01-08 04:43:19 +04:00
|
|
|
BKeyType type, const char* identifier,
|
2011-11-16 16:53:36 +04:00
|
|
|
const char* secondaryIdentifier, BKey& key);
|
2011-12-22 17:58:19 +04:00
|
|
|
status_t GetKey(const char* keyring,
|
2012-01-08 04:43:19 +04:00
|
|
|
BKeyType type, const char* identifier,
|
2011-11-16 16:53:36 +04:00
|
|
|
const char* secondaryIdentifier,
|
|
|
|
bool secondaryIdentifierOptional,
|
|
|
|
BKey& key);
|
|
|
|
|
2012-01-03 20:15:24 +04:00
|
|
|
status_t AddKey(const BKey& key);
|
|
|
|
status_t AddKey(const char* keyring, const BKey& key);
|
|
|
|
status_t RemoveKey(const BKey& key);
|
|
|
|
status_t RemoveKey(const char* keyring, const BKey& key);
|
2011-11-16 16:53:36 +04:00
|
|
|
|
2011-12-22 17:58:19 +04:00
|
|
|
status_t GetNextKey(uint32& cookie, BKey& key);
|
|
|
|
status_t GetNextKey(BKeyType type, BKeyPurpose purpose,
|
2011-11-16 16:53:36 +04:00
|
|
|
uint32& cookie, BKey& key);
|
2011-12-22 17:58:19 +04:00
|
|
|
status_t GetNextKey(const char* keyring,
|
|
|
|
uint32& cookie, BKey& key);
|
|
|
|
status_t GetNextKey(const char* keyring,
|
|
|
|
BKeyType type, BKeyPurpose purpose,
|
2011-11-16 16:53:36 +04:00
|
|
|
uint32& cookie, BKey& key);
|
|
|
|
|
|
|
|
// Keyrings
|
|
|
|
|
2012-06-25 22:12:59 +04:00
|
|
|
status_t AddKeyring(const char* keyring);
|
2012-01-03 20:15:24 +04:00
|
|
|
status_t RemoveKeyring(const char* keyring);
|
2011-11-16 16:53:36 +04:00
|
|
|
|
|
|
|
status_t GetNextKeyring(uint32& cookie,
|
|
|
|
BString& keyring);
|
|
|
|
|
2012-06-25 22:31:27 +04:00
|
|
|
status_t SetUnlockKey(const char* keyring,
|
|
|
|
const BKey& key);
|
|
|
|
status_t RemoveUnlockKey(const char* keyring);
|
2011-11-16 16:53:36 +04:00
|
|
|
|
2012-06-25 22:31:27 +04:00
|
|
|
// Master keyring
|
|
|
|
|
|
|
|
status_t SetMasterUnlockKey(const BKey& key);
|
|
|
|
status_t RemoveMasterUnlockKey();
|
2011-11-16 16:53:36 +04:00
|
|
|
|
|
|
|
status_t AddKeyringToMaster(const char* keyring);
|
|
|
|
status_t RemoveKeyringFromMaster(const char* keyring);
|
|
|
|
|
|
|
|
status_t GetNextMasterKeyring(uint32& cookie,
|
|
|
|
BString& keyring);
|
|
|
|
|
2012-06-24 16:37:27 +04:00
|
|
|
// Locking
|
2011-11-16 16:53:36 +04:00
|
|
|
|
2012-06-24 16:37:27 +04:00
|
|
|
bool IsKeyringUnlocked(const char* keyring);
|
|
|
|
status_t LockKeyring(const char* keyring);
|
|
|
|
status_t LockMasterKeyring();
|
2011-11-16 16:53:36 +04:00
|
|
|
|
2011-12-22 17:58:19 +04:00
|
|
|
// Applications
|
|
|
|
|
2012-06-24 16:53:07 +04:00
|
|
|
status_t GetNextApplication(uint32& cookie,
|
2012-01-08 04:55:14 +04:00
|
|
|
BString& signature) const;
|
2012-06-24 16:53:07 +04:00
|
|
|
status_t GetNextApplication(const char* keyring,
|
|
|
|
uint32& cookie, BString& signature) const;
|
|
|
|
status_t RemoveApplication(const char* signature);
|
2012-01-08 04:55:14 +04:00
|
|
|
status_t RemoveApplication(const char* keyring,
|
2012-06-24 16:53:07 +04:00
|
|
|
const char* signature);
|
2011-12-22 17:58:19 +04:00
|
|
|
|
2011-11-16 16:53:36 +04:00
|
|
|
// Service functions
|
|
|
|
|
2011-12-22 17:58:19 +04:00
|
|
|
status_t GeneratePassword(BPasswordKey& password,
|
|
|
|
size_t length, uint32 flags);
|
|
|
|
float PasswordStrength(const char* password);
|
2012-01-04 04:51:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
status_t _SendKeyMessage(BMessage& message,
|
|
|
|
BMessage* reply) const;
|
2011-11-16 16:53:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _KEY_STORE_H
|