// VerifyMIC implements gss_VerifyMIC API, as per https://tools.ietf.org/html/rfc2743#page-64.
330090
func (ctx *CtxId) VerifyMIC(messageBuffer *Buffer, tokenBuffer *Buffer) (
	qopState QOP, err error) {

	min := C.OM_uint32(0)
	qop := C.gss_qop_t(0)

	maj := C.wrap_gss_verify_mic(ctx.Fp_gss_verify_mic,
		&min,
		ctx.C_gss_ctx_id_t,
		messageBuffer.C_gss_buffer_t,
		tokenBuffer.C_gss_buffer_t,
		&qop)

	err = ctx.stashLastStatus(maj, min)
	if err != nil {
		return 0, err
	}

	return QOP(qop), nil
}
35121
func VerifyID(encodedEncryptedData []byte, id ID) error {
	return id.h.Verify(encodedEncryptedData)
}
761310
func (p7 *PKCS7) Verify() (err error) {
	if len(p7.Signers) == 0 {
		return errors.New("pkcs7: Message has no signers")
	}
	for _, signer := range p7.Signers {
		if err := verifySignature(p7, signer); err != nil {
			return err
		}
	}
	return nil
}
306698
func (hash *Hash) Verify(key *Key, signature []byte) error {
	err := tspiError(C.Tspi_Hash_VerifySignature(hash.handle, key.handle, (C.UINT32)(len(signature)), (*C.BYTE)(&signature[0])))
	return err
}
93939
func (c *Client) Verify() error {
	log.Printf("[INFO] verifying authentication")

	request, err := c.Request("GET", "/api/v1/authenticate", nil)
	if err != nil {
		return err
	}

	_, err = checkResp(c.HTTPClient.Do(request))
	return err
}
1149513
func (m *MockMembership) Verify(serializedID []byte, msg []byte, sig []byte) error {
	return m.VerifyErr
}
474745
func (u *Update) VerifySignature(signature []byte) *Update {
	u.Signature = signature
	return u
}
251422
func (hmac HMAC) Verify(key, buf []byte) error {
	if !hmac.IsValid() {
		return errors.WithStack(InvalidHashError{hmac.h})
	}

	// Once we have multiple hash types we'll need to expand this.
	t := hmac.hashType()
	if t != DefaultHashType {
		return errors.WithStack(UnknownHashTypeError{t})
	}

	expectedHMAC, err := DefaultHMAC(key, buf)
	if err != nil {
		return err
	}
	if hmac != expectedHMAC {
		return errors.WithStack(
			HashMismatchError{expectedHMAC.h, hmac.h})
	}
	return nil
}
881126
func Verify(publicKey *[PublicKeySize]byte, message []byte, sig *[SignatureSize]byte) bool {
	if sig[63]&224 != 0 {
		return false
	}

	var A edwards25519.ExtendedGroupElement
	if !A.FromBytes(publicKey) {
		return false
	}
	edwards25519.FeNeg(&A.X, &A.X)
	edwards25519.FeNeg(&A.T, &A.T)

	h := sha512.New()
	h.Write(sig[:32])
	h.Write(publicKey[:])
	h.Write(message)
	var digest [64]byte
	h.Sum(digest[:0])

	var hReduced [32]byte
	edwards25519.ScReduce(&hReduced, &digest)

	var R edwards25519.ProjectiveGroupElement
	var b [32]byte
	copy(b[:], sig[32:])
	edwards25519.GeDoubleScalarMultVartime(&R, &hReduced, &A, &b)

	var checkR [32]byte
	R.ToBytes(&checkR)
	return subtle.ConstantTimeCompare(sig[:32], checkR[:]) == 1
}
152864
func (m *SigningMethodRSAPSS) Verify(raw []byte, signature Signature, key interface{}) error {
	rsaKey, ok := key.(*rsa.PublicKey)
	if !ok {
		return ErrInvalidKey
	}
	return rsa.VerifyPSS(rsaKey, m.Hash, m.sum(raw), signature, m.Options)
}
970471
func (b *AESGCMBarrier) VerifyMaster(key []byte) error {
	b.l.RLock()
	defer b.l.RUnlock()
	if b.sealed {
		return ErrBarrierSealed
	}
	if subtle.ConstantTimeCompare(key, b.keyring.MasterKey()) != 1 {
		return ErrBarrierInvalidKey
	}
	return nil
}
499812
func Verify(msg []byte, sigInfo SignatureInfo) error {
	if sigInfo.Version < SigED25519 || sigInfo.Version > SigED25519ForKBFS {
		return errors.WithStack(UnknownSigVer{sigInfo.Version})
	}

	publicKey := kbcrypto.KIDToNaclSigningKeyPublic(
		sigInfo.VerifyingKey.KID().ToBytes())
	if publicKey == nil {
		return errors.WithStack(libkb.KeyCannotVerifyError{})
	}

	var naclSignature kbcrypto.NaclSignature
	if len(sigInfo.Signature) != len(naclSignature) {
		return errors.WithStack(kbcrypto.VerificationError{})
	}
	copy(naclSignature[:], sigInfo.Signature)

	if sigInfo.Version == SigED25519ForKBFS {
		msg = kbcrypto.SignaturePrefixKBFS.Prefix(msg)
	}

	if !publicKey.Verify(msg, naclSignature) {
		return errors.WithStack(kbcrypto.VerificationError{})
	}

	return nil
}
727645
func (js *JSONSignature) Verify() ([]PublicKey, error) {
	keys := make([]PublicKey, len(js.signatures))
	for i, signature := range js.signatures {
		signBytes, err := js.signBytes(signature.Protected)
		if err != nil {
			return nil, err
		}
		var publicKey PublicKey
		if len(signature.Header.Chain) > 0 {
			certBytes, err := base64.StdEncoding.DecodeString(signature.Header.Chain[0])
			if err != nil {
				return nil, err
			}
			cert, err := x509.ParseCertificate(certBytes)
			if err != nil {
				return nil, err
			}
			publicKey, err = FromCryptoPublicKey(cert.PublicKey)
			if err != nil {
				return nil, err
			}
		} else if signature.Header.JWK != nil {
			publicKey = signature.Header.JWK
		} else {
			return nil, errors.New("missing public key")
		}

		sigBytes, err := joseBase64UrlDecode(signature.Signature)
		if err != nil {
			return nil, err
		}

		err = publicKey.Verify(bytes.NewReader(signBytes), signature.Header.Algorithm, sigBytes)
		if err != nil {
			return nil, err
		}

		keys[i] = publicKey
	}
	return keys, nil
}
162259
func Verify(versionValidator VersionValidator, signedMsg []byte, keyring SigKeyring) (skey SigningPublicKey, verifiedMsg []byte, err error) {
	skey, stream, err := NewVerifyStream(versionValidator, bytes.NewReader(signedMsg), keyring)
	if err != nil {
		return nil, nil, err
	}

	verifiedMsg, err = ioutil.ReadAll(stream)
	if err != nil {
		return nil, nil, err
	}
	return skey, verifiedMsg, nil
}
517762
func (v Ed25519Verifier) Verify(key data.PublicKey, sig []byte, msg []byte) error {
	if key.Algorithm() != data.ED25519Key {
		return ErrInvalidKeyType{}
	}
	sigBytes := make([]byte, ed25519.SignatureSize)
	if len(sig) != ed25519.SignatureSize {
		logrus.Debugf("signature length is incorrect, must be %d, was %d.", ed25519.SignatureSize, len(sig))
		return ErrInvalid
	}
	copy(sigBytes, sig)

	keyBytes := make([]byte, ed25519.PublicKeySize)
	pub := key.Public()
	if len(pub) != ed25519.PublicKeySize {
		logrus.Errorf("public key is incorrect size, must be %d, was %d.", ed25519.PublicKeySize, len(pub))
		return ErrInvalidKeyLength{msg: fmt.Sprintf("ed25519 public key must be %d bytes.", ed25519.PublicKeySize)}
	}
	n := copy(keyBytes, key.Public())
	if n < ed25519.PublicKeySize {
		logrus.Errorf("failed to copy the key, must have %d bytes, copied %d bytes.", ed25519.PublicKeySize, n)
		return ErrInvalid
	}

	if !ed25519.Verify(ed25519.PublicKey(keyBytes), msg, sigBytes) {
		logrus.Debugf("failed ed25519 verification")
		return ErrInvalid
	}
	return nil
}
465881
func (c *Certificate) Verify(data []byte, sig *Signature) error {
	return c.Key.Verify(data, sig)
}
755759
func (pub PublicKey) Verify(mechanism pkcs11.Mechanism, message, signature []byte) error {
	s := pub.session
	s.Lock()
	defer s.Unlock()
	err := s.ctx.VerifyInit(s.handle, []*pkcs11.Mechanism{&mechanism}, pub.objectHandle)
	if err != nil {
		return err
	}
	err = s.ctx.Verify(s.handle, message, signature)
	if err != nil {
		return err
	}
	return nil
}