all repos — honk @ afcec984663d7cf9c39ce88413a5f93942570a26

my fork of honk

signature failure fix: makeitworksomehowwithoutregardforkeycontinuity
Ted Unangst tedu@tedunangst.com
Sat, 20 Apr 2019 16:12:41 -0400
commit

afcec984663d7cf9c39ce88413a5f93942570a26

parent

e8a291302f6a296a1e377dea15ad14ca76e51413

3 files changed, 23 insertions(+), 8 deletions(-)

jump to
M fun.gofun.go

@@ -22,6 +22,7 @@ "fmt"

"html" "html/template" "log" + "net/http" "regexp" "strings" "sync"

@@ -301,6 +302,15 @@ ziggylock.Lock()

zaggies[keyname] = key ziggylock.Unlock() return +} + +func makeitworksomehowwithoutregardforkeycontinuity(keyname string, r *http.Request, payload []byte) (string, error) { + db := opendatabase() + db.Exec("delete from xonkers where xid = ?", keyname) + ziggylock.Lock() + delete(zaggies, keyname) + ziggylock.Unlock() + return zag(r, payload) } func thoudostbitethythumb(userid int64, who string) bool {
M honk.gohonk.go

@@ -301,12 +301,17 @@ }

keyname, err := zag(r, payload) if err != nil { log.Printf("inbox message failed signature: %s", err) - fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) - io.WriteString(fd, "bad signature:\n") - WriteJunk(fd, j) - io.WriteString(fd, "\n") - fd.Close() - return + if keyname != "" { + keyname, err = makeitworksomehowwithoutregardforkeycontinuity(keyname, r, payload) + } + if err != nil { + fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) + io.WriteString(fd, "bad signature:\n") + WriteJunk(fd, j) + io.WriteString(fd, "\n") + fd.Close() + return + } } what, _ := jsongetstring(j, "type") if what == "Like" {
M zig.gozig.go

@@ -124,7 +124,7 @@ }

key := zaggy(keyname) if key == nil { - return "", fmt.Errorf("no key for %s", keyname) + return keyname, fmt.Errorf("no key for %s", keyname) } headers := strings.Split(heads, " ") var stuff []string

@@ -146,7 +146,7 @@ h.Write([]byte(strings.Join(stuff, "\n")))

sig := b64s(bsig) err := rsa.VerifyPKCS1v15(key, crypto.SHA256, h.Sum(nil), sig) if err != nil { - return "", err + return keyname, err } return keyname, nil }