Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
local-keys.hh
Go to the documentation of this file.
1#pragma once
3
5
6#include <map>
7
8namespace nix {
9
16{
17 std::string keyName;
18
22 std::string sig;
23
27 static Signature parse(std::string_view);
28
34 template<typename Container>
35 static std::set<Signature> parseMany(const Container & sigStrs);
36
37 std::string to_string() const;
38
39 static Strings toStrings(const std::set<Signature> & sigs);
40
41 auto operator<=>(const Signature &) const = default;
42};
43
44struct Key
45{
46 std::string name;
47 std::string key;
48
49 std::string to_string() const;
50
51protected:
52
60 Key(std::string_view s, bool sensitiveValue);
61
62 Key(std::string_view name, std::string && key)
63 : name(name)
64 , key(std::move(key))
65 {
66 }
67};
68
69struct PublicKey;
70
71struct SecretKey : Key
72{
73 SecretKey(std::string_view s);
74
78 Signature signDetached(std::string_view s) const;
79
80 PublicKey toPublicKey() const;
81
82 static SecretKey generate(std::string_view name);
83
84private:
85 SecretKey(std::string_view name, std::string && key)
86 : Key(name, std::move(key))
87 {
88 }
89};
90
91struct PublicKey : Key
92{
93 PublicKey(std::string_view data);
94
99 bool verifyDetached(std::string_view data, const Signature & sig) const;
100
107 bool verifyDetachedAnon(std::string_view data, const Signature & sig) const;
108
109private:
110 PublicKey(std::string_view name, std::string && key)
111 : Key(name, std::move(key))
112 {
113 }
114 friend struct SecretKey;
115};
116
120typedef std::map<std::string, PublicKey> PublicKeys;
121
126bool verifyDetached(std::string_view data, const Signature & sig, const PublicKeys & publicKeys);
127
128} // namespace nix
129
130JSON_IMPL(nix::Signature)
std::map< std::string, PublicKey > PublicKeys
Definition local-keys.hh:120
bool verifyDetached(std::string_view data, const Signature &sig, const PublicKeys &publicKeys)
Definition local-keys.cc:167
Key(std::string_view s, bool sensitiveValue)
Definition local-keys.cc:84
Definition local-keys.hh:92
bool verifyDetachedAnon(std::string_view data, const Signature &sig) const
Definition local-keys.cc:154
bool verifyDetached(std::string_view data, const Signature &sig) const
Definition local-keys.cc:146
Signature signDetached(std::string_view s) const
Definition local-keys.cc:111
Definition local-keys.hh:16
std::string sig
Definition local-keys.hh:22
static Signature parse(std::string_view)
Definition local-keys.cc:50
static std::set< Signature > parseMany(const Container &sigStrs)
Definition local-keys.cc:65