libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Keystore.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include <cstdint>
6#include <memory>
7#include <unordered_map>
9
10namespace Ship {
11class Config;
12
19enum class KeyOrigin { User, Game, System };
20
26 std::string Name;
28 std::vector<uint8_t> Data;
31};
32
48class Keystore : public Component {
49 public:
53 explicit Keystore(std::shared_ptr<Config> config = nullptr);
54 ~Keystore() override = default;
55
59 void Load();
60
64 void Save();
65
73 bool AddKey(const std::string& keyName, const std::vector<uint8_t>& keyData, KeyOrigin origin = KeyOrigin::Game);
74
80 bool RemoveKey(const std::string& keyName);
81
87 bool HasKey(const std::vector<uint8_t>& keyData) const;
88
94 std::vector<KeystoreEntry> GetKey(const std::string& keyName) const;
95
100 std::vector<KeystoreEntry> GetAllKeys() const;
101
102 private:
103 std::unordered_map<std::string, KeystoreEntry> mKeys;
104 std::shared_ptr<Config> mConfig;
105};
106
107} // namespace Ship
A named Part with a parent/child hierarchy and optional thread safety.
Definition Component.h:34
Persistent store of cryptographic keys used for archive signature verification.
Definition Keystore.h:48
Keystore(std::shared_ptr< Config > config=nullptr)
Constructs an empty Keystore.
std::vector< KeystoreEntry > GetAllKeys() const
Returns every key currently stored.
bool AddKey(const std::string &keyName, const std::vector< uint8_t > &keyData, KeyOrigin origin=KeyOrigin::Game)
Adds a key to the store.
bool RemoveKey(const std::string &keyName)
Removes a key from the store by name.
~Keystore() override=default
std::vector< KeystoreEntry > GetKey(const std::string &keyName) const
Retrieves all keys that match the given name.
void Load()
Loads all keys from the persistent storage file on disk.
void Save()
Persists the current set of keys to the storage file on disk.
bool HasKey(const std::vector< uint8_t > &keyData) const
Checks whether a key with the given data exists in the store.
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
KeyOrigin
Describes where a key originated.
Definition Keystore.h:19
A single named key stored in the Keystore.
Definition Keystore.h:24
KeyOrigin Origin
Origin category for this key.
Definition Keystore.h:30
std::string Name
Human-readable name identifying this key.
Definition Keystore.h:26
std::vector< uint8_t > Data
Raw key bytes.
Definition Keystore.h:28