diff --git a/go.mod b/go.mod index 17780ec..1e7ed58 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,6 @@ module suah.dev/ogvt go 1.13 require ( - golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 suah.dev/protect v1.0.0 ) diff --git a/go.sum b/go.sum index a7e8e69..d6c0e34 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 h1:+ELyKg6m8UBf0nPFSqD0mi7zUfwPyXo23HNjMnXPz7w= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/main.go b/main.go index e2c2a03..4c09281 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "path/filepath" "strings" "golang.org/x/crypto/openpgp" @@ -36,6 +37,14 @@ func main() { _ = protect.Unveil(pub, "r") _ = protect.UnveilBlock() + if sig != "" && file == "" { + // Check for a 'file' with the .sig extensions removed + bn := strings.TrimSuffix(sig, filepath.Ext(sig)) + if _, err := os.Stat(bn); err == nil { + file = bn + } + } + fPub, err := os.Open(pub) errExit(err) diff --git a/run_test.sh b/run_test.sh index 9fda212..4133610 100755 --- a/run_test.sh +++ b/run_test.sh @@ -5,12 +5,20 @@ set -e mandoc -T lint ./ogvt.1 go build printf "Testing detached armor (asc)\t\t" -./ogvt -file test/uptime.txt -sig test/uptime.txt.asc -pub test/adent.pub >/dev/null && echo "OK" +./ogvt -file test/uptime.txt -sig test/uptime.txt.asc -pub test/adent.pub >/dev/null && echo "OK" || echo "FAIL" + printf "Testing detached non-armor (gpg)\t" -./ogvt -file test/uptime.txt -sig test/uptime.txt.gpg -pub test/adent.pub >/dev/null && echo "OK" +./ogvt -file test/uptime.txt -sig test/uptime.txt.gpg -pub test/adent.pub >/dev/null && echo "OK" || echo "FAIL" + printf "Testing detached non-armor (sig)\t" -./ogvt -file test/uptime.txt -sig test/uptime.txt.sig -pub test/adent.pub >/dev/null && echo "OK" +./ogvt -file test/uptime.txt -sig test/uptime.txt.sig -pub test/adent.pub >/dev/null && echo "OK" || echo "FAIL" + +printf "Testing just having a sig (nofile)\t" +./ogvt -sig test/uptime.txt.sig -pub test/adent.pub >/dev/null && echo "OK" || echo "FAIL" + printf "Testing bad sig file\t\t\t" -./ogvt -file test/uptime.txt -sig test/bad.sig -pub test/adent.pub >/dev/null || echo "OK" +./ogvt -file test/uptime.txt -sig test/bad.sig -pub test/adent.pub >/dev/null && echo "FAIL" || echo "OK" + printf "Testing empty file\t\t\t" -./ogvt -file test/uptime.txt -sig /dev/null -pub test/adent.pub >/dev/null || echo "OK" +./ogvt -file test/uptime.txt -sig /dev/null -pub test/adent.pub >/dev/null && echo "FAIL" || echo "OK" +