tvl-depot/third_party/nix/src/libstore/crypto.hh
Vincent Ambo 3652326ed2 refactor(3p/nix): Anchor local includes at src/
Previously all includes were anchored in one global mess of header
files. This moves the includes into filesystem "namespaces" (if you
will) for each sub-package of Nix.

Note: This commit does not introduce the relevant build system changes.
2020-05-27 21:56:34 +01:00

49 lines
1.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <map>
#include "libutil/types.hh"
namespace nix {
struct Key {
std::string name;
std::string key;
/* Construct Key from a string in the format
<name>:<key-in-base64>. */
Key(const std::string& s);
protected:
Key(const std::string& name, const std::string& key) : name(name), key(key) {}
};
struct PublicKey;
struct SecretKey : Key {
SecretKey(const std::string& s);
/* Return a detached signature of the given string. */
std::string signDetached(const std::string& data) const;
PublicKey toPublicKey() const;
};
struct PublicKey : Key {
PublicKey(const std::string& s);
private:
PublicKey(const std::string& name, const std::string& key) : Key(name, 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();
} // namespace nix