From 3de81013c03a5e2aa6b6efa0a2ecaa5d12653e88 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 1 Jun 2020 00:40:30 -0400 Subject: [PATCH] bump go-dkim --- go.mod | 2 +- go.sum | 2 ++ vendor/github.com/toorop/go-dkim/dkim.go | 4 ++-- .../github.com/toorop/go-dkim/dkimHeader.go | 24 +++++++++---------- vendor/modules.txt | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 78f0c80d..cd62f25f 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775 github.com/stretchr/testify v1.4.0 // indirect github.com/tidwall/buntdb v1.1.2 - github.com/toorop/go-dkim v0.0.0-20191019073156-897ad64a2eeb + github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 golang.org/x/text v0.3.2 gopkg.in/yaml.v2 v2.2.8 diff --git a/go.sum b/go.sum index 8b8bfb79..77f7772d 100644 --- a/go.sum +++ b/go.sum @@ -73,6 +73,8 @@ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 h1:Otn9S136ELckZ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563/go.mod h1:mLqSmt7Dv/CNneF2wfcChfN1rvapyQr01LGKnKex0DQ= github.com/toorop/go-dkim v0.0.0-20191019073156-897ad64a2eeb h1:ilDZC+k9r67aJqSOalZLtEVLO7Cmmsq5ftfcvLirc24= github.com/toorop/go-dkim v0.0.0-20191019073156-897ad64a2eeb/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns= +github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e h1:uZTp+hhFm+PCH0t0Px5oE+QYlVTwVJ+XKNQr7ct4Q7w= +github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708 h1:pXVtWnwHkrWD9ru3sDxY/qFK/bfc0egRovX91EjWjf4= golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/vendor/github.com/toorop/go-dkim/dkim.go b/vendor/github.com/toorop/go-dkim/dkim.go index 87ccea74..ab893e31 100644 --- a/vendor/github.com/toorop/go-dkim/dkim.go +++ b/vendor/github.com/toorop/go-dkim/dkim.go @@ -202,7 +202,7 @@ func Sign(email *[]byte, options SigOptions) error { // error: if an error occurs during verification func Verify(email *[]byte, opts ...DNSOpt) (verifyOutput, error) { // parse email - dkimHeader, err := newDkimHeaderFromEmail(email) + dkimHeader, err := GetHeader(email) if err != nil { if err == ErrDkimHeaderNotFound { return NOTSIGNED, ErrDkimHeaderNotFound @@ -254,7 +254,7 @@ func Verify(email *[]byte, opts ...DNSOpt) (verifyOutput, error) { } // compute sig - dkimHeaderCano, err := canonicalizeHeader(dkimHeader.RawForSign, strings.Split(dkimHeader.MessageCanonicalization, "/")[0]) + dkimHeaderCano, err := canonicalizeHeader(dkimHeader.rawForSign, strings.Split(dkimHeader.MessageCanonicalization, "/")[0]) if err != nil { return getVerifyOutput(TEMPFAIL, err, pubKey.FlagTesting) } diff --git a/vendor/github.com/toorop/go-dkim/dkimHeader.go b/vendor/github.com/toorop/go-dkim/dkimHeader.go index 60248573..14a289ee 100644 --- a/vendor/github.com/toorop/go-dkim/dkimHeader.go +++ b/vendor/github.com/toorop/go-dkim/dkimHeader.go @@ -10,7 +10,7 @@ import ( "time" ) -type dkimHeader struct { +type DKIMHeader struct { // Version This tag defines the version of DKIM // specification that applies to the signature record. // tag v @@ -193,12 +193,12 @@ type dkimHeader struct { // RawForsign represents the raw part (without canonicalization) of the header // used for computint sig in verify process - RawForSign string + rawForSign string } // NewDkimHeaderBySigOptions return a new DkimHeader initioalized with sigOptions value -func newDkimHeaderBySigOptions(options SigOptions) *dkimHeader { - h := new(dkimHeader) +func newDkimHeaderBySigOptions(options SigOptions) *DKIMHeader { + h := new(DKIMHeader) h.Version = "1" h.Algorithm = options.Algo h.MessageCanonicalization = options.Canonicalization @@ -218,10 +218,10 @@ func newDkimHeaderBySigOptions(options SigOptions) *dkimHeader { return h } -// NewFromEmail return a new DkimHeader by parsing an email +// GetHeader return a new DKIMHeader by parsing an email // Note: according to RFC 6376 an email can have multiple DKIM Header // in this case we return the last inserted or the last with d== mail from -func newDkimHeaderFromEmail(email *[]byte) (*dkimHeader, error) { +func GetHeader(email *[]byte) (*DKIMHeader, error) { m, err := mail.ReadMessage(bytes.NewReader(*email)) if err != nil { return nil, err @@ -265,7 +265,7 @@ func newDkimHeaderFromEmail(email *[]byte) (*dkimHeader, error) { } } - var keep *dkimHeader + var keep *DKIMHeader var keepErr error //for _, dk := range m.Header[textproto.CanonicalMIMEHeaderKey("DKIM-Signature")] { for _, h := range dkHeaders { @@ -291,8 +291,8 @@ func newDkimHeaderFromEmail(email *[]byte) (*dkimHeader, error) { } // parseDkHeader parse raw dkim header -func parseDkHeader(header string) (dkh *dkimHeader, err error) { - dkh = new(dkimHeader) +func parseDkHeader(header string) (dkh *DKIMHeader, err error) { + dkh = new(DKIMHeader) keyVal := strings.SplitN(header, ":", 2) @@ -300,10 +300,10 @@ func parseDkHeader(header string) (dkh *dkimHeader, err error) { if t == -1 { return nil, ErrDkimHeaderBTagNotFound } - dkh.RawForSign = header[0 : t+2] + dkh.rawForSign = header[0 : t+2] p := strings.IndexByte(header[t:], ';') if p != -1 { - dkh.RawForSign = dkh.RawForSign + header[t+p:] + dkh.rawForSign = dkh.rawForSign + header[t+p:] } // Mandatory @@ -452,7 +452,7 @@ func parseDkHeader(header string) (dkh *dkimHeader, err error) { // GetHeaderBase return base header for signers // Todo: some refactoring needed... -func (d *dkimHeader) getHeaderBaseForSigning(bodyHash string) string { +func (d *DKIMHeader) getHeaderBaseForSigning(bodyHash string) string { h := "DKIM-Signature: v=" + d.Version + "; a=" + d.Algorithm + "; q=" + strings.Join(d.QueryMethods, ":") + "; c=" + d.MessageCanonicalization + ";" + CRLF + TAB subh := "s=" + d.Selector + ";" if len(subh)+len(d.Domain)+4 > MaxHeaderLineLength { diff --git a/vendor/modules.txt b/vendor/modules.txt index 36cc6449..c8efeefb 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -51,7 +51,7 @@ github.com/tidwall/rtree github.com/tidwall/rtree/base # github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 github.com/tidwall/tinyqueue -# github.com/toorop/go-dkim v0.0.0-20191019073156-897ad64a2eeb +# github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e ## explicit github.com/toorop/go-dkim # golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073