mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-15 18:56:16 +02:00
0746951be1
* Finish converting existing comments for internal API docs 99% of this was just reformatting existing comments. Only two exceptions: - Expanded upon `BuildResult::status` compat note - Split up file-level `symbol-table.hh` doc comments to get per-definition docs Also fixed a few whitespace goofs, turning leading tabs to spaces and removing trailing spaces. Picking up from #8133 * Fix two things from comments * Use triple-backtick not indent for `dumpPath` * Convert GNU-style `\`..'` quotes to markdown style in API docs This will render correctly.
69 lines
1.3 KiB
C++
69 lines
1.3 KiB
C++
#pragma once
|
||
///@file
|
||
|
||
#include "types.hh"
|
||
|
||
#include <map>
|
||
|
||
namespace nix {
|
||
|
||
struct Key
|
||
{
|
||
std::string name;
|
||
std::string key;
|
||
|
||
/**
|
||
* Construct Key from a string in the format
|
||
* ‘<name>:<key-in-base64>’.
|
||
*/
|
||
Key(std::string_view s);
|
||
|
||
std::string to_string() const;
|
||
|
||
protected:
|
||
Key(std::string_view name, std::string && key)
|
||
: name(name), key(std::move(key)) { }
|
||
};
|
||
|
||
struct PublicKey;
|
||
|
||
struct SecretKey : Key
|
||
{
|
||
SecretKey(std::string_view s);
|
||
|
||
/**
|
||
* Return a detached signature of the given string.
|
||
*/
|
||
std::string signDetached(std::string_view s) const;
|
||
|
||
PublicKey toPublicKey() const;
|
||
|
||
static SecretKey generate(std::string_view name);
|
||
|
||
private:
|
||
SecretKey(std::string_view name, std::string && key)
|
||
: Key(name, std::move(key)) { }
|
||
};
|
||
|
||
struct PublicKey : Key
|
||
{
|
||
PublicKey(std::string_view data);
|
||
|
||
private:
|
||
PublicKey(std::string_view name, std::string && key)
|
||
: Key(name, std::move(key)) { }
|
||
friend struct SecretKey;
|
||
};
|
||
|
||
typedef std::map<std::string, PublicKey> PublicKeys;
|
||
|
||
/**
|
||
* @return true iff ‘sig’ is a correct signature over ‘data’ using one
|
||
* of the given public keys.
|
||
*/
|
||
bool verifyDetached(const std::string & data, const std::string & sig,
|
||
const PublicKeys & publicKeys);
|
||
|
||
PublicKeys getDefaultPublicKeys();
|
||
|
||
}
|