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 1751ab46a8SMichael Lotz status_t GetKey(BKeyType type, const char* identifier, 1851ab46a8SMichael Lotz BKey& key); 1951ab46a8SMichael Lotz status_t GetKey(BKeyType type, const char* identifier, 203b3884d9SMichael Lotz const char* secondaryIdentifier, BKey& key); 2151ab46a8SMichael Lotz status_t GetKey(BKeyType type, const char* identifier, 223b3884d9SMichael Lotz const char* secondaryIdentifier, 233b3884d9SMichael Lotz bool secondaryIdentifierOptional, 243b3884d9SMichael Lotz BKey& key); 253b3884d9SMichael Lotz 26dc1acef8SMichael Lotz status_t GetKey(const char* keyring, 2751ab46a8SMichael Lotz BKeyType type, const char* identifier, 2851ab46a8SMichael Lotz BKey& key); 29dc1acef8SMichael Lotz status_t GetKey(const char* keyring, 3051ab46a8SMichael Lotz BKeyType type, const char* identifier, 313b3884d9SMichael Lotz const char* secondaryIdentifier, BKey& key); 32dc1acef8SMichael Lotz status_t GetKey(const char* keyring, 3351ab46a8SMichael Lotz BKeyType type, const char* identifier, 343b3884d9SMichael Lotz const char* secondaryIdentifier, 353b3884d9SMichael Lotz bool secondaryIdentifierOptional, 363b3884d9SMichael Lotz BKey& key); 373b3884d9SMichael Lotz 38b7398289SMichael Lotz status_t AddKey(const BKey& key); 39b7398289SMichael Lotz status_t AddKey(const char* keyring, const BKey& key); 40b7398289SMichael Lotz status_t RemoveKey(const BKey& key); 41b7398289SMichael Lotz status_t RemoveKey(const char* keyring, const BKey& key); 423b3884d9SMichael Lotz 43dc1acef8SMichael Lotz status_t GetNextKey(uint32& cookie, BKey& key); 44dc1acef8SMichael Lotz status_t GetNextKey(BKeyType type, BKeyPurpose purpose, 453b3884d9SMichael Lotz uint32& cookie, BKey& key); 46dc1acef8SMichael Lotz status_t GetNextKey(const char* keyring, 473b3884d9SMichael Lotz uint32& cookie, BKey& key); 48dc1acef8SMichael Lotz status_t GetNextKey(const char* keyring, 49dc1acef8SMichael Lotz BKeyType type, BKeyPurpose purpose, 50dc1acef8SMichael Lotz uint32& cookie, BKey& key); 513b3884d9SMichael Lotz 523b3884d9SMichael Lotz // Keyrings 533b3884d9SMichael Lotz 54*d4d6d123SMichael Lotz status_t AddKeyring(const char* keyring); 55b7398289SMichael Lotz status_t RemoveKeyring(const char* keyring); 563b3884d9SMichael Lotz 573b3884d9SMichael Lotz status_t GetNextKeyring(uint32& cookie, 583b3884d9SMichael Lotz BString& keyring); 593b3884d9SMichael Lotz 603b3884d9SMichael Lotz // Master key 613b3884d9SMichael Lotz 62dc1acef8SMichael Lotz status_t SetMasterKey(const BKey& key); 63dc1acef8SMichael Lotz status_t RemoveMasterKey(); 643b3884d9SMichael Lotz 653b3884d9SMichael Lotz status_t AddKeyringToMaster(const char* keyring); 663b3884d9SMichael Lotz status_t RemoveKeyringFromMaster(const char* keyring); 673b3884d9SMichael Lotz 683b3884d9SMichael Lotz status_t GetNextMasterKeyring(uint32& cookie, 693b3884d9SMichael Lotz BString& keyring); 703b3884d9SMichael Lotz 71c8ae843fSMichael Lotz // Locking 723b3884d9SMichael Lotz 73c8ae843fSMichael Lotz bool IsKeyringUnlocked(const char* keyring); 74c8ae843fSMichael Lotz status_t LockKeyring(const char* keyring); 75c8ae843fSMichael Lotz status_t LockMasterKeyring(); 763b3884d9SMichael Lotz 77dc1acef8SMichael Lotz // Applications 78dc1acef8SMichael Lotz 79f8ccc323SMichael Lotz status_t GetNextApplication(uint32& cookie, 8064ca113fSMichael Lotz BString& signature) const; 81f8ccc323SMichael Lotz status_t GetNextApplication(const char* keyring, 82f8ccc323SMichael Lotz uint32& cookie, BString& signature) const; 83f8ccc323SMichael Lotz status_t RemoveApplication(const char* signature); 8464ca113fSMichael Lotz status_t RemoveApplication(const char* keyring, 85f8ccc323SMichael Lotz const char* signature); 86dc1acef8SMichael Lotz 873b3884d9SMichael Lotz // Service functions 883b3884d9SMichael Lotz 89dc1acef8SMichael Lotz status_t GeneratePassword(BPasswordKey& password, 90dc1acef8SMichael Lotz size_t length, uint32 flags); 91dc1acef8SMichael Lotz float PasswordStrength(const char* password); 921c399649SMichael Lotz 931c399649SMichael Lotz private: 941c399649SMichael Lotz status_t _SendKeyMessage(BMessage& message, 951c399649SMichael Lotz BMessage* reply) const; 963b3884d9SMichael Lotz }; 973b3884d9SMichael Lotz 983b3884d9SMichael Lotz 993b3884d9SMichael Lotz #endif // _KEY_STORE_H 100