예제 #1
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)
            {
                Tracing.Information(
                    String.Format("Invalid payload hash {0} for data {1}", artifacts.PayloadHash.ToBase64String(),
                                  Encoding.UTF8.GetString(data)));
            }

            return(isHashValid);
        }
        /// <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();

                Tracing.Verbose("Normalized payload: " + Encoding.UTF8.GetString(data));

                responsePayloadHash = hasher.ComputeHash(data);
            }

            artifacts.PayloadHash = responsePayloadHash;

            byte[] normalizedRequest = this.normalizedRequest.ToBytes();
            artifacts.Mac = hasher.ComputeHmac(normalizedRequest, credential.Key);

            Tracing.Verbose("Normalized request: " + Encoding.UTF8.GetString(normalizedRequest));
        }
예제 #3
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();

                Tracing.Verbose("Normalized payload: " + Encoding.UTF8.GetString(data));

                responsePayloadHash = hasher.ComputeHash(data);
            }

            artifacts.PayloadHash = responsePayloadHash;

            byte[] normalizedRequest = this.normalizedRequest.ToBytes();
            artifacts.Mac = hasher.ComputeHmac(normalizedRequest, credential.Key);

            Tracing.Verbose("Normalized request: " + Encoding.UTF8.GetString(normalizedRequest));
        }
        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;
        }