// GetMessageDigestAttribute gets the signed MessageDigest attribute from the
// SignerInfo.
777708
func (si SignerInfo) GetMessageDigestAttribute() ([]byte, error) {
	rv, err := si.SignedAttrs.GetOnlyAttributeValueBytes(oid.AttributeMessageDigest)
	if err != nil {
		return nil, err
	}
	if rv.Class != asn1.ClassUniversal || rv.Tag != asn1.TagOctetString {
		return nil, ASN1Error{"bad class or tag"}
	}

	return rv.Bytes, nil
}
1050802
func (i *MintedOAuthTokenInfo) toBigQueryMessage() *bqpb.OAuthToken {
	return &bqpb.OAuthToken{
		Fingerprint:      utils.TokenFingerprint(i.Response.AccessToken),
		GrantFingerprint: utils.TokenFingerprint(i.Request.GrantToken),
		ServiceAccount:   i.GrantBody.ServiceAccount,
		OauthScopes:      i.Request.OauthScope,
		ProxyIdentity:    i.GrantBody.Proxy,
		EndUserIdentity:  i.GrantBody.EndUser,

		// Note: we are not using 'issued_at' because the returned token is often
		// fetched from cache (and thus it was issued some time ago, not now). This
		// timestamp is not preserved in the cache, since it can be calculated from
		// 'expiration' if necessary.
		RequestedAt: google.NewTimestamp(i.RequestedAt),
		Expiration:  i.Response.Expiry,

		// Information supplied by the caller.
		AuditTags: i.Request.AuditTags,

		// Information about the service account rule used.
		ConfigRev:  i.ConfigRev,
		ConfigRule: i.Rule.Name,

		// Information about the request handler environment.
		PeerIp:         i.PeerIP.String(),
		ServiceVersion: i.Response.ServiceVersion,
		GaeRequestId:   i.RequestID,
		AuthDbRev:      i.AuthDBRev,
	}
}
1277176
func IsValidAttribute(e *Entry) bool {
	// Check ExtIDs for valid formatting, then process them
	if len(e.ExtIDs) < 5 || bytes.Compare(e.ExtIDs[0], []byte("IdentityAttribute")) != 0 {
		return false
	}
	receiverChainID := string(e.ExtIDs[1])
	signerChainID := string(e.ExtIDs[4])
	if len(receiverChainID) != 64 || len(signerChainID) != 64 {
		return false
	}
	var signature [ed.SignatureSize]byte
	copy(signature[:], e.ExtIDs[2])
	var signerKey [ed.PublicKeySize]byte
	signerPubString := string(e.ExtIDs[3])
	if IdentityKeyStringType(signerPubString) != IDPub {
		return false
	}
	b := base58.Decode(signerPubString)
	copy(signerKey[:], b[IDKeyPrefixLength:IDKeyBodyLength])

	// Message that was signed = ReceiverChainID + DestinationChainID + AttributesJSON
	msg := []byte(receiverChainID + e.ChainID)
	attributesHash := sha256.Sum256(e.Content)
	msg = append(msg, attributesHash[:]...)
	return ed.Verify(&signerKey, msg, &signature)
}
499991
func GetMessage(err interface{}) string {
	switch e := err.(type) {
	case DropboxError:
		return extractFullErrorMessage(e, false)
	case runtime.Error:
		return runtime.Error(e).Error()
	case error:
		return e.Error()
	default:
		return "Passed a non-error to GetMessage"
	}
}
1373750
func getStorageInfoMsg(storageInfo StorageInfo) string {
	var msg string
	if storageInfo.Backend.Type == BackendErasure {
		diskInfo := fmt.Sprintf(" %d Online, %d Offline. ", storageInfo.Backend.OnlineDisks, storageInfo.Backend.OfflineDisks)
		msg += colorBlue("Status:") + fmt.Sprintf(getFormatStr(len(diskInfo), 8), diskInfo)
	}
	return msg
}
1286097
func (ga *gossipAdapterImpl) ValidateStateInfoMessage(msg *proto.SignedGossipMessage) error {
	return ga.gossipServiceImpl.validateStateInfoMsg(msg)
}
816048
func GetMaximumDHCPMessageSize(o dhcp4.Options) (uint16, error) {
	v := o.Get(dhcp4.OptionMaximumDHCPMessageSize)
	if v == nil {
		return 0, dhcp4.ErrOptionNotPresent
	}
	var u Uint16
	return uint16(u), (&u).UnmarshalBinary(v)
}
551551
func GetMessage(err error) string {
	if err == nil {
		return ""
	}
	cast, ok := err.(*Error)
	if !ok {
		return err.Error()
	}
	return cast.Message()
}
893413
func (srv *Server) getMessage() (interface{}, error) {
	var rawXMLMsgBytes []byte
	var err error
	if srv.isSafeMode {
		var encryptedXMLMsg message.EncryptedXMLMsg
		if err := xml.NewDecoder(srv.Request.Body).Decode(&encryptedXMLMsg); err != nil {
			return nil, fmt.Errorf("从body中解析xml失败,err=%v", err)
		}

		//验证消息签名
		timestamp := srv.Query("timestamp")
		srv.timestamp, err = strconv.ParseInt(timestamp, 10, 32)
		if err != nil {
			return nil, err
		}
		nonce := srv.Query("nonce")
		srv.nonce = nonce
		msgSignature := srv.Query("msg_signature")
		msgSignatureGen := util.Signature(srv.Token, timestamp, nonce, encryptedXMLMsg.EncryptedMsg)
		if msgSignature != msgSignatureGen {
			return nil, fmt.Errorf("消息不合法，验证签名失败")
		}

		//解密
		srv.random, rawXMLMsgBytes, err = util.DecryptMsg(srv.AppID, encryptedXMLMsg.EncryptedMsg, srv.EncodingAESKey)
		if err != nil {
			return nil, fmt.Errorf("消息解密失败, err=%v", err)
		}
	} else {
		rawXMLMsgBytes, err = ioutil.ReadAll(srv.Request.Body)
		if err != nil {
			return nil, fmt.Errorf("从body中解析xml失败, err=%v", err)
		}
	}

	srv.requestRawXMLMsg = rawXMLMsgBytes

	return srv.parseRequestMessage(rawXMLMsgBytes)
}
890959
func GetRelayMessageOption(o dhcp6.Options) (RelayMessageOption, error) {
	v, err := o.GetOne(dhcp6.OptionRelayMsg)
	if err != nil {
		return nil, err
	}

	var r RelayMessageOption
	err = (&r).UnmarshalBinary(v)
	return r, err
}
1178922
func (cb *RedisCeleryBroker) GetTaskMessage() (*TaskMessage, error) {
	celeryMessage, err := cb.GetCeleryMessage()
	if err != nil {
		return nil, err
	}
	return celeryMessage.GetTaskMessage(), nil
}
1295236
func (a *vppClient) GetMsgID(msgName string, msgCrc string) (uint16, error) {
	nameAndCrc := C.CString(msgName + "_" + msgCrc)
	defer C.free(unsafe.Pointer(nameAndCrc))

	msgID := uint16(C.govpp_get_msg_index(nameAndCrc))
	if msgID == ^uint16(0) {
		// VPP does not know this message
		return msgID, fmt.Errorf("unknown message: %v (crc: %v)", msgName, msgCrc)
	}

	return msgID, nil
}
87676
func (c *Target) SendMessageToTarget(message string, sessionId string, targetId string) (*gcdmessage.ChromeResponse, error) {
	var v TargetSendMessageToTargetParams
	v.Message = message
	v.SessionId = sessionId
	v.TargetId = targetId
	return c.SendMessageToTargetWithParams(&v)
}
169965
func (whisper *Whisper) MaxMessageSize() uint32 {
	val, _ := whisper.settings.Load(maxMsgSizeIdx)
	return val.(uint32)
}
510841
func (d *DismissedReview) GetDismissalMessage() string {
	if d == nil || d.DismissalMessage == nil {
		return ""
	}
	return *d.DismissalMessage
}
473181
func (s *SaltpackUI) SaltpackVerifyBadSender(_ context.Context, arg keybase1.SaltpackVerifyBadSenderArg) error {
	// write messages to stderr
	var message string
	var errorReason string
	switch arg.Sender.SenderType {
	case keybase1.SaltpackSenderType_TRACKING_BROKE:
		message = fmt.Sprintf("Signed by %s, but their tracking statement is broken.", ColorString(s.G(), "bold", arg.Sender.Username))
		errorReason = "tracking statement broken"
	case keybase1.SaltpackSenderType_REVOKED:
		message = fmt.Sprintf("Signed by %s, but the key they used is revoked:\n    %s", ColorString(s.G(), "bold", arg.Sender.Username), arg.SigningKID.String())
		errorReason = "sender key revoked"
	case keybase1.SaltpackSenderType_EXPIRED:
		message = fmt.Sprintf("Signed by %s, but the key they used is expired:\n    %s", ColorString(s.G(), "bold", arg.Sender.Username), arg.SigningKID.String())
		errorReason = "sender key expired"
	default:
		return fmt.Errorf("Unexpected bad sender type: %s", arg.Sender.SenderType)
	}
	w := s.terminal.ErrorWriter()
	fmt.Fprintf(w, ColorString(s.G(), "red", fmt.Sprintf("Problem verifying the sender: %s\n", message)))

	if s.force {
		return nil
	}
	fmt.Fprintf(w, ColorString(s.G(), "red", "Use --force to see the message anyway.\n"))
	return libkb.IdentifyFailedError{Assertion: arg.Sender.Username, Reason: errorReason}
}
1139016
func GetMessage(msg *Msg, hwnd uint32, MsgFilterMin uint32, MsgFilterMax uint32) (int32, error) {
	return int32(0), NewError(E_NOTIMPL)
}