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

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