gunk-dev/the-valley

sigverify.nix

source6db7e2f30e24main's published tip history
1.9 KiB
1# The security-key signature verifier: its tests with a software
2# authenticator, and the shipped command over a real signed tag.
3{ pkgs, packages, ... }:
4let
5 # OpenSSH's sk-dummy: the software FIDO authenticator from OpenSSH's own
6 # regression suite. It signs with whatever flags the client asks for, so
7 # a key stub without the touch-required flag gets a signature with the
8 # user-presence bit clear, exactly as a real key does. That is the
9 # signature this verifier exists to refuse, made by real ssh-keygen and
10 # with no hardware.
11 #
12 # It is built from the same source as the ssh-keygen the checks run,
13 # because a provider must speak its OpenSSH's middleware API version.
14 # Only the checks use it.
15 sk-dummy = pkgs.openssh.overrideAttrs {
16 pname = "openssh-sk-dummy";
17 outputs = [ "out" ];
18 buildPhase = ''
19 runHook preBuild
20 make -j$NIX_BUILD_CORES openbsd-compat/libopenbsd-compat.a
21 make -j$NIX_BUILD_CORES regress/misc/sk-dummy/sk-dummy.so
22 runHook postBuild
23 '';
24 doCheck = false;
25 doInstallCheck = false;
26 installPhase = ''
27 runHook preInstall
28 install -Dm755 regress/misc/sk-dummy/sk-dummy.so $out/lib/sk-dummy.so
29 runHook postInstall
30 '';
31 postInstall = "";
32 };
33 provider = "${sk-dummy}/lib/sk-dummy.so";
34in
35{
36 # The Go tests, with the security-key cases switched on: real
37 # ssh-keygen signing through sk-dummy, including a key stub rewritten
38 # to skip the touch, which ssh-keygen -Y verify and git verify-tag both
39 # accept and sigverify must refuse.
40 sigverify-unit = packages.sigverify.unit.overrideAttrs (old: {
41 env = (old.env or { }) // {
42 SIGVERIFY_SK_PROVIDER = provider;
43 };
44 });
45
46 # The shipped command, run the way a consumer runs it.
47 sigverify-e2e = pkgs.runCommand "valley-sigverify-e2e" {
48 nativeBuildInputs = [
49 pkgs.git
50 pkgs.openssh
51 packages.sigverify
52 ];
53 SSH_SK_PROVIDER = provider;
54 } (builtins.readFile ./sigverify-e2e.sh);
55}