Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixup compat.1 #22

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nike/csidh/csidh.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ppc64le
//go:build amd64 || arm64

// csidh.go - Adapts csidh module to our NIKE interface.
// Copyright (C) 2022 David Stainton.
Expand Down Expand Up @@ -30,7 +30,7 @@ import (
)

// CSIDHScheme is the nobs CSIDH-512 NIKE.
var NOBS_CSIDH512Scheme *CsidhNike
var NOBS_CSIDH512Scheme nike.Scheme

var _ nike.PrivateKey = (*PrivateKey)(nil)
var _ nike.PublicKey = (*PublicKey)(nil)
Expand Down
7 changes: 7 additions & 0 deletions nike/csidh/csidh_not_supported.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !amd64 && !arm64

package csidh

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

var NOBS_CSIDH512Scheme nike.Scheme = nil
2 changes: 1 addition & 1 deletion nike/csidh/csidh_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !ppc64le
//go:build amd64 || arm64

package csidh

Expand Down
3 changes: 0 additions & 3 deletions nike/csidh/no_csidh.go

This file was deleted.

7 changes: 4 additions & 3 deletions nike/schemes/schemes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ var potentialSchemes = [...]nike.Scheme{
hybrid.CTIDH512X25519,
hybrid.CTIDH1024X25519,
hybrid.CTIDH2048X25519,

// NOBS CSIDH doesn't work on arm32
// XXX TODO: deprecate and remove.
hybrid.NOBS_CSIDH512X25519,
}

var allSchemes = []nike.Scheme{
Expand All @@ -36,9 +40,6 @@ var allSchemes = []nike.Scheme{
x25519.Scheme(rand.Reader),
x448.Scheme(rand.Reader),
diffiehellman.Scheme(),

// XXX TODO: deprecate and remove.
hybrid.NOBS_CSIDH512X25519,
}

var allSchemeNames map[string]nike.Scheme
Expand Down
8 changes: 5 additions & 3 deletions sign/ed25519/eddsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/katzenpost/hpqc/nike/x25519"
"github.com/katzenpost/hpqc/rand"
"github.com/katzenpost/hpqc/sign"
"github.com/katzenpost/hpqc/sign/pem"
"github.com/katzenpost/hpqc/util"
)

Expand Down Expand Up @@ -284,15 +285,16 @@ func (p *PublicKey) UnmarshalBinary(data []byte) error {
}

func (p *PublicKey) MarshalText() (text []byte, err error) {
return []byte(base64.StdEncoding.EncodeToString(p.Bytes())), nil
return pem.ToPublicPEMBytes(p), nil
}

func (p *PublicKey) UnmarshalText(text []byte) error {
raw, err := base64.StdEncoding.DecodeString(string(text))
pubkey, err := pem.FromPublicPEMString(string(text), p.Scheme())
if err != nil {
return err
}
return p.FromBytes(raw)
p = pubkey.(*PublicKey)
return nil
}

// NewKeypair generates a new PrivateKey sampled from the provided entropy
Expand Down
Loading