Blame SOURCES/1001-vendor-patch-removed-backend-crypto.patch

05d305
patch removed backend crypto
05d305
05d305
the `Makefile` removed a few files containing (unused) crypto
05d305
algorithms from the vendor tarball, which are not used in Grafana.
05d305
This patch removes all references to the deleted files.
05d305
3d91f6
diff --git a/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go b/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
3d91f6
new file mode 100644
05d305
index 0000000000..871e612a61
3d91f6
--- /dev/null
3d91f6
+++ b/vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go
3d91f6
@@ -0,0 +1,25 @@
3d91f6
+package elgamal
3d91f6
+
3d91f6
+import (
3d91f6
+	"io"
3d91f6
+	"math/big"
3d91f6
+)
3d91f6
+
3d91f6
+// PublicKey represents an ElGamal public key.
3d91f6
+type PublicKey struct {
3d91f6
+	G, P, Y *big.Int
3d91f6
+}
3d91f6
+
3d91f6
+// PrivateKey represents an ElGamal private key.
3d91f6
+type PrivateKey struct {
3d91f6
+	PublicKey
3d91f6
+	X *big.Int
3d91f6
+}
3d91f6
+
3d91f6
+func Encrypt(random io.Reader, pub *PublicKey, msg []byte) (c1, c2 *big.Int, err error) {
3d91f6
+	panic("ElGamal encryption not available")
3d91f6
+}
3d91f6
+
3d91f6
+func Decrypt(priv *PrivateKey, c1, c2 *big.Int) (msg []byte, err error) {
3d91f6
+	panic("ElGamal encryption not available")
3d91f6
+}
3d91f6
diff --git a/vendor/golang.org/x/crypto/openpgp/packet/packet.go b/vendor/golang.org/x/crypto/openpgp/packet/packet.go
05d305
index 0a19794a8e..25a5ee9158 100644
3d91f6
--- a/vendor/golang.org/x/crypto/openpgp/packet/packet.go
3d91f6
+++ b/vendor/golang.org/x/crypto/openpgp/packet/packet.go
05d305
@@ -22,7 +22,6 @@ import (
3d91f6
 	"math/big"
3d91f6
 	"math/bits"
3d91f6
 
3d91f6
-	"golang.org/x/crypto/cast5"
3d91f6
 	"golang.org/x/crypto/openpgp/errors"
3d91f6
 )
3d91f6
 
