Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
crypto.hh
Go to the documentation of this file.
1#pragma once
3
4
5#include <map>
6#include <string>
7
8namespace nix {
9
10struct Key
11{
12 std::string name;
13 std::string key;
14
19 Key(std::string_view s);
20
21 std::string to_string() const;
22
23protected:
24 Key(std::string_view name, std::string && key)
25 : name(name), key(std::move(key)) { }
26};
27
28struct PublicKey;
29
30struct SecretKey : Key
31{
32 SecretKey(std::string_view s);
33
37 std::string signDetached(std::string_view s) const;
38
39 PublicKey toPublicKey() const;
40
41 static SecretKey generate(std::string_view name);
42
43private:
44 SecretKey(std::string_view name, std::string && key)
45 : Key(name, std::move(key)) { }
46};
47
48struct PublicKey : Key
49{
50 PublicKey(std::string_view data);
51
52private:
53 PublicKey(std::string_view name, std::string && key)
54 : Key(name, std::move(key)) { }
55 friend struct SecretKey;
56};
57
58typedef std::map<std::string, PublicKey> PublicKeys;
59
64bool verifyDetached(const std::string & data, const std::string & sig,
65 const PublicKeys & publicKeys);
66
67PublicKeys getDefaultPublicKeys();
68
69}
Key(std::string_view s)
Definition crypto.cc:19
Definition crypto.hh:49
std::string signDetached(std::string_view s) const
Definition crypto.cc:44