dc1acef865
* Modified the API greatly to be based on BKey* instead of BPassword*. * Added BKeyPurpose and used it instead of BKeyType. It is supposed to indicate the purpose of a key so that an app can look up keys on a more granular level. The BKeyType on the other hand actually identifies the type (i.e. subclass of BKey) so an app knows how to handle a given key or may only enumerate/use keys it is compatible with. * Made everything based on a raw data buffer for now, only BPasswordKey is implemented yet which stores the (0 terminated) string into that data buffer. * Removed the additional data BMessage as I don't yet see where it fits in. While I could imagine adding meta data to a key may be nice it might be an interoperability concern when keys are shared by different apps. * Moved the app functions to the keystore as per the TODO, but not sure how to actually implement them.
102 lines
3.0 KiB
C++
102 lines
3.0 KiB
C++
/*
|
|
* 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();
|
|
|
|
// TODO: -> GetNextPassword() - there can always be more than one key
|
|
// with the same identifier/secondaryIdentifier (ie. different username)
|
|
status_t GetKey(BKeyType type, BKeyPurpose purpose,
|
|
const char* identifier, BKey& key);
|
|
status_t GetKey(BKeyType type, BKeyPurpose purpose,
|
|
const char* identifier,
|
|
const char* secondaryIdentifier, BKey& key);
|
|
status_t GetKey(BKeyType type, BKeyPurpose purpose,
|
|
const char* identifier,
|
|
const char* secondaryIdentifier,
|
|
bool secondaryIdentifierOptional,
|
|
BKey& key);
|
|
|
|
status_t GetKey(const char* keyring,
|
|
BKeyType type, BKeyPurpose purpose,
|
|
const char* identifier, BKey& key);
|
|
status_t GetKey(const char* keyring,
|
|
BKeyType type, BKeyPurpose purpose,
|
|
const char* identifier,
|
|
const char* secondaryIdentifier, BKey& key);
|
|
status_t GetKey(const char* keyring,
|
|
BKeyType type, BKeyPurpose purpose,
|
|
const char* identifier,
|
|
const char* secondaryIdentifier,
|
|
bool secondaryIdentifierOptional,
|
|
BKey& key);
|
|
|
|
status_t RegisterKey(const BKey& key);
|
|
status_t RegisterKey(const char* keyring,
|
|
const BKey& key);
|
|
status_t UnregisterKey(const BKey& key);
|
|
status_t UnregisterKey(const char* keyring,
|
|
const BKey& key);
|
|
|
|
status_t GetNextKey(uint32& cookie, BKey& key);
|
|
status_t GetNextKey(BKeyType type, BKeyPurpose purpose,
|
|
uint32& cookie, BKey& key);
|
|
status_t GetNextKey(const char* keyring,
|
|
uint32& cookie, BKey& key);
|
|
status_t GetNextKey(const char* keyring,
|
|
BKeyType type, BKeyPurpose purpose,
|
|
uint32& cookie, BKey& key);
|
|
|
|
// Keyrings
|
|
|
|
status_t RegisterKeyring(const char* keyring,
|
|
const BKey& key);
|
|
status_t UnregisterKeyring(const char* keyring);
|
|
|
|
status_t GetNextKeyring(uint32& cookie,
|
|
BString& keyring);
|
|
|
|
// Master key
|
|
|
|
status_t SetMasterKey(const BKey& key);
|
|
status_t RemoveMasterKey();
|
|
|
|
status_t AddKeyringToMaster(const char* keyring);
|
|
status_t RemoveKeyringFromMaster(const char* keyring);
|
|
|
|
status_t GetNextMasterKeyring(uint32& cookie,
|
|
BString& keyring);
|
|
|
|
// Access
|
|
|
|
bool IsKeyringAccessible(const char* keyring);
|
|
status_t RevokeAccess(const char* keyring);
|
|
status_t RevokeMasterAccess();
|
|
|
|
// Applications
|
|
|
|
status_t GetNextApplication(const BKey& key,
|
|
uint32& cookie, BString& signature) const;
|
|
status_t RemoveApplication(const BKey& key,
|
|
const char* signature);
|
|
|
|
// Service functions
|
|
|
|
status_t GeneratePassword(BPasswordKey& password,
|
|
size_t length, uint32 flags);
|
|
float PasswordStrength(const char* password);
|
|
};
|
|
|
|
|
|
#endif // _KEY_STORE_H
|