try fixing signing omg this suxass
This commit is contained in:
parent
d61228215e
commit
fea75f7200
@ -165,7 +165,7 @@ func (self *NNTPDaemon) WrapSign(nntp NNTPMessage) {
|
|||||||
if seed == nil {
|
if seed == nil {
|
||||||
log.Println("invalid secretkey will not sign")
|
log.Println("invalid secretkey will not sign")
|
||||||
} else {
|
} else {
|
||||||
pk, sec := seedToKeyPair(seed)
|
pk, sec := naclSeedToKeyPair(seed)
|
||||||
sig := msgidFrontendSign(sec, nntp.MessageID())
|
sig := msgidFrontendSign(sec, nntp.MessageID())
|
||||||
nntp.Headers().Add("X-Frontend-Signature", sig)
|
nntp.Headers().Add("X-Frontend-Signature", sig)
|
||||||
nntp.Headers().Add("X-Frontend-Pubkey", hexify(pk))
|
nntp.Headers().Add("X-Frontend-Pubkey", hexify(pk))
|
||||||
|
@ -921,7 +921,7 @@ func (self *httpFrontend) handle_postRequest(pr *postRequest, b bannedFunc, e er
|
|||||||
// pack it before sending so that the article is well formed
|
// pack it before sending so that the article is well formed
|
||||||
// sign if needed
|
// sign if needed
|
||||||
if len(tripcode_privkey) == 32 {
|
if len(tripcode_privkey) == 32 {
|
||||||
pk, _ := seedToKeyPair(tripcode_privkey)
|
pk, _ := naclSeedToKeyPair(tripcode_privkey)
|
||||||
nntp.headers.Set("X-PubKey-Ed25519", hexify(pk))
|
nntp.headers.Set("X-PubKey-Ed25519", hexify(pk))
|
||||||
nntp.Pack()
|
nntp.Pack()
|
||||||
err = self.daemon.store.RegisterPost(nntp)
|
err = self.daemon.store.RegisterPost(nntp)
|
||||||
|
@ -180,7 +180,7 @@ func signArticle(nntp NNTPMessage, seed []byte) (signed *nntpArticle, err error)
|
|||||||
mw.Write([]byte{10})
|
mw.Write([]byte{10})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// build keypair
|
// build keypair
|
||||||
pk, sk := seedToKeyPair(seed)
|
pk, sk := naclSeedToKeyPair(seed)
|
||||||
// sign it nigguh
|
// sign it nigguh
|
||||||
digest := sha.Sum(nil)
|
digest := sha.Sum(nil)
|
||||||
sig := cryptoSignFucky(digest, sk)
|
sig := cryptoSignFucky(digest, sk)
|
||||||
@ -188,8 +188,8 @@ func signArticle(nntp NNTPMessage, seed []byte) (signed *nntpArticle, err error)
|
|||||||
// log.Printf("signed %s pubkey=%s sig=%s hash=%s", nntp.MessageID(), pk, sig, hexify(digest))
|
// log.Printf("signed %s pubkey=%s sig=%s hash=%s", nntp.MessageID(), pk, sig, hexify(digest))
|
||||||
signed.headers.Set("X-Signature-Ed25519-SHA512", sig)
|
signed.headers.Set("X-Signature-Ed25519-SHA512", sig)
|
||||||
signed.headers.Set("X-PubKey-Ed25519", hexify(pk[:]))
|
signed.headers.Set("X-PubKey-Ed25519", hexify(pk[:]))
|
||||||
sig = cryptoSignProper(blake.Sum(nil), sk)
|
//sig = cryptoSignProper(blake.Sum(nil), sk)
|
||||||
signed.headers.Set("X-Signature-Ed25519-BLAKE2B", sig)
|
//signed.headers.Set("X-Signature-Ed25519-BLAKE2B", sig)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ func (self httpModUI) CheckPubkey(pubkey, scope string) (bool, error) {
|
|||||||
func (self httpModUI) CheckKey(privkey, scope string) (bool, error) {
|
func (self httpModUI) CheckKey(privkey, scope string) (bool, error) {
|
||||||
privkey_bytes, err := hex.DecodeString(privkey)
|
privkey_bytes, err := hex.DecodeString(privkey)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
pk, _ := seedToKeyPair(privkey_bytes)
|
pk, _ := naclSeedToKeyPair(privkey_bytes)
|
||||||
pubkey := hex.EncodeToString(pk)
|
pubkey := hex.EncodeToString(pk)
|
||||||
return self.CheckPubkey(pubkey, scope)
|
return self.CheckPubkey(pubkey, scope)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ func naclCryptoSignDetached(hash, sk []byte) []byte {
|
|||||||
return nacl.CryptoSignDetached(hash, sk)
|
return nacl.CryptoSignDetached(hash, sk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func seedToKeyPair(seed []byte) (pk, sk []byte) {
|
func naclSeedToKeyPair(seed []byte) (pk, sk []byte) {
|
||||||
kp := nacl.LoadSignKey(seed)
|
kp := nacl.LoadSignKey(seed)
|
||||||
defer kp.Free()
|
defer kp.Free()
|
||||||
pk, sk = kp.Public(), kp.Secret()
|
pk, sk = kp.Public(), kp.Secret()
|
||||||
|
@ -298,7 +298,7 @@ func ValidNewsgroup(newsgroup string) bool {
|
|||||||
|
|
||||||
func genKeypair() (pk, sk []byte) {
|
func genKeypair() (pk, sk []byte) {
|
||||||
sk = randbytes(32)
|
sk = randbytes(32)
|
||||||
pk, _ = seedToKeyPair(sk)
|
pk, _ = naclSeedToKeyPair(sk)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ func hexify(data []byte) string {
|
|||||||
// extract pubkey from secret key
|
// extract pubkey from secret key
|
||||||
// return as hex
|
// return as hex
|
||||||
func getSignPubkey(sk []byte) string {
|
func getSignPubkey(sk []byte) string {
|
||||||
pk, _ := seedToKeyPair(sk)
|
pk, _ := naclSeedToKeyPair(sk)
|
||||||
return hexify(pk)
|
return hexify(pk)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,31 +411,9 @@ func cryptoSignFucky(h, sk []byte) string {
|
|||||||
return hexify(sig)
|
return hexify(sig)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// convert seed to secret key
|
|
||||||
func seedToKeyPair(seed []byte) (pub ed25519.PublicKey, full ed25519.PrivateKey) {
|
|
||||||
pub = make(ed25519.PublicKey, ed25519.PublicKeySize)
|
|
||||||
full = make(ed25519.PrivateKey, ed25519.PrivateKeySize)
|
|
||||||
h := sha512.Sum512(seed)
|
|
||||||
seed = h[:]
|
|
||||||
seed[0] &= 248
|
|
||||||
seed[31] &= 127
|
|
||||||
seed[31] |= 64
|
|
||||||
var in [32]byte
|
|
||||||
var out [32]byte
|
|
||||||
copy(in[:], seed[0:32])
|
|
||||||
naclScalarBaseMult(&out, &in)
|
|
||||||
copy(pub[:], out[:])
|
|
||||||
copy(full[0:32], in[:])
|
|
||||||
copy(full[32:64], pub[:])
|
|
||||||
log.Println("pk=", hexify(pub[:]))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
func cryptoSignProper(h, sk []byte) string {
|
func cryptoSignProper(h, sk []byte) string {
|
||||||
// convert key
|
key := make(ed25519.PrivateKey, ed25519.PrivateKeySize)
|
||||||
_, key := seedToKeyPair(sk)
|
copy(key, sk)
|
||||||
// sign
|
// sign
|
||||||
sig := ed25519.Sign(key, h)
|
sig := ed25519.Sign(key, h)
|
||||||
if sig == nil {
|
if sig == nil {
|
||||||
|
Reference in New Issue
Block a user