tor-dam

tor distributed announce mechanism (not a dht)
git clone https://git.parazyd.org/tor-dam
Log | Files | Refs | README | LICENSE

commit 0c8ccaabf122b19a04eb991da71177dbaef6bf2e
parent e4164289bf78ce6142d87fa4200d3c2fa2b61b67
Author: parazyd <parazyd@dyne.org>
Date:   Thu,  7 Dec 2017 22:01:15 +0100

Bug #23032 resolved.

Diffstat:
Mgo/lib/crypto.go | 18++++++------------
Mgo/lib/helpers.go | 22++++++++++------------
2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/go/lib/crypto.go b/go/lib/crypto.go @@ -136,19 +136,13 @@ func OnionFromPubkey(pubkey rsa.PublicKey) string { // ParsePubkey parses a []byte form of a RSA public key and returns the proper // type. func ParsePubkey(pubkey []byte) (*rsa.PublicKey, error) { - block, _ := pem.Decode(pubkey) - if block == nil { - return nil, errors.New("Failed to parse PEM block containing the public key.") - } + var pub rsa.PublicKey + var ret *rsa.PublicKey - // FIXME: Golang bug. Reported at: https://github.com/golang/go/issues/23032 - pub, err := x509.ParsePKIXPublicKey(block.Bytes) + block, _ := pem.Decode(pubkey) + _, err := asn1.Unmarshal(block.Bytes, &pub) CheckError(err) - switch pub := pub.(type) { - case *rsa.PublicKey: - return pub, nil - default: - return nil, errors.New("Invalid type of public key") - } + ret = &pub + return ret, nil } diff --git a/go/lib/helpers.go b/go/lib/helpers.go @@ -84,19 +84,17 @@ func ValidateReq(req map[string]string) ([]byte, bool) { pubkey = FetchHSPubkey(req["address"]) } - // FIXME: commented until bug 23032 is resolved. - // https://github.com/golang/go/issues/23032 // Validate signature. - /* - msg := []byte(req["message"]) - sig := []byte(req["signature"]) - pub := []byte(pubkey) - val, err := VerifyMsg(msg, sig, pub) - CheckError(err) - if val != true { - return false - } - */ + msg := []byte(req["message"]) + sig := []byte(req["signature"]) + pub, err := ParsePubkey([]byte(pubkey)) + CheckError(err) + + val, err := VerifyMsg(msg, sig, pub) + CheckError(err) + if val != true { + return nil, false + } return []byte(pubkey), true }