2011-11-16 13:53:36 +01: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 01:43:19 +01:00
|
|
|
status_t GetKey(BKeyType type, const char* identifier,
|
|
|
|
BKey& key);
|
|
|
|
status_t GetKey(BKeyType type, const char* identifier,
|
2011-11-16 13:53:36 +01:00
|
|
|
const char* secondaryIdentifier, BKey& key);
|
2012-01-08 01:43:19 +01:00
|
|
|
status_t GetKey(BKeyType type, const char* identifier,
|
2011-11-16 13:53:36 +01:00
|
|
|
const char* secondaryIdentifier,
|
|
|
|
bool secondaryIdentifierOptional,
|
|
|
|
BKey& key);
|
|
|
|
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t GetKey(const char* keyring,
|
2012-01-08 01:43:19 +01:00
|
|
|
BKeyType type, const char* identifier,
|
|
|
|
BKey& key);
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t GetKey(const char* keyring,
|
2012-01-08 01:43:19 +01:00
|
|
|
BKeyType type, const char* identifier,
|
2011-11-16 13:53:36 +01:00
|
|
|
const char* secondaryIdentifier, BKey& key);
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t GetKey(const char* keyring,
|
2012-01-08 01:43:19 +01:00
|
|
|
BKeyType type, const char* identifier,
|
2011-11-16 13:53:36 +01:00
|
|
|
const char* secondaryIdentifier,
|
|
|
|
bool secondaryIdentifierOptional,
|
|
|
|
BKey& key);
|
|
|
|
|
2012-01-03 17:15:24 +01: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 13:53:36 +01:00
|
|
|
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t GetNextKey(uint32& cookie, BKey& key);
|
|
|
|
status_t GetNextKey(BKeyType type, BKeyPurpose purpose,
|
2011-11-16 13:53:36 +01:00
|
|
|
uint32& cookie, BKey& key);
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t GetNextKey(const char* keyring,
|
|
|
|
uint32& cookie, BKey& key);
|
|
|
|
status_t GetNextKey(const char* keyring,
|
|
|
|
BKeyType type, BKeyPurpose purpose,
|
2011-11-16 13:53:36 +01:00
|
|
|
uint32& cookie, BKey& key);
|
|
|
|
|
|
|
|
// Keyrings
|
|
|
|
|
2012-06-25 20:12:59 +02:00
|
|
|
status_t AddKeyring(const char* keyring);
|
2012-01-03 17:15:24 +01:00
|
|
|
status_t RemoveKeyring(const char* keyring);
|
2011-11-16 13:53:36 +01:00
|
|
|
|
|
|
|
status_t GetNextKeyring(uint32& cookie,
|
|
|
|
BString& keyring);
|
|
|
|
|
|
|
|
// Master key
|
|
|
|
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t SetMasterKey(const BKey& key);
|
|
|
|
status_t RemoveMasterKey();
|
2011-11-16 13:53:36 +01:00
|
|
|
|
|
|
|
status_t AddKeyringToMaster(const char* keyring);
|
|
|
|
status_t RemoveKeyringFromMaster(const char* keyring);
|
|
|
|
|
|
|
|
status_t GetNextMasterKeyring(uint32& cookie,
|
|
|
|
BString& keyring);
|
|
|
|
|
2012-06-24 14:37:27 +02:00
|
|
|
// Locking
|
2011-11-16 13:53:36 +01:00
|
|
|
|
2012-06-24 14:37:27 +02:00
|
|
|
bool IsKeyringUnlocked(const char* keyring);
|
|
|
|
status_t LockKeyring(const char* keyring);
|
|
|
|
status_t LockMasterKeyring();
|
2011-11-16 13:53:36 +01:00
|
|
|
|
2011-12-22 14:58:19 +01:00
|
|
|
// Applications
|
|
|
|
|
2012-06-24 14:53:07 +02:00
|
|
|
status_t GetNextApplication(uint32& cookie,
|
2012-01-08 01:55:14 +01:00
|
|
|
BString& signature) const;
|
2012-06-24 14:53:07 +02:00
|
|
|
status_t GetNextApplication(const char* keyring,
|
|
|
|
uint32& cookie, BString& signature) const;
|
|
|
|
status_t RemoveApplication(const char* signature);
|
2012-01-08 01:55:14 +01:00
|
|
|
status_t RemoveApplication(const char* keyring,
|
2012-06-24 14:53:07 +02:00
|
|
|
const char* signature);
|
2011-12-22 14:58:19 +01:00
|
|
|
|
2011-11-16 13:53:36 +01:00
|
|
|
// Service functions
|
|
|
|
|
2011-12-22 14:58:19 +01:00
|
|
|
status_t GeneratePassword(BPasswordKey& password,
|
|
|
|
size_t length, uint32 flags);
|
|
|
|
float PasswordStrength(const char* password);
|
2012-01-04 01:51:59 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
status_t _SendKeyMessage(BMessage& message,
|
|
|
|
BMessage* reply) const;
|
2011-11-16 13:53:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _KEY_STORE_H
|