Skip to content

Commit

Permalink
rename sign/api to sign/schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
bwesterb committed Aug 6, 2020
1 parent 6564028 commit 3f119a5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pki/pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions pki/pki_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 6 additions & 6 deletions sign/api/api.go → sign/schemes/schemes.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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[:] }
8 changes: 4 additions & 4 deletions sign/api/api_test.go → sign/schemes/schemes_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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()
}
Expand Down
4 changes: 4 additions & 0 deletions sign/sign.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down

0 comments on commit 3f119a5

Please sign in to comment.