diff --git a/pki/pki.go b/pki/pki.go index 30b31a9a9..1727d8a8b 100644 --- a/pki/pki.go +++ b/pki/pki.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/cloudflare/circl/sign" - "github.com/cloudflare/circl/sign/api" + "github.com/cloudflare/circl/sign/schemes" ) var allSchemesByOID map[string]sign.Scheme @@ -23,14 +23,14 @@ type pkixPrivKey struct { func init() { allSchemesByOID = make(map[string]sign.Scheme) - for _, scheme := range api.AllSchemes() { + for _, scheme := range schemes.All() { if cert, ok := scheme.(CertificateScheme); ok { allSchemesByOID[cert.Oid().String()] = scheme } } allSchemesByTLS = make(map[uint]sign.Scheme) - for _, scheme := range api.AllSchemes() { + for _, scheme := range schemes.All() { if tlsScheme, ok := scheme.(TLSScheme); ok { allSchemesByTLS[tlsScheme.TLSIdentifier()] = scheme } diff --git a/pki/pki_test.go b/pki/pki_test.go index 1f24cb27f..07d3ddd70 100644 --- a/pki/pki_test.go +++ b/pki/pki_test.go @@ -4,11 +4,11 @@ import ( "testing" "github.com/cloudflare/circl/pki" - "github.com/cloudflare/circl/sign/api" + "github.com/cloudflare/circl/sign/schemes" ) func TestPEM(t *testing.T) { - for _, scheme := range api.AllSchemes() { + for _, scheme := range schemes.All() { scheme := scheme t.Run(scheme.Name(), func(t *testing.T) { if scheme == nil { diff --git a/sign/api/api.go b/sign/schemes/schemes.go similarity index 61% rename from sign/api/api.go rename to sign/schemes/schemes.go index 44cd2e90d..587435251 100644 --- a/sign/api/api.go +++ b/sign/schemes/schemes.go @@ -1,5 +1,5 @@ -// Package api contains a register of signature algorithms. -package api +// Package schemes contains a register of signature algorithms. +package schemes import ( "github.com/cloudflare/circl/sign" @@ -25,9 +25,9 @@ func init() { } } -// SchemeByName returns the scheme with the given name and nil if it is not +// ByName returns the scheme with the given name and nil if it is not // supported. -func SchemeByName(name string) sign.Scheme { return allSchemeNames[name] } +func ByName(name string) sign.Scheme { return allSchemeNames[name] } -// AllSchemes returns all signature schemes supported. -func AllSchemes() []sign.Scheme { a := allSchemes; return a[:] } +// All returns all signature schemes supported. +func All() []sign.Scheme { a := allSchemes; return a[:] } diff --git a/sign/api/api_test.go b/sign/schemes/schemes_test.go similarity index 92% rename from sign/api/api_test.go rename to sign/schemes/schemes_test.go index f041cd4fb..b311a23a7 100644 --- a/sign/api/api_test.go +++ b/sign/schemes/schemes_test.go @@ -1,15 +1,15 @@ -package api_test +package schemes_test import ( "fmt" "testing" "github.com/cloudflare/circl/sign" - "github.com/cloudflare/circl/sign/api" + "github.com/cloudflare/circl/sign/schemes" ) func TestApi(t *testing.T) { - allSchemes := api.AllSchemes() + allSchemes := schemes.All() for _, scheme := range allSchemes { scheme := scheme t.Run(scheme.Name(), func(t *testing.T) { @@ -86,7 +86,7 @@ func TestApi(t *testing.T) { t.FailNow() } - scheme2 := api.SchemeByName(scheme.Name()) + scheme2 := schemes.ByName(scheme.Name()) if scheme2 == nil || scheme2 != scheme { t.FailNow() } diff --git a/sign/sign.go b/sign/sign.go index 56b6095ae..f16425493 100644 --- a/sign/sign.go +++ b/sign/sign.go @@ -1,4 +1,8 @@ // Package sign provides unified interfaces for signature schemes. +// +// A register of schemes is available in the package +// +// github.com/cloudflare/circl/sign/schemes package sign import (