diff options
Diffstat (limited to 'vendor/golang.org/x/crypto')
| -rw-r--r-- | vendor/golang.org/x/crypto/AUTHORS | 3 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/CONTRIBUTORS | 3 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/acme/acme.go | 14 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/acme/autocert/cache.go | 6 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/acme/jws.go | 37 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/acme/rfc8555.go | 39 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/chacha20/chacha_generic.go | 4 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/curve25519/curve25519.go | 9 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/internal/alias/alias.go (renamed from vendor/golang.org/x/crypto/internal/subtle/aliasing.go) | 5 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/internal/alias/alias_purego.go (renamed from vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go) | 5 | ||||
| -rw-r--r-- | vendor/golang.org/x/crypto/ssh/certs.go | 2 | 
11 files changed, 100 insertions, 27 deletions
diff --git a/vendor/golang.org/x/crypto/AUTHORS b/vendor/golang.org/x/crypto/AUTHORS deleted file mode 100644 index 2b00ddba0..000000000 --- a/vendor/golang.org/x/crypto/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at https://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/crypto/CONTRIBUTORS b/vendor/golang.org/x/crypto/CONTRIBUTORS deleted file mode 100644 index 1fbd3e976..000000000 --- a/vendor/golang.org/x/crypto/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at https://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/crypto/acme/acme.go b/vendor/golang.org/x/crypto/acme/acme.go index 2c86df354..7f1cd80c0 100644 --- a/vendor/golang.org/x/crypto/acme/acme.go +++ b/vendor/golang.org/x/crypto/acme/acme.go @@ -306,6 +306,20 @@ func (c *Client) UpdateReg(ctx context.Context, acct *Account) (*Account, error)  	return c.updateRegRFC(ctx, acct)  } +// AccountKeyRollover attempts to transition a client's account key to a new key. +// On success client's Key is updated which is not concurrency safe. +// On failure an error will be returned. +// The new key is already registered with the ACME provider if the following is true: +//   - error is of type acme.Error +//   - StatusCode should be 409 (Conflict) +//   - Location header will have the KID of the associated account +// +// More about account key rollover can be found at +// https://tools.ietf.org/html/rfc8555#section-7.3.5. +func (c *Client) AccountKeyRollover(ctx context.Context, newKey crypto.Signer) error { +	return c.accountKeyRollover(ctx, newKey) +} +  // Authorize performs the initial step in the pre-authorization flow,  // as opposed to order-based flow.  // The caller will then need to choose from and perform a set of returned diff --git a/vendor/golang.org/x/crypto/acme/autocert/cache.go b/vendor/golang.org/x/crypto/acme/autocert/cache.go index 03f63022f..3156a081f 100644 --- a/vendor/golang.org/x/crypto/acme/autocert/cache.go +++ b/vendor/golang.org/x/crypto/acme/autocert/cache.go @@ -41,7 +41,7 @@ type DirCache string  // Get reads a certificate data from the specified file name.  func (d DirCache) Get(ctx context.Context, name string) ([]byte, error) { -	name = filepath.Join(string(d), name) +	name = filepath.Join(string(d), filepath.Clean("/"+name))  	var (  		data []byte  		err  error @@ -82,7 +82,7 @@ func (d DirCache) Put(ctx context.Context, name string, data []byte) error {  		case <-ctx.Done():  			// Don't overwrite the file if the context was canceled.  		default: -			newName := filepath.Join(string(d), name) +			newName := filepath.Join(string(d), filepath.Clean("/"+name))  			err = os.Rename(tmp, newName)  		}  	}() @@ -96,7 +96,7 @@ func (d DirCache) Put(ctx context.Context, name string, data []byte) error {  // Delete removes the specified file name.  func (d DirCache) Delete(ctx context.Context, name string) error { -	name = filepath.Join(string(d), name) +	name = filepath.Join(string(d), filepath.Clean("/"+name))  	var (  		err  error  		done = make(chan struct{}) diff --git a/vendor/golang.org/x/crypto/acme/jws.go b/vendor/golang.org/x/crypto/acme/jws.go index 403e5b0c2..b38828d85 100644 --- a/vendor/golang.org/x/crypto/acme/jws.go +++ b/vendor/golang.org/x/crypto/acme/jws.go @@ -33,6 +33,10 @@ const noKeyID = KeyID("")  // See https://tools.ietf.org/html/rfc8555#section-6.3 for more details.  const noPayload = "" +// noNonce indicates that the nonce should be omitted from the protected header. +// See jwsEncodeJSON for details. +const noNonce = "" +  // jsonWebSignature can be easily serialized into a JWS following  // https://tools.ietf.org/html/rfc7515#section-3.2.  type jsonWebSignature struct { @@ -45,10 +49,15 @@ type jsonWebSignature struct {  // The result is serialized in JSON format containing either kid or jwk  // fields based on the provided KeyID value.  // -// If kid is non-empty, its quoted value is inserted in the protected head +// The claimset is marshalled using json.Marshal unless it is a string. +// In which case it is inserted directly into the message. +// +// If kid is non-empty, its quoted value is inserted in the protected header  // as "kid" field value. Otherwise, JWK is computed using jwkEncode and inserted  // as "jwk" field value. The "jwk" and "kid" fields are mutually exclusive.  // +// If nonce is non-empty, its quoted value is inserted in the protected header. +//  // See https://tools.ietf.org/html/rfc7515#section-7.  func jwsEncodeJSON(claimset interface{}, key crypto.Signer, kid KeyID, nonce, url string) ([]byte, error) {  	if key == nil { @@ -58,20 +67,36 @@ func jwsEncodeJSON(claimset interface{}, key crypto.Signer, kid KeyID, nonce, ur  	if alg == "" || !sha.Available() {  		return nil, ErrUnsupportedKey  	} -	var phead string +	headers := struct { +		Alg   string          `json:"alg"` +		KID   string          `json:"kid,omitempty"` +		JWK   json.RawMessage `json:"jwk,omitempty"` +		Nonce string          `json:"nonce,omitempty"` +		URL   string          `json:"url"` +	}{ +		Alg:   alg, +		Nonce: nonce, +		URL:   url, +	}  	switch kid {  	case noKeyID:  		jwk, err := jwkEncode(key.Public())  		if err != nil {  			return nil, err  		} -		phead = fmt.Sprintf(`{"alg":%q,"jwk":%s,"nonce":%q,"url":%q}`, alg, jwk, nonce, url) +		headers.JWK = json.RawMessage(jwk)  	default: -		phead = fmt.Sprintf(`{"alg":%q,"kid":%q,"nonce":%q,"url":%q}`, alg, kid, nonce, url) +		headers.KID = string(kid) +	} +	phJSON, err := json.Marshal(headers) +	if err != nil { +		return nil, err  	} -	phead = base64.RawURLEncoding.EncodeToString([]byte(phead)) +	phead := base64.RawURLEncoding.EncodeToString([]byte(phJSON))  	var payload string -	if claimset != noPayload { +	if val, ok := claimset.(string); ok { +		payload = val +	} else {  		cs, err := json.Marshal(claimset)  		if err != nil {  			return nil, err diff --git a/vendor/golang.org/x/crypto/acme/rfc8555.go b/vendor/golang.org/x/crypto/acme/rfc8555.go index 928a5aa03..940e70b85 100644 --- a/vendor/golang.org/x/crypto/acme/rfc8555.go +++ b/vendor/golang.org/x/crypto/acme/rfc8555.go @@ -24,6 +24,9 @@ import (  //  // It only works with CAs implementing RFC 8555.  func (c *Client) DeactivateReg(ctx context.Context) error { +	if _, err := c.Discover(ctx); err != nil { // required by c.accountKID +		return err +	}  	url := string(c.accountKID(ctx))  	if url == "" {  		return ErrNoAccount @@ -148,6 +151,42 @@ func responseAccount(res *http.Response) (*Account, error) {  	}, nil  } +// accountKeyRollover attempts to perform account key rollover. +// On success it will change client.Key to the new key. +func (c *Client) accountKeyRollover(ctx context.Context, newKey crypto.Signer) error { +	dir, err := c.Discover(ctx) // Also required by c.accountKID +	if err != nil { +		return err +	} +	kid := c.accountKID(ctx) +	if kid == noKeyID { +		return ErrNoAccount +	} +	oldKey, err := jwkEncode(c.Key.Public()) +	if err != nil { +		return err +	} +	payload := struct { +		Account string          `json:"account"` +		OldKey  json.RawMessage `json:"oldKey"` +	}{ +		Account: string(kid), +		OldKey:  json.RawMessage(oldKey), +	} +	inner, err := jwsEncodeJSON(payload, newKey, noKeyID, noNonce, dir.KeyChangeURL) +	if err != nil { +		return err +	} + +	res, err := c.post(ctx, nil, dir.KeyChangeURL, base64.RawURLEncoding.EncodeToString(inner), wantStatus(http.StatusOK)) +	if err != nil { +		return err +	} +	defer res.Body.Close() +	c.Key = newKey +	return nil +} +  // AuthorizeOrder initiates the order-based application for certificate issuance,  // as opposed to pre-authorization in Authorize.  // It is only supported by CAs implementing RFC 8555. diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_generic.go b/vendor/golang.org/x/crypto/chacha20/chacha_generic.go index a2ecf5c32..93eb5ae6d 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_generic.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_generic.go @@ -12,7 +12,7 @@ import (  	"errors"  	"math/bits" -	"golang.org/x/crypto/internal/subtle" +	"golang.org/x/crypto/internal/alias"  )  const ( @@ -189,7 +189,7 @@ func (s *Cipher) XORKeyStream(dst, src []byte) {  		panic("chacha20: output smaller than input")  	}  	dst = dst[:len(src)] -	if subtle.InexactOverlap(dst, src) { +	if alias.InexactOverlap(dst, src) {  		panic("chacha20: invalid buffer overlap")  	} diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519.go b/vendor/golang.org/x/crypto/curve25519/curve25519.go index cda3fdd35..bc62161d6 100644 --- a/vendor/golang.org/x/crypto/curve25519/curve25519.go +++ b/vendor/golang.org/x/crypto/curve25519/curve25519.go @@ -9,7 +9,8 @@ package curve25519 // import "golang.org/x/crypto/curve25519"  import (  	"crypto/subtle" -	"fmt" +	"errors" +	"strconv"  	"golang.org/x/crypto/curve25519/internal/field"  ) @@ -124,10 +125,10 @@ func X25519(scalar, point []byte) ([]byte, error) {  func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) {  	var in [32]byte  	if l := len(scalar); l != 32 { -		return nil, fmt.Errorf("bad scalar length: %d, expected %d", l, 32) +		return nil, errors.New("bad scalar length: " + strconv.Itoa(l) + ", expected 32")  	}  	if l := len(point); l != 32 { -		return nil, fmt.Errorf("bad point length: %d, expected %d", l, 32) +		return nil, errors.New("bad point length: " + strconv.Itoa(l) + ", expected 32")  	}  	copy(in[:], scalar)  	if &point[0] == &Basepoint[0] { @@ -138,7 +139,7 @@ func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) {  		copy(base[:], point)  		ScalarMult(dst, &in, &base)  		if subtle.ConstantTimeCompare(dst[:], zero[:]) == 1 { -			return nil, fmt.Errorf("bad input point: low order point") +			return nil, errors.New("bad input point: low order point")  		}  	}  	return dst[:], nil diff --git a/vendor/golang.org/x/crypto/internal/subtle/aliasing.go b/vendor/golang.org/x/crypto/internal/alias/alias.go index 4fad24f8d..69c17f822 100644 --- a/vendor/golang.org/x/crypto/internal/subtle/aliasing.go +++ b/vendor/golang.org/x/crypto/internal/alias/alias.go @@ -5,9 +5,8 @@  //go:build !purego  // +build !purego -// Package subtle implements functions that are often useful in cryptographic -// code but require careful thought to use correctly. -package subtle // import "golang.org/x/crypto/internal/subtle" +// Package alias implements memory aliasing tests. +package alias  import "unsafe" diff --git a/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go b/vendor/golang.org/x/crypto/internal/alias/alias_purego.go index 80ccbed2c..4775b0a43 100644 --- a/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go +++ b/vendor/golang.org/x/crypto/internal/alias/alias_purego.go @@ -5,9 +5,8 @@  //go:build purego  // +build purego -// Package subtle implements functions that are often useful in cryptographic -// code but require careful thought to use correctly. -package subtle // import "golang.org/x/crypto/internal/subtle" +// Package alias implements memory aliasing tests. +package alias  // This is the Google App Engine standard variant based on reflect  // because the unsafe package and cgo are disallowed. diff --git a/vendor/golang.org/x/crypto/ssh/certs.go b/vendor/golang.org/x/crypto/ssh/certs.go index a69e22491..4600c2077 100644 --- a/vendor/golang.org/x/crypto/ssh/certs.go +++ b/vendor/golang.org/x/crypto/ssh/certs.go @@ -460,6 +460,8 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error {  // certKeyAlgoNames is a mapping from known certificate algorithm names to the  // corresponding public key signature algorithm. +// +// This map must be kept in sync with the one in agent/client.go.  var certKeyAlgoNames = map[string]string{  	CertAlgoRSAv01:        KeyAlgoRSA,  	CertAlgoRSASHA256v01:  KeyAlgoRSASHA256,  | 
