Example #1
0
File: pgp.go Project: netantho/mig
// TransformArmoredPubKeysToKeyring takes a list of public PGP key in armored form and transforms
// it into a keyring that can be used in other openpgp's functions
func GetFingerprintFromSignature(data string, signature string, keyring io.Reader) (fingerprint string, err error) {
	defer func() {
		if e := recover(); e != nil {
			err = fmt.Errorf("GetFingerprintFromSignature() -> %v", e)
		}
	}()
	_, entity, err := verify.Verify(data, signature, keyring)
	if err != nil {
		panic(err)
	}
	fingerprint = hex.EncodeToString(entity.PrimaryKey.Fingerprint[:])
	return
}
Example #2
0
// Validate verifies that the Action received contained all the
// necessary fields, and returns an error when it doesn't.
func (a Action) VerifySignature(keyring io.Reader) (err error) {
	// Verify the signature
	astr, err := a.String()
	if err != nil {
		return errors.New("Failed to stringify action")
	}
	valid, _, err := verify.Verify(astr, a.PGPSignature, keyring)
	if err != nil {
		return errors.New("Failed to verify PGP Signature")
	}
	if !valid {
		return errors.New("Invalid PGP Signature")
	}

	return nil
}