add support for ed25519 httpsig keys
This commit is contained in:
parent
7e2a8c0457
commit
d6e1690192
|
@ -17,7 +17,6 @@ package main
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rsa"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -58,11 +57,11 @@ func friendorfoe(ct string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func PostJunk(keyname string, key *rsa.PrivateKey, url string, j junk.Junk) error {
|
||||
func PostJunk(keyname string, key httpsig.PrivateKey, url string, j junk.Junk) error {
|
||||
return PostMsg(keyname, key, url, j.ToBytes())
|
||||
}
|
||||
|
||||
func PostMsg(keyname string, key *rsa.PrivateKey, url string, msg []byte) error {
|
||||
func PostMsg(keyname string, key httpsig.PrivateKey, url string, msg []byte) error {
|
||||
client := http.DefaultClient
|
||||
req, err := http.NewRequest("POST", url, bytes.NewReader(msg))
|
||||
if err != nil {
|
||||
|
|
16
fun.go
16
fun.go
|
@ -17,7 +17,6 @@ package main
|
|||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/sha512"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
@ -594,10 +593,11 @@ func ziggy(userid int64) *KeyInfo {
|
|||
return ki
|
||||
}
|
||||
|
||||
var zaggies = cache.New(cache.Options{Filler: func(keyname string) (*rsa.PublicKey, bool) {
|
||||
var zaggies = cache.New(cache.Options{Filler: func(keyname string) (httpsig.PublicKey, bool) {
|
||||
var data string
|
||||
row := stmtGetXonker.QueryRow(keyname, "pubkey")
|
||||
err := row.Scan(&data)
|
||||
var key httpsig.PublicKey
|
||||
if err != nil {
|
||||
log.Printf("hitting the webs for missing pubkey: %s", keyname)
|
||||
j, err := GetJunk(keyname)
|
||||
|
@ -605,7 +605,7 @@ var zaggies = cache.New(cache.Options{Filler: func(keyname string) (*rsa.PublicK
|
|||
log.Printf("error getting %s pubkey: %s", keyname, err)
|
||||
when := time.Now().UTC().Format(dbtimeformat)
|
||||
stmtSaveXonker.Exec(keyname, "failed", "pubkey", when)
|
||||
return nil, true
|
||||
return key, true
|
||||
}
|
||||
allinjest(originate(keyname), j)
|
||||
row = stmtGetXonker.QueryRow(keyname, "pubkey")
|
||||
|
@ -614,19 +614,19 @@ var zaggies = cache.New(cache.Options{Filler: func(keyname string) (*rsa.PublicK
|
|||
log.Printf("key not found after ingesting")
|
||||
when := time.Now().UTC().Format(dbtimeformat)
|
||||
stmtSaveXonker.Exec(keyname, "failed", "pubkey", when)
|
||||
return nil, true
|
||||
return key, true
|
||||
}
|
||||
}
|
||||
_, key, err := httpsig.DecodeKey(data)
|
||||
_, key, err = httpsig.DecodeKey(data)
|
||||
if err != nil {
|
||||
log.Printf("error decoding %s pubkey: %s", keyname, err)
|
||||
return nil, true
|
||||
return key, true
|
||||
}
|
||||
return key, true
|
||||
}, Limit: 512})
|
||||
|
||||
func zaggy(keyname string) *rsa.PublicKey {
|
||||
var key *rsa.PublicKey
|
||||
func zaggy(keyname string) httpsig.PublicKey {
|
||||
var key httpsig.PublicKey
|
||||
zaggies.Get(keyname, &key)
|
||||
return key
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -7,7 +7,7 @@ require (
|
|||
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859
|
||||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3
|
||||
humungus.tedunangst.com/r/webs v0.6.31
|
||||
humungus.tedunangst.com/r/webs v0.6.34
|
||||
)
|
||||
|
||||
go 1.11
|
||||
|
|
2
go.sum
2
go.sum
|
@ -25,3 +25,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9
|
|||
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
|
||||
humungus.tedunangst.com/r/webs v0.6.31 h1:xDgtESuVljephZA4GfcycwiOwJeeJYUIQbStFHceN1Y=
|
||||
humungus.tedunangst.com/r/webs v0.6.31/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
|
||||
humungus.tedunangst.com/r/webs v0.6.34 h1:C9S5L310Z1H4H681f/e4zwqGJLR53XoCTwDoHAq7UVo=
|
||||
humungus.tedunangst.com/r/webs v0.6.34/go.mod h1:S9sXpVSbgAIa24yYhnMN0C94LKHG+2rioS+NsiDimps=
|
||||
|
|
7
honk.go
7
honk.go
|
@ -16,7 +16,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/rsa"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
|
@ -26,6 +25,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"humungus.tedunangst.com/r/webs/httpsig"
|
||||
)
|
||||
|
||||
var softwareVersion = "develop"
|
||||
|
@ -42,7 +43,7 @@ type WhatAbout struct {
|
|||
Key string
|
||||
URL string
|
||||
Options UserOptions
|
||||
SecKey *rsa.PrivateKey
|
||||
SecKey httpsig.PrivateKey
|
||||
}
|
||||
|
||||
type UserOptions struct {
|
||||
|
@ -54,7 +55,7 @@ type UserOptions struct {
|
|||
|
||||
type KeyInfo struct {
|
||||
keyname string
|
||||
seckey *rsa.PrivateKey
|
||||
seckey httpsig.PrivateKey
|
||||
}
|
||||
|
||||
const serverUID int64 = -2
|
||||
|
|
Loading…
Reference in New Issue