Update dependencies (#5518)

This commit is contained in:
hongming
2023-02-12 23:09:20 +08:00
committed by GitHub
parent d3b35fb2da
commit a979342f56
1486 changed files with 126660 additions and 71128 deletions

View File

@@ -4,8 +4,8 @@
// If you do not care about the details, the only things that you
// would need to use are the following functions:
//
// jws.SignWithOption(Payload, algorithm, key)
// jws.Verify(encodedjws, algorithm, key)
// jws.SignWithOption(Payload, algorithm, key)
// jws.Verify(encodedjws, algorithm, key)
//
// To sign, simply use `jws.SignWithOption`. `Payload` is a []byte buffer that
// contains whatever data you want to sign. `alg` is one of the
@@ -38,7 +38,6 @@ import (
// SignLiteral generates a Signature for the given Payload and Headers, and serializes
// it in compact serialization format. In this format you may NOT use
// multiple signers.
//
func SignLiteral(payload []byte, alg jwa.SignatureAlgorithm, key interface{}, hdrBuf []byte, rnd io.Reader) ([]byte, error) {
encodedHdr := base64.RawURLEncoding.EncodeToString(hdrBuf)
encodedPayload := base64.RawURLEncoding.EncodeToString(payload)

View File

@@ -4,11 +4,11 @@ import (
"crypto/hmac"
"crypto/sha256"
"crypto/sha512"
"errors"
"fmt"
"hash"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
"github.com/pkg/errors"
)
var hmacSignFuncs = map[jwa.SignatureAlgorithm]hmacSignFunc{}
@@ -29,7 +29,7 @@ func init() {
func newHMAC(alg jwa.SignatureAlgorithm) (*HMACSigner, error) {
signer, ok := hmacSignFuncs[alg]
if !ok {
return nil, errors.Errorf(`unsupported algorithm while trying to create HMAC signer: %s`, alg)
return nil, fmt.Errorf(`unsupported algorithm while trying to create HMAC signer: %s`, alg)
}
return &HMACSigner{
@@ -55,7 +55,7 @@ func (s HMACSigner) Algorithm() jwa.SignatureAlgorithm {
func (s HMACSigner) Sign(payload []byte, key interface{}) ([]byte, error) {
hmackey, ok := key.([]byte)
if !ok {
return nil, errors.Errorf(`invalid key type %T. []byte is required`, key)
return nil, fmt.Errorf(`invalid key type %T. []byte is required`, key)
}
if len(hmackey) == 0 {

View File

@@ -4,10 +4,10 @@ import (
"crypto"
"crypto/rand"
"crypto/rsa"
"errors"
"fmt"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
"github.com/pkg/errors"
)
var rsaSignFuncs = map[jwa.SignatureAlgorithm]rsaSignFunc{}
@@ -69,7 +69,7 @@ func makeSignPSS(hash crypto.Hash) rsaSignFunc {
func newRSA(alg jwa.SignatureAlgorithm) (*RSASigner, error) {
signfn, ok := rsaSignFuncs[alg]
if !ok {
return nil, errors.Errorf(`unsupported algorithm while trying to create RSA signer: %s`, alg)
return nil, fmt.Errorf(`unsupported algorithm while trying to create RSA signer: %s`, alg)
}
return &RSASigner{
alg: alg,
@@ -90,7 +90,7 @@ func (s RSASigner) Sign(payload []byte, key interface{}) ([]byte, error) {
}
rsakey, ok := key.(*rsa.PrivateKey)
if !ok {
return nil, errors.Errorf(`invalid key type %T. *rsa.PrivateKey is required`, key)
return nil, fmt.Errorf(`invalid key type %T. *rsa.PrivateKey is required`, key)
}
return s.sign(payload, rsakey)

View File

@@ -5,8 +5,6 @@ import (
"encoding/pem"
"fmt"
"github.com/pkg/errors"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
)
@@ -20,7 +18,7 @@ func New(alg jwa.SignatureAlgorithm) (Signer, error) {
case jwa.HS256, jwa.HS384, jwa.HS512:
return newHMAC(alg)
default:
return nil, errors.Errorf(`unsupported signature algorithm %s`, alg)
return nil, fmt.Errorf(`unsupported signature algorithm %s`, alg)
}
}
@@ -62,6 +60,6 @@ func GetSigningKey(key string, alg jwa.SignatureAlgorithm) (interface{}, error)
case jwa.HS256, jwa.HS384, jwa.HS512:
return []byte(key), nil
default:
return nil, errors.Errorf("unsupported signature algorithm: %s", alg)
return nil, fmt.Errorf("unsupported signature algorithm: %s", alg)
}
}

View File

@@ -3,10 +3,10 @@ package verify
import (
"crypto"
"crypto/ecdsa"
"errors"
"fmt"
"math/big"
"github.com/pkg/errors"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
)
@@ -45,7 +45,7 @@ func makeECDSAVerifyFunc(hash crypto.Hash) ecdsaVerifyFunc {
func newECDSA(alg jwa.SignatureAlgorithm) (*ECDSAVerifier, error) {
verifyfn, ok := ecdsaVerifyFuncs[alg]
if !ok {
return nil, errors.Errorf(`unsupported algorithm while trying to create ECDSA verifier: %s`, alg)
return nil, fmt.Errorf(`unsupported algorithm while trying to create ECDSA verifier: %s`, alg)
}
return &ECDSAVerifier{
@@ -60,7 +60,7 @@ func (v ECDSAVerifier) Verify(payload []byte, signature []byte, key interface{})
}
ecdsakey, ok := key.(*ecdsa.PublicKey)
if !ok {
return errors.Errorf(`invalid key type %T. *ecdsa.PublicKey is required`, key)
return fmt.Errorf(`invalid key type %T. *ecdsa.PublicKey is required`, key)
}
return v.verify(payload, signature, ecdsakey)

View File

@@ -2,11 +2,11 @@ package verify
import (
"crypto/hmac"
"errors"
"fmt"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
"github.com/open-policy-agent/opa/internal/jwx/jws/sign"
"github.com/pkg/errors"
)
func newHMAC(alg jwa.SignatureAlgorithm) (*HMACVerifier, error) {

View File

@@ -3,10 +3,10 @@ package verify
import (
"crypto"
"crypto/rsa"
"errors"
"fmt"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
"github.com/pkg/errors"
)
var rsaVerifyFuncs = map[jwa.SignatureAlgorithm]rsaVerifyFunc{}
@@ -66,7 +66,7 @@ func makeVerifyPSS(hash crypto.Hash) rsaVerifyFunc {
func newRSA(alg jwa.SignatureAlgorithm) (*RSAVerifier, error) {
verifyfn, ok := rsaVerifyFuncs[alg]
if !ok {
return nil, errors.Errorf(`unsupported algorithm while trying to create RSA verifier: %s`, alg)
return nil, fmt.Errorf(`unsupported algorithm while trying to create RSA verifier: %s`, alg)
}
return &RSAVerifier{
@@ -81,7 +81,7 @@ func (v RSAVerifier) Verify(payload, signature []byte, key interface{}) error {
}
rsaKey, ok := key.(*rsa.PublicKey)
if !ok {
return errors.Errorf(`invalid key type %T. *rsa.PublicKey is required`, key)
return fmt.Errorf(`invalid key type %T. *rsa.PublicKey is required`, key)
}
return v.verify(payload, signature, rsaKey)

View File

@@ -7,8 +7,6 @@ import (
"encoding/pem"
"fmt"
"github.com/pkg/errors"
"github.com/open-policy-agent/opa/internal/jwx/jwa"
)
@@ -23,7 +21,7 @@ func New(alg jwa.SignatureAlgorithm) (Verifier, error) {
case jwa.HS256, jwa.HS384, jwa.HS512:
return newHMAC(alg)
default:
return nil, errors.Errorf(`unsupported signature algorithm: %s`, alg)
return nil, fmt.Errorf(`unsupported signature algorithm: %s`, alg)
}
}
@@ -52,6 +50,6 @@ func GetSigningKey(key string, alg jwa.SignatureAlgorithm) (interface{}, error)
case jwa.HS256, jwa.HS384, jwa.HS512:
return []byte(key), nil
default:
return nil, errors.Errorf("unsupported signature algorithm: %s", alg)
return nil, fmt.Errorf("unsupported signature algorithm: %s", alg)
}
}