mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-22 03:49:27 +01:00
bump go-dkim
This commit is contained in:
parent
c2671b0d57
commit
3de81013c0
2
go.mod
2
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
|
||||
|
2
go.sum
2
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=
|
||||
|
4
vendor/github.com/toorop/go-dkim/dkim.go
generated
vendored
4
vendor/github.com/toorop/go-dkim/dkim.go
generated
vendored
@ -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)
|
||||
}
|
||||
|
24
vendor/github.com/toorop/go-dkim/dkimHeader.go
generated
vendored
24
vendor/github.com/toorop/go-dkim/dkimHeader.go
generated
vendored
@ -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 {
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user