private bool IsHashValid(string body, string contentType)
        {
            var normalizedPayload = new NormalizedPayload(body, contentType);
            byte[] data = normalizedPayload.ToBytes();

            bool isHashValid = this.hasher.IsValidHash(data, artifacts.PayloadHash);

            if (!isHashValid)
                Tracing.Information(
                    String.Format("Invalid payload hash {0} for data {1}", artifacts.PayloadHash.ToBase64String(),
                                                                            Encoding.UTF8.GetString(data)));

            return isHashValid;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the payload hash and the corresponding HMAC, and updates the artifacts object
        /// with these new values.
        /// </summary>
        internal void Sign(string body = null, string contentType = null)
        {
            byte[] responsePayloadHash = null;
            if (body != null && contentType != null)
            {
                var    payload = new NormalizedPayload(body, contentType);
                byte[] data    = payload.ToBytes();

                responsePayloadHash = hasher.ComputeHash(data);
            }

            artifacts.PayloadHash = responsePayloadHash;

            byte[] normalizedRequest = this.normalizedRequest.ToBytes();
            artifacts.Mac = hasher.ComputeHmac(normalizedRequest, credential.Key);
        }
        /// <summary>
        /// Creates the payload hash and the corresponding HMAC, and updates the artifacts object
        /// with these new values.
        /// </summary>
        internal void Sign(string body = null, string contentType = null)
        {
            byte[] responsePayloadHash = null;
            if (body != null && contentType != null)
            {
                var payload = new NormalizedPayload(body, contentType);
                byte[] data = payload.ToBytes();

                responsePayloadHash = hasher.ComputeHash(data);
            }

            artifacts.PayloadHash = responsePayloadHash;

            byte[] normalizedRequest = this.normalizedRequest.ToBytes();
            artifacts.Mac = hasher.ComputeHmac(normalizedRequest, credential.Key);
        }
Exemplo n.º 4
0
        private bool IsHashValid(string body, string contentType)
        {
            var normalizedPayload = new NormalizedPayload(body, contentType);

            byte[] data = normalizedPayload.ToBytes();

            bool isHashValid = this.hasher.IsValidHash(data, artifacts.PayloadHash);

            if (!isHashValid)
            {
                HawkEventSource.Log.Debug(
                    String.Format("Invalid payload hash {0} for data {1}",
                                  artifacts.PayloadHash.ToBase64String(), Encoding.UTF8.GetString(data)));
            }

            return(isHashValid);
        }