Skip to content

Commit

Permalink
Merge pull request #14 from katzenpost/sphincsplus_build_tags
Browse files Browse the repository at this point in the history
sign: only register supported signature schemes
  • Loading branch information
david415 authored May 10, 2024
2 parents 61d6e76 + 852d3a5 commit 83ff443
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
24 changes: 17 additions & 7 deletions sign/schemes/schemes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@ import (
"github.com/katzenpost/hpqc/sign/sphincsplus"
)

var allSchemes = [...]sign.Scheme{
// classical
ed25519.Scheme(),
ed448.Scheme(),

var potentialSchemes = [...]sign.Scheme{
// post quantum
sphincsplus.Scheme(),

// hybrid
// hybrid post quantum
hybrid.New("Ed25519 Sphincs+", ed25519.Scheme(), sphincsplus.Scheme()),
hybrid.New("Ed448-Sphincs+", ed448.Scheme(), sphincsplus.Scheme()),
}

var allSchemes = []sign.Scheme{
// classical
ed25519.Scheme(),
ed448.Scheme(),

// hybrid post quantum
eddilithium2.Scheme(),
eddilithium3.Scheme(),
}
Expand All @@ -35,6 +39,12 @@ var allSchemeNames map[string]sign.Scheme

func init() {
allSchemeNames = make(map[string]sign.Scheme)

for _, scheme := range potentialSchemes {
if scheme != nil {
allSchemes = append(allSchemes, scheme)
}
}
for _, scheme := range allSchemes {
allSchemeNames[strings.ToLower(scheme.Name())] = scheme
}
Expand All @@ -46,7 +56,7 @@ func ByName(name string) sign.Scheme {
return ret
}

// All returns all NIKE schemes supported.
// All returns all signature schemes supported.
func All() []sign.Scheme {
a := allSchemes
return a[:]
Expand Down
4 changes: 4 additions & 0 deletions sign/sphincsplus/sphincs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build (darwin || linux) && amd64
// +build darwin linux
// +build amd64

// SPDX-FileCopyrightText: (c) 2022-2024 David Stainton
// SPDX-License-Identifier: AGPL-3.0-only

Expand Down
9 changes: 9 additions & 0 deletions sign/sphincsplus/sphincs_not_supported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build (!darwin || !linux) && !amd64

package p

import "github.com/katzenpost/hpqc/sign"

func Scheme() sign.Scheme {
return nil
}
4 changes: 4 additions & 0 deletions sign/sphincsplus/sphincs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build (darwin || linux) && amd64
// +build darwin linux
// +build amd64

// SPDX-FileCopyrightText: (c) 2022-2024 David Stainton
// SPDX-License-Identifier: AGPL-3.0-only

Expand Down

0 comments on commit 83ff443

Please sign in to comment.