Skip to content

Commit

Permalink
testdata: Include a test for askpass during signing
Browse files Browse the repository at this point in the history
Signed-off-by: Morten Linderud <morten@linderud.pw>
  • Loading branch information
Foxboron committed Jan 12, 2025
1 parent a7c5e2e commit 9489a80
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions cmd/ssh-tpm-agent/testdata/script/agent_password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Create an askpass binary
env SSH_ASKPASS=./askpass-test
exec go build -o askpass-test askpass.go
exec ./askpass-test passphrase

# ssh sign file with password - ecdsa
env SSH_ASKPASS_REQUIRE=force
exec ssh-tpm-agent -d --no-load &agent&
exec ssh-tpm-keygen -N 12345
exec ssh-tpm-add
stdout id_ecdsa.tpm
exec ssh-add -l
stdout ECDSA
exec ssh-keygen -Y sign -n file -f .ssh/id_ecdsa.pub file_to_sign.txt
stdin file_to_sign.txt
exec ssh-keygen -Y check-novalidate -n file -f .ssh/id_ecdsa.pub -s file_to_sign.txt.sig
exists file_to_sign.txt.sig
exec ssh-add -D
rm file_to_sign.txt.sig

-- file_to_sign.txt --
Hello World

-- go.mod --
module example.com/askpass

-- askpass.go --
package main

import (
"fmt"
"os"
"strings"
)

func main() {
if strings.Contains(os.Args[1], "passphrase") {
fmt.Println("12345")
}
}

0 comments on commit 9489a80

Please sign in to comment.