Exemplo n.º 1
0
// Verifies whether the X0 and hash is correct
func TestVerifySignature(t *testing.T) {
	setupTestSig()

	if !conode.VerifySignature(suite, &reply, X0, hash) {
		t.Error("Verification failed")
	} else {
		dbg.Lvl2("Verification passed")
	}
}
Exemplo n.º 2
0
// Verify signature takes a file name and the name of the signature file
// if signature file is empty ( sigFile == ""), then the signature file is
// simply the name of the file appended with ".sig" extension.
func VerifyFileSignature(file, sigFile string) bool {
	if file == "" {
		dbg.Fatal("Can not verify anything with an empty file name !")
	}

	// by default
	if sigFile == "" {
		sigFile = file + sigExtension
	}
	// read the sig
	signature := conode.StampSignature{
		SuiteStr: suite.String(),
	}
	if err := signature.Open(sigFile); err != nil {
		dbg.Fatal("Couldn't read signature-file", sigFile, ":", err)
	}
	hash := hashFile(file)
	dbg.Print(base64.StdEncoding.EncodeToString(hash))
	// Then verify the proper signature
	return conode.VerifySignature(suite, &signature, public_X0, hash)
}