From d7a1eab5beba4241dab4402c5cd268432d7b46cd Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 21 Mar 2020 08:20:16 +1000 Subject: Migrate to Go111Modules, Add Dockerfile and GoRelaser support --- vendor/github.com/wybiral/torgo/rsa.go | 46 ---------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 vendor/github.com/wybiral/torgo/rsa.go (limited to 'vendor/github.com/wybiral/torgo/rsa.go') diff --git a/vendor/github.com/wybiral/torgo/rsa.go b/vendor/github.com/wybiral/torgo/rsa.go deleted file mode 100644 index c0c49b6..0000000 --- a/vendor/github.com/wybiral/torgo/rsa.go +++ /dev/null @@ -1,46 +0,0 @@ -package torgo - -import ( - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "encoding/asn1" - "encoding/base32" - "encoding/base64" - "errors" - "strings" -) - -// OnionFromRSA returns an Onion instance from a 1024 bit RSA private key which -// can be used to start a hidden service with controller.AddOnion. -func OnionFromRSA(pri *rsa.PrivateKey) (*Onion, error) { - pub, ok := pri.Public().(*rsa.PublicKey) - if !ok { - return nil, errors.New("torgo: unable to extract *rsa.PublicKey") - } - serviceID, err := ServiceIDFromRSA(pub) - if err != nil { - return nil, err - } - der := x509.MarshalPKCS1PrivateKey(pri) - key := base64.StdEncoding.EncodeToString(der) - return &Onion{ - Ports: make(map[int]string), - ServiceID: serviceID, - PrivateKey: key, - PrivateKeyType: "RSA1024", - }, nil -} - -// ServiceIDFromRSA calculates a Tor service ID from an *rsa.PublicKey. -func ServiceIDFromRSA(pub *rsa.PublicKey) (string, error) { - der, err := asn1.Marshal(*pub) - if err != nil { - return "", err - } - // Onion id is base32(firstHalf(sha1(publicKeyDER))) - hash := sha1.Sum(der) - half := hash[:len(hash)/2] - serviceID := base32.StdEncoding.EncodeToString(half) - return strings.ToLower(serviceID), nil -} -- cgit v1.2.3