05d305
@@ -493,7 +492,7 @@ func (cipher CipherFunction) KeySize() int {
3d91f6
 	case Cipher3DES:
3d91f6
 		return 24
3d91f6
 	case CipherCAST5:
3d91f6
-		return cast5.KeySize
3d91f6
+		panic("cast5 cipher not available")
3d91f6
 	case CipherAES128:
3d91f6
 		return 16
3d91f6
 	case CipherAES192:
05d305
@@ -523,7 +522,7 @@ func (cipher CipherFunction) new(key []byte) (block cipher.Block) {
3d91f6
 	case Cipher3DES:
3d91f6
 		block, _ = des.NewTripleDESCipher(key)
3d91f6
 	case CipherCAST5:
3d91f6
-		block, _ = cast5.NewCipher(key)
3d91f6
+		panic("cast5 cipher not available")
3d91f6
 	case CipherAES128, CipherAES192, CipherAES256:
3d91f6
 		block, _ = aes.NewCipher(key)
3d91f6
 	}
3d91f6
diff --git a/vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go b/vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go
05d305
index 6126030eb9..3a54c5f2b1 100644
3d91f6
--- a/vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go
3d91f6
+++ b/vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go
3d91f6
@@ -5,13 +5,12 @@
3d91f6
 package packet
3d91f6
 
3d91f6
 import (
3d91f6
-	"crypto/cipher"
3d91f6
 	"crypto/sha1"
3d91f6
 	"crypto/subtle"
3d91f6
-	"golang.org/x/crypto/openpgp/errors"
3d91f6
 	"hash"
3d91f6
 	"io"
3d91f6
-	"strconv"
3d91f6
+
3d91f6
+	"golang.org/x/crypto/openpgp/errors"
3d91f6
 )
3d91f6
 
3d91f6
 // SymmetricallyEncrypted represents a symmetrically encrypted byte string. The
3d91f6
@@ -45,46 +44,7 @@ func (se *SymmetricallyEncrypted) parse(r io.Reader) error {
3d91f6
 // packet can be read. An incorrect key can, with high probability, be detected
3d91f6
 // immediately and this will result in a KeyIncorrect error being returned.
3d91f6
 func (se *SymmetricallyEncrypted) Decrypt(c CipherFunction, key []byte) (io.ReadCloser, error) {
3d91f6
-	keySize := c.KeySize()
3d91f6
-	if keySize == 0 {
3d91f6
-		return nil, errors.UnsupportedError("unknown cipher: " + strconv.Itoa(int(c)))
3d91f6
-	}
3d91f6
-	if len(key) != keySize {
3d91f6
-		return nil, errors.InvalidArgumentError("SymmetricallyEncrypted: incorrect key length")
3d91f6
-	}
3d91f6
-
3d91f6
-	if se.prefix == nil {
3d91f6
-		se.prefix = make([]byte, c.blockSize()+2)
3d91f6
-		_, err := readFull(se.contents, se.prefix)
3d91f6
-		if err != nil {
3d91f6
-			return nil, err
3d91f6
-		}
3d91f6
-	} else if len(se.prefix) != c.blockSize()+2 {
3d91f6
-		return nil, errors.InvalidArgumentError("can't try ciphers with different block lengths")
3d91f6
-	}
3d91f6
-
3d91f6
-	ocfbResync := OCFBResync
3d91f6
-	if se.MDC {
3d91f6
-		// MDC packets use a different form of OCFB mode.
3d91f6
-		ocfbResync = OCFBNoResync
3d91f6
-	}
3d91f6
-
3d91f6
-	s := NewOCFBDecrypter(c.new(key), se.prefix, ocfbResync)
3d91f6
-	if s == nil {
3d91f6
-		return nil, errors.ErrKeyIncorrect
3d91f6
-	}
3d91f6
-
3d91f6
-	plaintext := cipher.StreamReader{S: s, R: se.contents}
3d91f6
-
3d91f6
-	if se.MDC {
3d91f6
-		// MDC packets have an embedded hash that we need to check.
3d91f6
-		h := sha1.New()
3d91f6
-		h.Write(se.prefix)
3d91f6
-		return &seMDCReader{in: plaintext, h: h}, nil
3d91f6
-	}
3d91f6
-
3d91f6
-	// Otherwise, we just need to wrap plaintext so that it's a valid ReadCloser.
3d91f6
-	return seReader{plaintext}, nil
3d91f6
+	panic("OCFB cipher not available")
3d91f6
 }
3d91f6
 
3d91f6
 // seReader wraps an io.Reader with a no-op Close method.
3d91f6
@@ -254,37 +214,5 @@ func (c noOpCloser) Close() error {
3d91f6
 // written.
3d91f6
 // If config is nil, sensible defaults will be used.
3d91f6
 func SerializeSymmetricallyEncrypted(w io.Writer, c CipherFunction, key []byte, config *Config) (contents io.WriteCloser, err error) {
3d91f6
-	if c.KeySize() != len(key) {
3d91f6
-		return nil, errors.InvalidArgumentError("SymmetricallyEncrypted.Serialize: bad key length")
3d91f6
-	}
3d91f6
-	writeCloser := noOpCloser{w}
3d91f6
-	ciphertext, err := serializeStreamHeader(writeCloser, packetTypeSymmetricallyEncryptedMDC)
3d91f6
-	if err != nil {
3d91f6
-		return
3d91f6
-	}
3d91f6
-
3d91f6
-	_, err = ciphertext.Write([]byte{symmetricallyEncryptedVersion})
3d91f6
-	if err != nil {
3d91f6
-		return
3d91f6
-	}
3d91f6
-
3d91f6
-	block := c.new(key)
3d91f6
-	blockSize := block.BlockSize()
3d91f6
-	iv := make([]byte, blockSize)
3d91f6
-	_, err = config.Random().Read(iv)
3d91f6
-	if err != nil {
3d91f6
-		return
3d91f6
-	}
3d91f6
-	s, prefix := NewOCFBEncrypter(block, iv, OCFBNoResync)
3d91f6
-	_, err = ciphertext.Write(prefix)
3d91f6
-	if err != nil {
3d91f6
-		return
3d91f6
-	}
3d91f6
-	plaintext := cipher.StreamWriter{S: s, W: ciphertext}
3d91f6
-
3d91f6
-	h := sha1.New()
3d91f6
-	h.Write(iv)
3d91f6
-	h.Write(iv[blockSize-2:])
3d91f6
-	contents = &seMDCWriter{w: plaintext, h: h}
3d91f6
-	return
3d91f6
+	panic("OCFB cipher not available")
3d91f6
 }
05d305
diff --git a/vendor/golang.org/x/crypto/pkcs12/crypto.go b/vendor/golang.org/x/crypto/pkcs12/crypto.go
05d305
index 484ca51b71..5f502b8df1 100644
05d305
--- a/vendor/golang.org/x/crypto/pkcs12/crypto.go
05d305
+++ b/vendor/golang.org/x/crypto/pkcs12/crypto.go
05d305
@@ -11,8 +11,6 @@ import (
05d305
 	"crypto/x509/pkix"
05d305
 	"encoding/asn1"
05d305
 	"errors"
05d305
-
05d305
-	"golang.org/x/crypto/pkcs12/internal/rc2"
05d305
 )
05d305
 
05d305
 var (
05d305
@@ -46,10 +44,6 @@ func (shaWithTripleDESCBC) deriveIV(salt, password []byte, iterations int) []byt
05d305
 
05d305
 type shaWith40BitRC2CBC struct{}
05d305
 
05d305
-func (shaWith40BitRC2CBC) create(key []byte) (cipher.Block, error) {
05d305
-	return rc2.New(key, len(key)*8)
05d305
-}
05d305
-
05d305
 func (shaWith40BitRC2CBC) deriveKey(salt, password []byte, iterations int) []byte {
05d305
 	return pbkdf(sha1Sum, 20, 64, salt, password, iterations, 1, 5)
05d305
 }
05d305
@@ -70,7 +64,7 @@ func pbDecrypterFor(algorithm pkix.AlgorithmIdentifier, password []byte) (cipher
05d305
 	case algorithm.Algorithm.Equal(oidPBEWithSHAAnd3KeyTripleDESCBC):
05d305
 		cipherType = shaWithTripleDESCBC{}
05d305
 	case algorithm.Algorithm.Equal(oidPBEWithSHAAnd40BitRC2CBC):
05d305
-		cipherType = shaWith40BitRC2CBC{}
05d305
+		panic("RC2 encryption not available")
05d305
 	default:
05d305
 		return nil, 0, NotImplementedError("algorithm " + algorithm.Algorithm.String() + " is not supported")
05d305
 	}
05d305
diff --git a/vendor/github.com/prometheus/exporter-toolkit/web/handler.go b/vendor/github.com/prometheus/exporter-toolkit/web/handler.go
05d305
index ae3ebc03b9..11dbc3c56e 100644
05d305
--- a/vendor/github.com/prometheus/exporter-toolkit/web/handler.go
05d305
+++ b/vendor/github.com/prometheus/exporter-toolkit/web/handler.go
05d305
@@ -16,13 +16,11 @@
05d305
 package web
05d305
 
05d305
 import (
05d305
-	"encoding/hex"
05d305
 	"fmt"
05d305
 	"net/http"
05d305
 	"sync"
05d305
 
05d305
 	"github.com/go-kit/log"
05d305
-	"golang.org/x/crypto/bcrypt"
05d305
 )
05d305
 
05d305
 // extraHTTPHeaders is a map of HTTP headers that can be added to HTTP
05d305
@@ -36,22 +34,6 @@ var extraHTTPHeaders = map[string][]string{
05d305
 	"Content-Security-Policy":   nil,
05d305
 }
05d305
 
05d305
-func validateUsers(configPath string) error {
05d305
-	c, err := getConfig(configPath)
05d305
-	if err != nil {
05d305
-		return err
05d305
-	}
05d305
-
05d305
-	for _, p := range c.Users {
05d305
-		_, err = bcrypt.Cost([]byte(p))
05d305
-		if err != nil {
05d305
-			return err
05d305
-		}
05d305
-	}
05d305
-
05d305
-	return nil
05d305
-}
05d305
-
05d305
 // validateHeaderConfig checks that the provided header configuration is correct.
05d305
 // It does not check the validity of all the values, only the ones which are
05d305
 // well-defined enumerations.
05d305
@@ -83,55 +65,3 @@ type webHandler struct {
05d305
 	// only once in parallel as this is CPU intensive.
05d305
 	bcryptMtx sync.Mutex
05d305
 }
05d305
-
05d305
-func (u *webHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
05d305
-	c, err := getConfig(u.tlsConfigPath)
05d305
-	if err != nil {
05d305
-		u.logger.Log("msg", "Unable to parse configuration", "err", err)
05d305
-		http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
05d305
-		return
05d305
-	}
05d305
-
05d305
-	// Configure http headers.
05d305
-	for k, v := range c.HTTPConfig.Header {
05d305
-		w.Header().Set(k, v)
05d305
-	}
05d305
-
05d305
-	if len(c.Users) == 0 {
05d305
-		u.handler.ServeHTTP(w, r)
05d305
-		return
05d305
-	}
05d305
-
05d305
-	user, pass, auth := r.BasicAuth()
05d305
-	if auth {
05d305
-		hashedPassword, validUser := c.Users[user]
05d305
-
05d305
-		if !validUser {
05d305
-			// The user is not found. Use a fixed password hash to
05d305
-			// prevent user enumeration by timing requests.
05d305
-			// This is a bcrypt-hashed version of "fakepassword".
05d305
-			hashedPassword = "$2y$10$QOauhQNbBCuQDKes6eFzPeMqBSjb7Mr5DUmpZ/VcEd00UAV/LDeSi"
05d305
-		}
05d305
-
05d305
-		cacheKey := hex.EncodeToString(append(append([]byte(user), []byte(hashedPassword)...), []byte(pass)...))
05d305
-		authOk, ok := u.cache.get(cacheKey)
05d305
-
05d305
-		if !ok {
05d305
-			// This user, hashedPassword, password is not cached.
05d305
-			u.bcryptMtx.Lock()
05d305
-			err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(pass))
05d305
-			u.bcryptMtx.Unlock()
05d305
-
05d305
-			authOk = err == nil
05d305
-			u.cache.set(cacheKey, authOk)
05d305
-		}
05d305
-
05d305
-		if authOk && validUser {
05d305
-			u.handler.ServeHTTP(w, r)
05d305
-			return
05d305
-		}
05d305
-	}
05d305
-
05d305
-	w.Header().Set("WWW-Authenticate", "Basic")
05d305
-	http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
05d305
-}
05d305
diff --git a/vendor/github.com/prometheus/exporter-toolkit/web/tls_config.go b/vendor/github.com/prometheus/exporter-toolkit/web/tls_config.go
05d305
index 2668964a06..291464ba7e 100644
05d305
--- a/vendor/github.com/prometheus/exporter-toolkit/web/tls_config.go
05d305
+++ b/vendor/github.com/prometheus/exporter-toolkit/web/tls_config.go
05d305
@@ -18,12 +18,8 @@ import (
05d305
 	"crypto/x509"
05d305
 	"fmt"
05d305
 	"io/ioutil"
05d305
-	"net"
05d305
-	"net/http"
05d305
 	"path/filepath"
05d305
 
05d305
-	"github.com/go-kit/log"
05d305
-	"github.com/go-kit/log/level"
05d305
 	"github.com/pkg/errors"
05d305
 	config_util "github.com/prometheus/common/config"
05d305
 	"gopkg.in/yaml.v2"
05d305
@@ -177,93 +173,6 @@ func ConfigToTLSConfig(c *TLSStruct) (*tls.Config, error) {
05d305
 	return cfg, nil
05d305
 }
05d305
 
05d305
-// ListenAndServe starts the server on the given address. Based on the file
05d305
-// tlsConfigPath, TLS or basic auth could be enabled.
05d305
-func ListenAndServe(server *http.Server, tlsConfigPath string, logger log.Logger) error {
05d305
-	listener, err := net.Listen("tcp", server.Addr)
05d305
-	if err != nil {
05d305
-		return err
05d305
-	}
05d305
-	defer listener.Close()
05d305
-	return Serve(listener, server, tlsConfigPath, logger)
05d305
-}
05d305
-
05d305
-// Server starts the server on the given listener. Based on the file
05d305
-// tlsConfigPath, TLS or basic auth could be enabled.
05d305
-func Serve(l net.Listener, server *http.Server, tlsConfigPath string, logger log.Logger) error {
05d305
-	if tlsConfigPath == "" {
05d305
-		level.Info(logger).Log("msg", "TLS is disabled.", "http2", false)
05d305
-		return server.Serve(l)
05d305
-	}
05d305
-
05d305
-	if err := validateUsers(tlsConfigPath); err != nil {
05d305
-		return err
05d305
-	}
05d305
-
05d305
-	// Setup basic authentication.
05d305
-	var handler http.Handler = http.DefaultServeMux
05d305
-	if server.Handler != nil {
05d305
-		handler = server.Handler
05d305
-	}
05d305
-
05d305
-	c, err := getConfig(tlsConfigPath)
05d305
-	if err != nil {
05d305
-		return err
05d305
-	}
05d305
-
05d305
-	server.Handler = &webHandler{
05d305
-		tlsConfigPath: tlsConfigPath,
05d305
-		logger:        logger,
05d305
-		handler:       handler,
05d305
-		cache:         newCache(),
05d305
-	}
05d305
-
05d305
-	config, err := ConfigToTLSConfig(&c.TLSConfig)
05d305
-	switch err {
05d305
-	case nil:
05d305
-		if !c.HTTPConfig.HTTP2 {
05d305
-			server.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler))
05d305
-		}
05d305
-		// Valid TLS config.
05d305
-		level.Info(logger).Log("msg", "TLS is enabled.", "http2", c.HTTPConfig.HTTP2)
05d305
-	case errNoTLSConfig:
05d305
-		// No TLS config, back to plain HTTP.
05d305
-		level.Info(logger).Log("msg", "TLS is disabled.", "http2", false)
05d305
-		return server.Serve(l)
05d305
-	default:
05d305
-		// Invalid TLS config.
05d305
-		return err
05d305
-	}
05d305
-
05d305
-	server.TLSConfig = config
05d305
-
05d305
-	// Set the GetConfigForClient method of the HTTPS server so that the config
05d305
-	// and certs are reloaded on new connections.
05d305
-	server.TLSConfig.GetConfigForClient = func(*tls.ClientHelloInfo) (*tls.Config, error) {
05d305
-		return getTLSConfig(tlsConfigPath)
05d305
-	}
05d305
-	return server.ServeTLS(l, "", "")
05d305
-}
05d305
-
05d305
-// Validate configuration file by reading the configuration and the certificates.
05d305
-func Validate(tlsConfigPath string) error {
05d305
-	if tlsConfigPath == "" {
05d305
-		return nil
05d305
-	}
05d305
-	if err := validateUsers(tlsConfigPath); err != nil {
05d305
-		return err
05d305
-	}
05d305
-	c, err := getConfig(tlsConfigPath)
05d305
-	if err != nil {
05d305
-		return err
05d305
-	}
05d305
-	_, err = ConfigToTLSConfig(&c.TLSConfig)
05d305
-	if err == errNoTLSConfig {
05d305
-		return nil
05d305
-	}
05d305
-	return err
05d305
-}
05d305
-
05d305
 type cipher uint16
05d305
 
05d305
 func (c *cipher) UnmarshalYAML(unmarshal func(interface{}) error) error {
05d305
@@ -346,11 +255,3 @@ func (tv *tlsVersion) MarshalYAML() (interface{}, error) {
05d305
 	}
05d305
 	return fmt.Sprintf("%v", tv), nil
05d305
 }
05d305
-
05d305
-// Listen starts the server on the given address. Based on the file
05d305
-// tlsConfigPath, TLS or basic auth could be enabled.
05d305
-//
05d305
-// Deprecated: Use ListenAndServe instead.
05d305
-func Listen(server *http.Server, tlsConfigPath string, logger log.Logger) error {
05d305
-	return ListenAndServe(server, tlsConfigPath, logger)
05d305
-}