Example #1
0
func (self PKCS15Verifier) Verify(mech string, sig []byte, sigo []byte) (err os.Error) {
	err = ValidMech(mech, self)
	if err != nil {
		return
	}
	h, err := hashes.GetHash(mech)
	if err != nil {
		return
	}
	_, err = h.Write(sigo)
	if err != nil {
		return
	}
	hbytes := h.Sum()
	//log.Printf("Verify Hash: %X", hbytes)
	hi, err := hashes.GetPKCS15Hash(mech)
	if err != nil {
		return
	}
	err = rsa.VerifyPKCS1v15(self.PublicKey, hi, hbytes, sig)
	return
}
Example #2
0
func (self PKCS15Signer) Sign(mech string, in []byte) (out []byte, err os.Error) {
	err = ValidMech(mech, self)
	if err != nil {
		return
	}
	h, err := hashes.GetHash(mech)
	if err != nil {
		return
	}
	_, err = h.Write(in)
	if err != nil {
		return
	}
	hbytes := h.Sum()
	//log.Printf("Sign Hash: %X", hbytes)
	hi, err := hashes.GetPKCS15Hash(mech)
	if err != nil {
		return
	}
	out, err = rsa.SignPKCS1v15(rand.Reader, self.PrivateKey, hi, hbytes)
	return
}