Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email">The email to sign.</param>
        /// <returns></returns>
        public string GenerateSignature([NotNull] Email email)
        {
            if (email == null)
            {
                throw new ArgumentNullException("email");
            }

            if (email.Headers == null)
            {
                throw new ArgumentException("email headers property is null");
            }

            var headers = DkimCanonicalizer.CanonicalizeHeaders(email.Headers, this.HeaderCanonicalization, true, _headersToSign);

            //if (this.Debug != null)
            //{
            //    this.Debug.WriteContent("DKIM signature", email.Headers[SignatureKey].Value);
            //    this.Debug.WriteContent("DKIM canonicalized headers", headers);

            //}



            // assumes signature ends with "b="
            return(Convert.ToBase64String(_privateKeySigner.Sign(this.Encoding.GetBytes(headers), this.SigningAlgorithm)));
        }
Exemple #2
0
        public string SignSignature([NotNull] Email email)
        {
            var text = DomainKeyCanonicalizer.Canonicalize(email, this.Canonicalization, _headersToSign);

            Trace.WriteLine("DomainKey canonicalized headers:");
            Trace.WriteLine(text);
            //if (this.Debug != null)
            //{
            //    this.Debug.WriteContent("DomainKey canonicalized headers", text);
            //}

            return(Convert.ToBase64String(_privateKeySigner.Sign(this.Encoding.GetBytes(text), SigningAlgorithm.RSASha1)));
        }
Exemple #3
0
        private static string GenerateDkimSignature(Email email, Encoding encoding, IPrivateKeySigner privateKeySigner, string[] headersToSign)
        {
            if (email == null)
            {
                throw new ArgumentNullException("email");
            }

            if (email.Headers == null)
            {
                throw new ArgumentException("email headers property is null");
            }

            var headers = DkimCanonicalizer.CanonicalizeHeaders(email.Headers, dkimHeaderCanonicalization, true, headersToSign);

            // assumes signature ends with "b="
            return(Convert.ToBase64String(privateKeySigner.Sign(encoding.GetBytes(headers), dkimSigningAlgorithm)));
        }
Exemple #4
0
        private static string DomainKeySignSignature(Email email, Encoding encoding, IPrivateKeySigner privateKeySigner, string[] headersToSign)
        {
            var text = DomainKeyCanonicalizer.Canonicalize(email, domainKeyCanonicalization, headersToSign);

            return(Convert.ToBase64String(privateKeySigner.Sign(encoding.GetBytes(text), SigningAlgorithm.RSASha1)));
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="email">The email to sign.</param>
        /// <param name="headers"></param>
        /// <returns></returns>
        public string GenerateSignature(Email email, List <EmailHeader> headers)
        {
            var cheaders = DkimCanonicalizer.CanonicalizeHeaders(headers, HeaderCanonicalization);

            return(Convert.ToBase64String(_privateKeySigner.Sign(email.Encoding.GetBytes(cheaders))));
        }
Exemple #6
0
        public string SignSignature(Email email, List <EmailHeader> headers)
        {
            var text = DomainKeyCanonicalizer.Canonicalize(email, this.Canonicalization, headers);

            return(Convert.ToBase64String(_privateKeySigner.Sign(email.Encoding.GetBytes(text))));
        }