예제 #1
1
// Verify verifies that the message's signature matches its origin,
// returning an error when it doesn't.
func (m Message) Verify() error {
	if len(m.Signature) == 0 {
		return errors.New("empty signature")
	}
	hashed := sha256.Sum256(m.PayloadBytes)
	pubKey := rsa.PublicKey(m.Origin)
	return rsa.VerifyPKCS1v15(&pubKey, crypto.SHA256, hashed[:], m.Signature)
}
예제 #2
0
func (id identity) Fingerprint() fingerprint {
	pubKey := rsa.PublicKey(id)
	derEncoded, err := x509.MarshalPKIXPublicKey(&pubKey)
	if err != nil {
		panic(err)
	}
	return fingerprint(sha256.Sum256(derEncoded))
}