wg-hive: derive test keys from a fixed seed so every store agrees
This commit is contained in:
parent
15964a06f8
commit
4b71bd97eb
1 changed files with 17 additions and 9 deletions
|
|
@ -2,10 +2,10 @@
|
|||
# Unlike ../module-eval, which only reads the rendered `networking.wireguard`
|
||||
# options, this boots both hosts and sends packets.
|
||||
#
|
||||
# Keys are minted by a throwaway derivation at build time and nothing is
|
||||
# committed. The module takes peer public keys as eval-time strings
|
||||
# (`swarm.hives.<name>.wireguardPublicKey`), so they are read back from
|
||||
# the derivation's output.
|
||||
# Keys are derived from a fixed per-host seed, so every store builds the
|
||||
# same bytes and nothing is committed. The module takes peer public keys
|
||||
# as eval-time strings (`swarm.hives.<name>.wireguardPublicKey`), so they
|
||||
# are read back from the derivation's output.
|
||||
{
|
||||
pkgs,
|
||||
self,
|
||||
|
|
@ -13,11 +13,19 @@
|
|||
let
|
||||
mkKey =
|
||||
name:
|
||||
pkgs.runCommand "wg-hive-test-key-${name}" { nativeBuildInputs = [ pkgs.wireguard-tools ]; } ''
|
||||
mkdir $out
|
||||
wg genkey > $out/private
|
||||
wg pubkey < $out/private > $out/public
|
||||
'';
|
||||
pkgs.runCommand "wg-hive-test-key-${name}"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
pkgs.wireguard-tools
|
||||
pkgs.openssl
|
||||
];
|
||||
}
|
||||
''
|
||||
# Test-only key: base64 of sha256(seed); wg clamps the scalar itself.
|
||||
mkdir $out
|
||||
printf '%s' 'hyperhive-wg-hive-test-${name}' | openssl dgst -sha256 -binary | base64 > $out/private
|
||||
wg pubkey < $out/private > $out/public
|
||||
'';
|
||||
keys = {
|
||||
h1 = mkKey "h1";
|
||||
h2 = mkKey "h2";
|
||||
|
|
|
|||
Loading…
Reference in a new issue