github.com/cloudflare/circl@v1.5.0/sign/schemes/schemes.go (about)

     1  // Package schemes contains a register of signature algorithms.
     2  //
     3  // Implemented schemes:
     4  //
     5  //	Ed25519
     6  //	Ed448
     7  //	Ed25519-Dilithium2
     8  //	Ed448-Dilithium3
     9  package schemes
    10  
    11  import (
    12  	"strings"
    13  
    14  	"github.com/cloudflare/circl/sign"
    15  	"github.com/cloudflare/circl/sign/ed25519"
    16  	"github.com/cloudflare/circl/sign/ed448"
    17  	"github.com/cloudflare/circl/sign/eddilithium2"
    18  	"github.com/cloudflare/circl/sign/eddilithium3"
    19  
    20  	dilithium2 "github.com/cloudflare/circl/sign/dilithium/mode2"
    21  	dilithium3 "github.com/cloudflare/circl/sign/dilithium/mode3"
    22  	dilithium5 "github.com/cloudflare/circl/sign/dilithium/mode5"
    23  	"github.com/cloudflare/circl/sign/mldsa/mldsa44"
    24  	"github.com/cloudflare/circl/sign/mldsa/mldsa65"
    25  	"github.com/cloudflare/circl/sign/mldsa/mldsa87"
    26  )
    27  
    28  var allSchemes = [...]sign.Scheme{
    29  	ed25519.Scheme(),
    30  	ed448.Scheme(),
    31  	eddilithium2.Scheme(),
    32  	eddilithium3.Scheme(),
    33  	dilithium2.Scheme(),
    34  	dilithium3.Scheme(),
    35  	dilithium5.Scheme(),
    36  	mldsa44.Scheme(),
    37  	mldsa65.Scheme(),
    38  	mldsa87.Scheme(),
    39  }
    40  
    41  var allSchemeNames map[string]sign.Scheme
    42  
    43  func init() {
    44  	allSchemeNames = make(map[string]sign.Scheme)
    45  	for _, scheme := range allSchemes {
    46  		allSchemeNames[strings.ToLower(scheme.Name())] = scheme
    47  	}
    48  }
    49  
    50  // ByName returns the scheme with the given name and nil if it is not
    51  // supported.
    52  //
    53  // Names are case insensitive.
    54  func ByName(name string) sign.Scheme {
    55  	return allSchemeNames[strings.ToLower(name)]
    56  }
    57  
    58  // All returns all signature schemes supported.
    59  func All() []sign.Scheme { a := allSchemes; return a[:] }