tBug #23032 resolved. - tordam - A library for peer discovery inside the Tor network
 (HTM) git clone https://git.parazyd.org/tordam
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 0c8ccaabf122b19a04eb991da71177dbaef6bf2e
 (DIR) parent e4164289bf78ce6142d87fa4200d3c2fa2b61b67
 (HTM) Author: parazyd <parazyd@dyne.org>
       Date:   Thu,  7 Dec 2017 22:01:15 +0100
       
       Bug #23032 resolved.
       
       Diffstat:
         M go/lib/crypto.go                    |      18 ++++++------------
         M go/lib/helpers.go                   |      22 ++++++++++------------
       
       2 files changed, 16 insertions(+), 24 deletions(-)
       ---
 (DIR) diff --git a/go/lib/crypto.go b/go/lib/crypto.go
       t@@ -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
        }
 (DIR) diff --git a/go/lib/helpers.go b/go/lib/helpers.go
       t@@ -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
        }