storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/cmd/config/identity/openid/ecdsa-sha3.go (about)

     1  // MinIO Cloud Storage, (C) 2020 MinIO, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  //go:build !fips
    16  // +build !fips
    17  
    18  package openid
    19  
    20  import (
    21  	"crypto"
    22  
    23  	"github.com/dgrijalva/jwt-go"
    24  
    25  	// Needed for SHA3 to work - See: https://golang.org/src/crypto/crypto.go?s=1034:1288
    26  	_ "golang.org/x/crypto/sha3" // There is no SHA-3 FIPS-140 2 compliant implementation
    27  )
    28  
    29  // Specific instances for EC256 and company
    30  var (
    31  	SigningMethodES3256 *jwt.SigningMethodECDSA
    32  	SigningMethodES3384 *jwt.SigningMethodECDSA
    33  	SigningMethodES3512 *jwt.SigningMethodECDSA
    34  )
    35  
    36  func init() {
    37  	// ES256
    38  	SigningMethodES3256 = &jwt.SigningMethodECDSA{Name: "ES3256", Hash: crypto.SHA3_256, KeySize: 32, CurveBits: 256}
    39  	jwt.RegisterSigningMethod(SigningMethodES3256.Alg(), func() jwt.SigningMethod {
    40  		return SigningMethodES3256
    41  	})
    42  
    43  	// ES384
    44  	SigningMethodES3384 = &jwt.SigningMethodECDSA{Name: "ES3384", Hash: crypto.SHA3_384, KeySize: 48, CurveBits: 384}
    45  	jwt.RegisterSigningMethod(SigningMethodES3384.Alg(), func() jwt.SigningMethod {
    46  		return SigningMethodES3384
    47  	})
    48  
    49  	// ES512
    50  	SigningMethodES3512 = &jwt.SigningMethodECDSA{Name: "ES3512", Hash: crypto.SHA3_512, KeySize: 66, CurveBits: 521}
    51  	jwt.RegisterSigningMethod(SigningMethodES3512.Alg(), func() jwt.SigningMethod {
    52  		return SigningMethodES3512
    53  	})
    54  }